diff options
author | Denis Vlasenko | 2008-12-31 03:33:50 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-12-31 03:33:50 +0000 |
commit | 15c0b725849875c718b168a26e13872e163cde4c (patch) | |
tree | 687a5425953ae362ef285c6c671f09a05d3fa3c0 /libbb/xconnect.c | |
parent | ccdc13d306c0a8d2735488bf8e46503f7e567767 (diff) | |
download | busybox-15c0b725849875c718b168a26e13872e163cde4c.zip busybox-15c0b725849875c718b168a26e13872e163cde4c.tar.gz |
Apply post 1.13.1 patches, bump to 1.13.21_13_2
Diffstat (limited to 'libbb/xconnect.c')
-rw-r--r-- | libbb/xconnect.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index d48c503..27c7424 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -7,6 +7,7 @@ */ #include <netinet/in.h> +#include <net/if.h> #include "libbb.h" void FAST_FUNC setsockopt_reuseaddr(int fd) @@ -17,6 +18,20 @@ int FAST_FUNC setsockopt_broadcast(int fd) { return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); } +int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface) +{ + int r; + struct ifreq ifr; + strncpy(ifr.ifr_name, iface, IFNAMSIZ); + /* Actually, ifr_name is at offset 0, and in practice + * just giving char[IFNAMSIZ] instead of struct ifreq works too. + * But just in case it's not true on some obscure arch... */ + r = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)); + if (r) + bb_perror_msg("can't bind to interface %s", iface); + return r; +} + void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) { |