diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-02 16:13:36 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-02 16:13:36 +0000 |
commit | cb6874cc66df69fe49c65338a67fec1206d02c4b (patch) | |
tree | 456f9bab87457df640ee305716b000f87ed6285c /networking/ping.c | |
parent | d53dd3e627d158953c124107dae1c7ca48ca0a55 (diff) | |
download | busybox-w32-cb6874cc66df69fe49c65338a67fec1206d02c4b.tar.gz busybox-w32-cb6874cc66df69fe49c65338a67fec1206d02c4b.tar.bz2 busybox-w32-cb6874cc66df69fe49c65338a67fec1206d02c4b.zip |
Sync ping and ping6 a bit, fix style and indentation.
Diffstat (limited to 'networking/ping.c')
-rw-r--r-- | networking/ping.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/networking/ping.c b/networking/ping.c index 5cd6f4a1a..8ccb7e0bf 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include "busybox.h" | 32 | #include "busybox.h" |
33 | 33 | ||
34 | |||
35 | enum { | 34 | enum { |
36 | DEFDATALEN = 56, | 35 | DEFDATALEN = 56, |
37 | MAXIPLEN = 60, | 36 | MAXIPLEN = 60, |
@@ -78,7 +77,8 @@ static int in_cksum(unsigned short *buf, int sz) | |||
78 | 77 | ||
79 | /* simple version */ | 78 | /* simple version */ |
80 | #ifndef CONFIG_FEATURE_FANCY_PING | 79 | #ifndef CONFIG_FEATURE_FANCY_PING |
81 | static char *hostname = NULL; | 80 | static char *hostname; |
81 | |||
82 | static void noresp(int ign) | 82 | static void noresp(int ign) |
83 | { | 83 | { |
84 | printf("No response from %s\n", hostname); | 84 | printf("No response from %s\n", hostname); |
@@ -163,10 +163,7 @@ static int myid, options; | |||
163 | static unsigned long tmin = ULONG_MAX, tmax, tsum; | 163 | static unsigned long tmin = ULONG_MAX, tmax, tsum; |
164 | static char rcvd_tbl[MAX_DUP_CHK / 8]; | 164 | static char rcvd_tbl[MAX_DUP_CHK / 8]; |
165 | 165 | ||
166 | #ifndef CONFIG_FEATURE_FANCY_PING6 | 166 | static struct hostent *hostent; |
167 | static | ||
168 | #endif | ||
169 | struct hostent *hostent; | ||
170 | 167 | ||
171 | static void sendping(int); | 168 | static void sendping(int); |
172 | static void pingstats(int); | 169 | static void pingstats(int); |
@@ -278,11 +275,11 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) | |||
278 | icmppkt = (struct icmp *) (buf + hlen); | 275 | icmppkt = (struct icmp *) (buf + hlen); |
279 | 276 | ||
280 | if (icmppkt->icmp_id != myid) | 277 | if (icmppkt->icmp_id != myid) |
281 | return; /* not our ping */ | 278 | return; /* not our ping */ |
282 | 279 | ||
283 | if (icmppkt->icmp_type == ICMP_ECHOREPLY) { | 280 | if (icmppkt->icmp_type == ICMP_ECHOREPLY) { |
284 | u_int16_t recv_seq = ntohs(icmppkt->icmp_seq); | 281 | u_int16_t recv_seq = ntohs(icmppkt->icmp_seq); |
285 | ++nreceived; | 282 | ++nreceived; |
286 | tp = (struct timeval *) icmppkt->icmp_data; | 283 | tp = (struct timeval *) icmppkt->icmp_data; |
287 | 284 | ||
288 | if ((tv.tv_usec -= tp->tv_usec) < 0) { | 285 | if ((tv.tv_usec -= tp->tv_usec) < 0) { |
@@ -352,7 +349,7 @@ static void ping(const char *host) | |||
352 | sizeof(sockopt)); | 349 | sizeof(sockopt)); |
353 | 350 | ||
354 | printf("PING %s (%s): %d data bytes\n", | 351 | printf("PING %s (%s): %d data bytes\n", |
355 | hostent->h_name, | 352 | hostent->h_name, |
356 | inet_ntoa(*(struct in_addr *) &pingaddr.sin_addr.s_addr), | 353 | inet_ntoa(*(struct in_addr *) &pingaddr.sin_addr.s_addr), |
357 | datalen); | 354 | datalen); |
358 | 355 | ||
@@ -400,13 +397,13 @@ int ping_main(int argc, char **argv) | |||
400 | break; | 397 | break; |
401 | case 'c': | 398 | case 'c': |
402 | if (--argc <= 0) | 399 | if (--argc <= 0) |
403 | bb_show_usage(); | 400 | bb_show_usage(); |
404 | argv++; | 401 | argv++; |
405 | pingcount = atoi(*argv); | 402 | pingcount = atoi(*argv); |
406 | break; | 403 | break; |
407 | case 's': | 404 | case 's': |
408 | if (--argc <= 0) | 405 | if (--argc <= 0) |
409 | bb_show_usage(); | 406 | bb_show_usage(); |
410 | argv++; | 407 | argv++; |
411 | datalen = atoi(*argv); | 408 | datalen = atoi(*argv); |
412 | break; | 409 | break; |