summaryrefslogtreecommitdiff
path: root/networking/ping.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-08 23:55:33 +0000
committerDenis Vlasenko2007-01-08 23:55:33 +0000
commit44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3 (patch)
tree4fd57ec4aec7587b1187138f724f2c64e6a1d471 /networking/ping.c
parentd6c23aeefba32ae1d7290f849cf2290749876462 (diff)
downloadbusybox-44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3.zip
busybox-44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3.tar.gz
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.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/networking/ping.c b/networking/ping.c
index 8b49df1..de97d7e 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -12,23 +12,11 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/times.h>
-#include <signal.h>
-
-#include <netinet/in.h>
-#include <netinet/ip.h>
+//#include <netinet/in.h>
+//#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
+//#include <arpa/inet.h>
+//#include <netdb.h>
#include "busybox.h"
enum {
@@ -120,9 +108,8 @@ static void ping(const char *host)
c = recvfrom(pingsock, packet, sizeof(packet), 0,
(struct sockaddr *) &from, &fromlen);
if (c < 0) {
- if (errno == EINTR)
- continue;
- bb_perror_msg("recvfrom");
+ if (errno != EINTR)
+ bb_perror_msg("recvfrom");
continue;
}
if (c >= 76) { /* ip + icmp */
@@ -135,7 +122,6 @@ static void ping(const char *host)
}
if (ENABLE_FEATURE_CLEAN_UP) close(pingsock);
printf("%s is alive!\n", hostname);
- return;
}
int ping_main(int argc, char **argv)
@@ -231,7 +217,7 @@ static void sendping(int junk)
if (i < 0)
bb_perror_msg_and_die("sendto");
- else if ((size_t)i != sizeof(packet))
+ if ((size_t)i != sizeof(packet))
bb_error_msg_and_die("ping wrote %d chars; %d expected", i,
(int)sizeof(packet));
@@ -328,7 +314,8 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
} else
if (icmppkt->icmp_type != ICMP_ECHO)
bb_error_msg("warning: got ICMP %d (%s)",
- icmppkt->icmp_type, icmp_type_name(icmppkt->icmp_type));
+ icmppkt->icmp_type,
+ icmp_type_name(icmppkt->icmp_type));
fflush(stdout);
}
@@ -380,11 +367,11 @@ static void ping(const char *host)
socklen_t fromlen = (socklen_t) sizeof(from);
int c;
- if ((c = recvfrom(pingsock, packet, sizeof(packet), 0,
- (struct sockaddr *) &from, &fromlen)) < 0) {
- if (errno == EINTR)
- continue;
- bb_perror_msg("recvfrom");
+ c = recvfrom(pingsock, packet, sizeof(packet), 0,
+ (struct sockaddr *) &from, &fromlen);
+ if (c < 0) {
+ if (errno != EINTR)
+ bb_perror_msg("recvfrom");
continue;
}
unpack(packet, c, &from);