diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-19 22:54:21 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-19 22:54:21 +0000 |
commit | 5ad1048c3d139a11df61392b82d76221ef1576f2 (patch) | |
tree | 580007a6d5d06e8d48a5e9209fa23da52d98fb76 /networking/ping.c | |
parent | a19faf8bb7fc1db51f863fea4233639851ba7789 (diff) | |
download | busybox-w32-5ad1048c3d139a11df61392b82d76221ef1576f2.tar.gz busybox-w32-5ad1048c3d139a11df61392b82d76221ef1576f2.tar.bz2 busybox-w32-5ad1048c3d139a11df61392b82d76221ef1576f2.zip |
ping: fix incorrect handling of -I (Iouri Kharon <bc-info@styx.cabel.net>)
Diffstat (limited to 'networking/ping.c')
-rw-r--r-- | networking/ping.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/networking/ping.c b/networking/ping.c index c4a498cd8..6945abb4a 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -530,8 +530,12 @@ static void ping4(len_and_sockaddr *lsa) | |||
530 | 530 | ||
531 | pingsock = create_icmp_socket(); | 531 | pingsock = create_icmp_socket(); |
532 | pingaddr.sin = lsa->sin; | 532 | pingaddr.sin = lsa->sin; |
533 | if (source_lsa) | 533 | if (source_lsa) { |
534 | xbind(pingsock, &lsa->sa, lsa->len); | 534 | if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF, |
535 | &source_lsa->sa, source_lsa->len)) | ||
536 | bb_error_msg_and_die("can't set multicast source interface"); | ||
537 | xbind(pingsock, &source_lsa->sa, source_lsa->len); | ||
538 | } | ||
535 | 539 | ||
536 | /* enable broadcast pings */ | 540 | /* enable broadcast pings */ |
537 | setsockopt_broadcast(pingsock); | 541 | setsockopt_broadcast(pingsock); |
@@ -578,7 +582,7 @@ static void ping6(len_and_sockaddr *lsa) | |||
578 | pingaddr.sin6 = lsa->sin6; | 582 | pingaddr.sin6 = lsa->sin6; |
579 | /* untested whether "-I addr" really works for IPv6: */ | 583 | /* untested whether "-I addr" really works for IPv6: */ |
580 | if (source_lsa) | 584 | if (source_lsa) |
581 | xbind(pingsock, &lsa->sa, lsa->len); | 585 | xbind(pingsock, &source_lsa->sa, source_lsa->len); |
582 | 586 | ||
583 | #ifdef ICMP6_FILTER | 587 | #ifdef ICMP6_FILTER |
584 | { | 588 | { |
@@ -659,7 +663,7 @@ static void ping(len_and_sockaddr *lsa) | |||
659 | printf("PING %s (%s)", hostname, dotted); | 663 | printf("PING %s (%s)", hostname, dotted); |
660 | if (source_lsa) { | 664 | if (source_lsa) { |
661 | printf(" from %s", | 665 | printf(" from %s", |
662 | xmalloc_sockaddr2dotted_noport(&lsa->sa, lsa->len)); | 666 | xmalloc_sockaddr2dotted_noport(&source_lsa->sa, source_lsa->len)); |
663 | } | 667 | } |
664 | printf(": %d data bytes\n", datalen); | 668 | printf(": %d data bytes\n", datalen); |
665 | 669 | ||
@@ -691,7 +695,6 @@ int ping_main(int argc, char **argv) | |||
691 | if_index = if_nametoindex(opt_I); | 695 | if_index = if_nametoindex(opt_I); |
692 | if (!if_index) { | 696 | if (!if_index) { |
693 | /* TODO: I'm not sure it takes IPv6 unless in [XX:XX..] format */ | 697 | /* TODO: I'm not sure it takes IPv6 unless in [XX:XX..] format */ |
694 | /* (ping doesn't support source IPv6 addresses yet anyway) */ | ||
695 | source_lsa = xdotted2sockaddr(opt_I, 0); | 698 | source_lsa = xdotted2sockaddr(opt_I, 0); |
696 | } | 699 | } |
697 | } | 700 | } |