aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-08-24 19:48:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-08-24 20:00:17 +0200
commitc52cbea2bba6582b44facb424a15dc544b54fb28 (patch)
treeb048b3f7832621a16ed9ba2441756e2fc69ee316 /libbb
parent2db782bc7be70c34a756e2bc6d4a53e8f47bab20 (diff)
downloadbusybox-c52cbea2bba6582b44facb424a15dc544b54fb28.tar.gz
libbb: add setsockopt_foo helpers
function old new delta setsockopt_int - 23 +23 do_load 918 934 +16 setsockopt_SOL_SOCKET_int - 14 +14 setsockopt_keepalive - 10 +10 setsockopt_SOL_SOCKET_1 - 10 +10 buffer_fill_and_print 169 178 +9 setsockopt_1 - 8 +8 nfsmount 3560 3566 +6 redirect 1277 1282 +5 tcpudpsvd_main 1782 1786 +4 d6_send_kernel_packet 272 275 +3 i2cget_main 380 382 +2 ed_main 2544 2545 +1 scan_recursive 380 378 -2 nbdclient_main 492 490 -2 hash_find 235 233 -2 cmdputs 334 332 -2 parse_command 1443 1440 -3 static.two 4 - -4 ntpd_main 1039 1035 -4 const_int_1 4 - -4 const_IPTOS_LOWDELAY 4 - -4 RCVBUF 4 - -4 ntp_init 474 469 -5 change_listen_mode 316 310 -6 uevent_main 416 409 -7 arping_main 1697 1690 -7 telnet_main 1612 1603 -9 socket_want_pktinfo 42 33 -9 setsockopt_reuseaddr 21 10 -11 setsockopt_broadcast 21 10 -11 httpd_main 772 757 -15 get_remote_transfer_fd 109 94 -15 make_new_session 503 487 -16 ftpd_main 2177 2160 -17 read_bunzip 1896 1866 -30 common_traceroute_main 4099 4058 -41 common_ping_main 1836 1783 -53 ------------------------------------------------------------------------------ (add/remove: 5/4 grow/shrink: 8/21 up/down: 111/-283) Total: -172 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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