diff options
Diffstat (limited to 'libbb/xconnect.c')
-rw-r--r-- | libbb/xconnect.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 2a96e03..6e78e63 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -14,13 +14,34 @@ #include <sys/un.h> #include "libbb.h" +int FAST_FUNC setsockopt_int(int fd, int level, int optname, int optval) +{ + return setsockopt(fd, level, optname, &optval, sizeof(int)); +} +int FAST_FUNC setsockopt_1(int fd, int level, int optname) +{ + return setsockopt_int(fd, level, optname, 1); +} +int FAST_FUNC setsockopt_SOL_SOCKET_int(int fd, int optname, int optval) +{ + return setsockopt_int(fd, SOL_SOCKET, optname, optval); +} +int FAST_FUNC setsockopt_SOL_SOCKET_1(int fd, int optname) +{ + return setsockopt_SOL_SOCKET_int(fd, optname, 1); +} + void FAST_FUNC setsockopt_reuseaddr(int fd) { - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_1, sizeof(const_int_1)); + setsockopt_SOL_SOCKET_1(fd, SO_REUSEADDR); } int FAST_FUNC setsockopt_broadcast(int fd) { - return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); + return setsockopt_SOL_SOCKET_1(fd, SO_BROADCAST); +} +int FAST_FUNC setsockopt_keepalive(int fd) +{ + return setsockopt_SOL_SOCKET_1(fd, SO_KEEPALIVE); } #ifdef SO_BINDTODEVICE |