aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/messages.c2
-rw-r--r--libbb/udp_io.c4
-rw-r--r--libbb/xconnect.c25
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 =
"PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH;
-const int const_int_1 = 1;
+//const int const_int_1 = 1;
/* explicitly = 0, otherwise gcc may make it a common variable
* and it will end up in bss */
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
socket_want_pktinfo(int fd UNUSED_PARAM)
{
#ifdef IP_PKTINFO
- setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &const_int_1, sizeof(int));
+ setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO);
#endif
#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
- setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &const_int_1, sizeof(int));
+ setsockopt_1(fd, IPPROTO_IPV6, IPV6_PKTINFO);
#endif
}
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 @@
#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