diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-11 14:55:46 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-11 14:55:46 +0100 |
commit | ba3b9dbf065438402d89655d7baefb0ccc6f0663 (patch) | |
tree | 4669edd0fb031940a794eaf8942bdbf314efea2e /networking/arping.c | |
parent | d3162773d5c722cc1f5c5b1ea5171c8d3c208135 (diff) | |
download | busybox-w32-ba3b9dbf065438402d89655d7baefb0ccc6f0663.tar.gz busybox-w32-ba3b9dbf065438402d89655d7baefb0ccc6f0663.tar.bz2 busybox-w32-ba3b9dbf065438402d89655d7baefb0ccc6f0663.zip |
libbb: introduce and use bb_getsockname()
function old new delta
bb_getsockname - 18 +18
xrtnl_open 88 83 -5
do_iplink 1216 1209 -7
arping_main 1686 1668 -18
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/3 up/down: 18/-30) Total: -12 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/arping.c')
-rw-r--r-- | networking/arping.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/networking/arping.c b/networking/arping.c index a16f04b9f..59092a7d7 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -363,15 +363,13 @@ int arping_main(int argc UNUSED_PARAM, char **argv) | |||
363 | xbind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); | 363 | xbind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); |
364 | } else { /* !(option_mask32 & DAD) case */ | 364 | } else { /* !(option_mask32 & DAD) case */ |
365 | /* Find IP address on this iface */ | 365 | /* Find IP address on this iface */ |
366 | socklen_t alen = sizeof(saddr); | ||
367 | |||
368 | saddr.sin_port = htons(1025); | 366 | saddr.sin_port = htons(1025); |
369 | saddr.sin_addr = dst; | 367 | saddr.sin_addr = dst; |
370 | 368 | ||
371 | if (setsockopt_SOL_SOCKET_1(probe_fd, SO_DONTROUTE) != 0) | 369 | if (setsockopt_SOL_SOCKET_1(probe_fd, SO_DONTROUTE) != 0) |
372 | bb_perror_msg("setsockopt(%s)", "SO_DONTROUTE"); | 370 | bb_perror_msg("setsockopt(%s)", "SO_DONTROUTE"); |
373 | xconnect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); | 371 | xconnect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); |
374 | getsockname(probe_fd, (struct sockaddr *) &saddr, &alen); | 372 | bb_getsockname(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)); |
375 | //never happens: | 373 | //never happens: |
376 | //if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == -1) | 374 | //if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == -1) |
377 | // bb_perror_msg_and_die("getsockname"); | 375 | // bb_perror_msg_and_die("getsockname"); |
@@ -387,13 +385,10 @@ int arping_main(int argc UNUSED_PARAM, char **argv) | |||
387 | me.sll_protocol = htons(ETH_P_ARP); | 385 | me.sll_protocol = htons(ETH_P_ARP); |
388 | xbind(sock_fd, (struct sockaddr *) &me, sizeof(me)); | 386 | xbind(sock_fd, (struct sockaddr *) &me, sizeof(me)); |
389 | 387 | ||
390 | { | 388 | bb_getsockname(sock_fd, (struct sockaddr *) &me, sizeof(me)); |
391 | socklen_t alen = sizeof(me); | 389 | //never happens: |
392 | getsockname(sock_fd, (struct sockaddr *) &me, &alen); | 390 | //if (getsockname(sock_fd, (struct sockaddr *) &me, &alen) == -1) |
393 | //never happens: | 391 | // bb_perror_msg_and_die("getsockname"); |
394 | //if (getsockname(sock_fd, (struct sockaddr *) &me, &alen) == -1) | ||
395 | // bb_perror_msg_and_die("getsockname"); | ||
396 | } | ||
397 | if (me.sll_halen == 0) { | 392 | if (me.sll_halen == 0) { |
398 | bb_error_msg(err_str, "is not ARPable (no ll address)"); | 393 | bb_error_msg(err_str, "is not ARPable (no ll address)"); |
399 | BUILD_BUG_ON(DAD != 2); | 394 | BUILD_BUG_ON(DAD != 2); |