diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-08 23:55:33 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-08 23:55:33 +0000 |
commit | 44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3 (patch) | |
tree | 4fd57ec4aec7587b1187138f724f2c64e6a1d471 /networking/ping.c | |
parent | d6c23aeefba32ae1d7290f849cf2290749876462 (diff) | |
download | busybox-w32-44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3.tar.gz busybox-w32-44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3.tar.bz2 busybox-w32-44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3.zip |
ping6: fix sequence numbers (missed ntoh) and ttl display.
(apparently some, eh, clever libc guy decided that
*CHANGING* IPV6_HOPLIMIT value in libc header is a nifty idea...)
Diffstat (limited to 'networking/ping.c')
-rw-r--r-- | networking/ping.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/networking/ping.c b/networking/ping.c index 8b49df1bd..de97d7e7f 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -12,23 +12,11 @@ | |||
12 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 12 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <sys/param.h> | 15 | //#include <netinet/in.h> |
16 | #include <sys/socket.h> | 16 | //#include <netinet/ip.h> |
17 | #include <sys/file.h> | ||
18 | #include <sys/times.h> | ||
19 | #include <signal.h> | ||
20 | |||
21 | #include <netinet/in.h> | ||
22 | #include <netinet/ip.h> | ||
23 | #include <netinet/ip_icmp.h> | 17 | #include <netinet/ip_icmp.h> |
24 | #include <arpa/inet.h> | 18 | //#include <arpa/inet.h> |
25 | #include <netdb.h> | 19 | //#include <netdb.h> |
26 | #include <stdio.h> | ||
27 | #include <stdlib.h> | ||
28 | #include <errno.h> | ||
29 | #include <unistd.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "busybox.h" | 20 | #include "busybox.h" |
33 | 21 | ||
34 | enum { | 22 | enum { |
@@ -120,9 +108,8 @@ static void ping(const char *host) | |||
120 | c = recvfrom(pingsock, packet, sizeof(packet), 0, | 108 | c = recvfrom(pingsock, packet, sizeof(packet), 0, |
121 | (struct sockaddr *) &from, &fromlen); | 109 | (struct sockaddr *) &from, &fromlen); |
122 | if (c < 0) { | 110 | if (c < 0) { |
123 | if (errno == EINTR) | 111 | if (errno != EINTR) |
124 | continue; | 112 | bb_perror_msg("recvfrom"); |
125 | bb_perror_msg("recvfrom"); | ||
126 | continue; | 113 | continue; |
127 | } | 114 | } |
128 | if (c >= 76) { /* ip + icmp */ | 115 | if (c >= 76) { /* ip + icmp */ |
@@ -135,7 +122,6 @@ static void ping(const char *host) | |||
135 | } | 122 | } |
136 | if (ENABLE_FEATURE_CLEAN_UP) close(pingsock); | 123 | if (ENABLE_FEATURE_CLEAN_UP) close(pingsock); |
137 | printf("%s is alive!\n", hostname); | 124 | printf("%s is alive!\n", hostname); |
138 | return; | ||
139 | } | 125 | } |
140 | 126 | ||
141 | int ping_main(int argc, char **argv) | 127 | int ping_main(int argc, char **argv) |
@@ -231,7 +217,7 @@ static void sendping(int junk) | |||
231 | 217 | ||
232 | if (i < 0) | 218 | if (i < 0) |
233 | bb_perror_msg_and_die("sendto"); | 219 | bb_perror_msg_and_die("sendto"); |
234 | else if ((size_t)i != sizeof(packet)) | 220 | if ((size_t)i != sizeof(packet)) |
235 | bb_error_msg_and_die("ping wrote %d chars; %d expected", i, | 221 | bb_error_msg_and_die("ping wrote %d chars; %d expected", i, |
236 | (int)sizeof(packet)); | 222 | (int)sizeof(packet)); |
237 | 223 | ||
@@ -328,7 +314,8 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) | |||
328 | } else | 314 | } else |
329 | if (icmppkt->icmp_type != ICMP_ECHO) | 315 | if (icmppkt->icmp_type != ICMP_ECHO) |
330 | bb_error_msg("warning: got ICMP %d (%s)", | 316 | bb_error_msg("warning: got ICMP %d (%s)", |
331 | icmppkt->icmp_type, icmp_type_name(icmppkt->icmp_type)); | 317 | icmppkt->icmp_type, |
318 | icmp_type_name(icmppkt->icmp_type)); | ||
332 | fflush(stdout); | 319 | fflush(stdout); |
333 | } | 320 | } |
334 | 321 | ||
@@ -380,11 +367,11 @@ static void ping(const char *host) | |||
380 | socklen_t fromlen = (socklen_t) sizeof(from); | 367 | socklen_t fromlen = (socklen_t) sizeof(from); |
381 | int c; | 368 | int c; |
382 | 369 | ||
383 | if ((c = recvfrom(pingsock, packet, sizeof(packet), 0, | 370 | c = recvfrom(pingsock, packet, sizeof(packet), 0, |
384 | (struct sockaddr *) &from, &fromlen)) < 0) { | 371 | (struct sockaddr *) &from, &fromlen); |
385 | if (errno == EINTR) | 372 | if (c < 0) { |
386 | continue; | 373 | if (errno != EINTR) |
387 | bb_perror_msg("recvfrom"); | 374 | bb_perror_msg("recvfrom"); |
388 | continue; | 375 | continue; |
389 | } | 376 | } |
390 | unpack(packet, c, &from); | 377 | unpack(packet, c, &from); |