From 44c2eb23ddddb7d0703f24d1dac99f4501f1b9f3 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 8 Jan 2007 23:55:33 +0000 Subject: 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...) --- networking/ping.c | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'networking/ping.c') 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 -#include -#include -#include -#include - -#include -#include +//#include +//#include #include -#include -#include -#include -#include -#include -#include -#include -#include +//#include +//#include #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); -- cgit v1.1