diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/messages.c | 2 | ||||
-rw-r--r-- | libbb/udp_io.c | 4 | ||||
-rw-r--r-- | libbb/xconnect.c | 25 |
3 files changed, 26 insertions, 5 deletions
diff --git a/libbb/messages.c b/libbb/messages.c index fad82c9da..c1b7ba252 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -43,7 +43,7 @@ const char bb_PATH_root_path[] ALIGN1 = | |||
43 | "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH; | 43 | "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH; |
44 | 44 | ||
45 | 45 | ||
46 | const int const_int_1 = 1; | 46 | //const int const_int_1 = 1; |
47 | /* explicitly = 0, otherwise gcc may make it a common variable | 47 | /* explicitly = 0, otherwise gcc may make it a common variable |
48 | * and it will end up in bss */ | 48 | * and it will end up in bss */ |
49 | const int const_int_0 = 0; | 49 | const int const_int_0 = 0; |
diff --git a/libbb/udp_io.c b/libbb/udp_io.c index 7985a9723..a32af9bd2 100644 --- a/libbb/udp_io.c +++ b/libbb/udp_io.c | |||
@@ -16,10 +16,10 @@ void FAST_FUNC | |||
16 | socket_want_pktinfo(int fd UNUSED_PARAM) | 16 | socket_want_pktinfo(int fd UNUSED_PARAM) |
17 | { | 17 | { |
18 | #ifdef IP_PKTINFO | 18 | #ifdef IP_PKTINFO |
19 | setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &const_int_1, sizeof(int)); | 19 | setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); |
20 | #endif | 20 | #endif |
21 | #if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) | 21 | #if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) |
22 | setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &const_int_1, sizeof(int)); | 22 | setsockopt_1(fd, IPPROTO_IPV6, IPV6_PKTINFO); |
23 | #endif | 23 | #endif |
24 | } | 24 | } |
25 | 25 | ||
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 2a96e03dc..6e78e6363 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -14,13 +14,34 @@ | |||
14 | #include <sys/un.h> | 14 | #include <sys/un.h> |
15 | #include "libbb.h" | 15 | #include "libbb.h" |
16 | 16 | ||
17 | int FAST_FUNC setsockopt_int(int fd, int level, int optname, int optval) | ||
18 | { | ||
19 | return setsockopt(fd, level, optname, &optval, sizeof(int)); | ||
20 | } | ||
21 | int FAST_FUNC setsockopt_1(int fd, int level, int optname) | ||
22 | { | ||
23 | return setsockopt_int(fd, level, optname, 1); | ||
24 | } | ||
25 | int FAST_FUNC setsockopt_SOL_SOCKET_int(int fd, int optname, int optval) | ||
26 | { | ||
27 | return setsockopt_int(fd, SOL_SOCKET, optname, optval); | ||
28 | } | ||
29 | int FAST_FUNC setsockopt_SOL_SOCKET_1(int fd, int optname) | ||
30 | { | ||
31 | return setsockopt_SOL_SOCKET_int(fd, optname, 1); | ||
32 | } | ||
33 | |||
17 | void FAST_FUNC setsockopt_reuseaddr(int fd) | 34 | void FAST_FUNC setsockopt_reuseaddr(int fd) |
18 | { | 35 | { |
19 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_1, sizeof(const_int_1)); | 36 | setsockopt_SOL_SOCKET_1(fd, SO_REUSEADDR); |
20 | } | 37 | } |
21 | int FAST_FUNC setsockopt_broadcast(int fd) | 38 | int FAST_FUNC setsockopt_broadcast(int fd) |
22 | { | 39 | { |
23 | return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); | 40 | return setsockopt_SOL_SOCKET_1(fd, SO_BROADCAST); |
41 | } | ||
42 | int FAST_FUNC setsockopt_keepalive(int fd) | ||
43 | { | ||
44 | return setsockopt_SOL_SOCKET_1(fd, SO_KEEPALIVE); | ||
24 | } | 45 | } |
25 | 46 | ||
26 | #ifdef SO_BINDTODEVICE | 47 | #ifdef SO_BINDTODEVICE |