diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2010-04-02 16:11:46 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2010-04-02 16:11:46 +0200 |
commit | e7b09e4ab99fc850480480bbb577ffa36a6c5cd7 (patch) | |
tree | 878afa02cdb11fc78664ea8ce5ac542e897d91d2 /sysdep/linux | |
parent | 97ab4c34986139b2419c563a3de7ddfe41727d07 (diff) | |
download | bird-e7b09e4ab99fc850480480bbb577ffa36a6c5cd7.tar bird-e7b09e4ab99fc850480480bbb577ffa36a6c5cd7.zip |
Use SO_BINDTODEVICE also in Linux/IPv6.
Diffstat (limited to 'sysdep/linux')
-rw-r--r-- | sysdep/linux/sysio.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sysdep/linux/sysio.h b/sysdep/linux/sysio.h index 1cfbcc4..795d0b3 100644 --- a/sysdep/linux/sysio.h +++ b/sysdep/linux/sysio.h @@ -6,6 +6,8 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ +#include <net/if.h> + #ifdef IPV6 #ifndef IPV6_UNICAST_HOPS @@ -28,9 +30,18 @@ get_inaddr(ip_addr *a, struct in6_addr *ia) ipa_ntoh(*a); } -#else +static inline char * +sysio_bind_to_iface(sock *s) +{ + struct ifreq ifr; + strcpy(ifr.ifr_name, s->iface->name); + if (setsockopt(s->fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0) + return "SO_BINDTODEVICE"; -#include <net/if.h> + return NULL; +} + +#else static inline void set_inaddr(struct in_addr *ia, ip_addr a) |