diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-08-24 19:48:03 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-08-24 20:00:17 +0200 |
commit | c52cbea2bba6582b44facb424a15dc544b54fb28 (patch) | |
tree | b048b3f7832621a16ed9ba2441756e2fc69ee316 /networking/traceroute.c | |
parent | 2db782bc7be70c34a756e2bc6d4a53e8f47bab20 (diff) | |
download | busybox-w32-c52cbea2bba6582b44facb424a15dc544b54fb28.tar.gz busybox-w32-c52cbea2bba6582b44facb424a15dc544b54fb28.tar.bz2 busybox-w32-c52cbea2bba6582b44facb424a15dc544b54fb28.zip |
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 'networking/traceroute.c')
-rw-r--r-- | networking/traceroute.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index e41d89e9f..642110c54 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -473,8 +473,8 @@ send_probe(int seq, int ttl) | |||
473 | 473 | ||
474 | #if ENABLE_TRACEROUTE6 | 474 | #if ENABLE_TRACEROUTE6 |
475 | if (dest_lsa->u.sa.sa_family == AF_INET6) { | 475 | if (dest_lsa->u.sa.sa_family == AF_INET6) { |
476 | res = setsockopt(sndsock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)); | 476 | res = setsockopt_int(sndsock, SOL_IPV6, IPV6_UNICAST_HOPS, ttl); |
477 | if (res < 0) | 477 | if (res != 0) |
478 | bb_perror_msg_and_die("setsockopt(%s) %d", "UNICAST_HOPS", ttl); | 478 | bb_perror_msg_and_die("setsockopt(%s) %d", "UNICAST_HOPS", ttl); |
479 | out = outip; | 479 | out = outip; |
480 | len = packlen; | 480 | len = packlen; |
@@ -482,8 +482,8 @@ send_probe(int seq, int ttl) | |||
482 | #endif | 482 | #endif |
483 | { | 483 | { |
484 | #if defined IP_TTL | 484 | #if defined IP_TTL |
485 | res = setsockopt(sndsock, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)); | 485 | res = setsockopt_int(sndsock, IPPROTO_IP, IP_TTL, ttl); |
486 | if (res < 0) | 486 | if (res != 0) |
487 | bb_perror_msg_and_die("setsockopt(%s) %d", "TTL", ttl); | 487 | bb_perror_msg_and_die("setsockopt(%s) %d", "TTL", ttl); |
488 | #endif | 488 | #endif |
489 | out = outicmp; | 489 | out = outicmp; |
@@ -902,13 +902,10 @@ common_traceroute_main(int op, char **argv) | |||
902 | if (af == AF_INET6) { | 902 | if (af == AF_INET6) { |
903 | xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); | 903 | xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); |
904 | # ifdef IPV6_RECVPKTINFO | 904 | # ifdef IPV6_RECVPKTINFO |
905 | setsockopt(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO, | 905 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO); |
906 | &const_int_1, sizeof(const_int_1)); | 906 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_2292PKTINFO); |
907 | setsockopt(rcvsock, SOL_IPV6, IPV6_2292PKTINFO, | ||
908 | &const_int_1, sizeof(const_int_1)); | ||
909 | # else | 907 | # else |
910 | setsockopt(rcvsock, SOL_IPV6, IPV6_PKTINFO, | 908 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_PKTINFO); |
911 | &const_int_1, sizeof(const_int_1)); | ||
912 | # endif | 909 | # endif |
913 | } else | 910 | } else |
914 | #endif | 911 | #endif |
@@ -918,17 +915,14 @@ common_traceroute_main(int op, char **argv) | |||
918 | 915 | ||
919 | #if TRACEROUTE_SO_DEBUG | 916 | #if TRACEROUTE_SO_DEBUG |
920 | if (op & OPT_DEBUG) | 917 | if (op & OPT_DEBUG) |
921 | setsockopt(rcvsock, SOL_SOCKET, SO_DEBUG, | 918 | setsockopt_SOL_SOCKET_1(rcvsock, SO_DEBUG); |
922 | &const_int_1, sizeof(const_int_1)); | ||
923 | #endif | 919 | #endif |
924 | if (op & OPT_BYPASS_ROUTE) | 920 | if (op & OPT_BYPASS_ROUTE) |
925 | setsockopt(rcvsock, SOL_SOCKET, SO_DONTROUTE, | 921 | setsockopt_SOL_SOCKET_1(rcvsock, SO_DONTROUTE); |
926 | &const_int_1, sizeof(const_int_1)); | ||
927 | 922 | ||
928 | #if ENABLE_TRACEROUTE6 | 923 | #if ENABLE_TRACEROUTE6 |
929 | if (af == AF_INET6) { | 924 | if (af == AF_INET6) { |
930 | static const int two = 2; | 925 | if (setsockopt_int(rcvsock, SOL_RAW, IPV6_CHECKSUM, 2) != 0) |
931 | if (setsockopt(rcvsock, SOL_RAW, IPV6_CHECKSUM, &two, sizeof(two)) < 0) | ||
932 | bb_perror_msg_and_die("setsockopt(%s)", "IPV6_CHECKSUM"); | 926 | bb_perror_msg_and_die("setsockopt(%s)", "IPV6_CHECKSUM"); |
933 | xmove_fd(xsocket(af, SOCK_DGRAM, 0), sndsock); | 927 | xmove_fd(xsocket(af, SOCK_DGRAM, 0), sndsock); |
934 | } else | 928 | } else |
@@ -966,28 +960,25 @@ common_traceroute_main(int op, char **argv) | |||
966 | } | 960 | } |
967 | 961 | ||
968 | #ifdef SO_SNDBUF | 962 | #ifdef SO_SNDBUF |
969 | if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, &packlen, sizeof(packlen)) < 0) { | 963 | if (setsockopt_SOL_SOCKET_int(sndsock, SO_SNDBUF, packlen) != 0) { |
970 | bb_perror_msg_and_die("SO_SNDBUF"); | 964 | bb_perror_msg_and_die("setsockopt(%s)", "SO_SNDBUF"); |
971 | } | 965 | } |
972 | #endif | 966 | #endif |
973 | #ifdef IP_TOS | 967 | #ifdef IP_TOS |
974 | if ((op & OPT_TOS) && setsockopt(sndsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) { | 968 | if ((op & OPT_TOS) && setsockopt_int(sndsock, IPPROTO_IP, IP_TOS, tos) != 0) { |
975 | bb_perror_msg_and_die("setsockopt(%s) %d", "TOS", tos); | 969 | bb_perror_msg_and_die("setsockopt(%s) %d", "TOS", tos); |
976 | } | 970 | } |
977 | #endif | 971 | #endif |
978 | #ifdef IP_DONTFRAG | 972 | #ifdef IP_DONTFRAG |
979 | if (op & OPT_DONT_FRAGMNT) | 973 | if (op & OPT_DONT_FRAGMNT) |
980 | setsockopt(sndsock, IPPROTO_IP, IP_DONTFRAG, | 974 | setsockopt_1(sndsock, IPPROTO_IP, IP_DONTFRAG); |
981 | &const_int_1, sizeof(const_int_1)); | ||
982 | #endif | 975 | #endif |
983 | #if TRACEROUTE_SO_DEBUG | 976 | #if TRACEROUTE_SO_DEBUG |
984 | if (op & OPT_DEBUG) | 977 | if (op & OPT_DEBUG) |
985 | setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, | 978 | setsockopt_SOL_SOCKET_1(sndsock, SO_DEBUG); |
986 | &const_int_1, sizeof(const_int_1)); | ||
987 | #endif | 979 | #endif |
988 | if (op & OPT_BYPASS_ROUTE) | 980 | if (op & OPT_BYPASS_ROUTE) |
989 | setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, | 981 | setsockopt_SOL_SOCKET_1(sndsock, SO_DONTROUTE); |
990 | &const_int_1, sizeof(const_int_1)); | ||
991 | 982 | ||
992 | outip = xzalloc(packlen); | 983 | outip = xzalloc(packlen); |
993 | 984 | ||