aboutsummaryrefslogtreecommitdiff
path: root/networking/ping.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-02 16:13:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-02 16:13:36 +0000
commitcb6874cc66df69fe49c65338a67fec1206d02c4b (patch)
tree456f9bab87457df640ee305716b000f87ed6285c /networking/ping.c
parentd53dd3e627d158953c124107dae1c7ca48ca0a55 (diff)
downloadbusybox-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.c19
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
35enum { 34enum {
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
81static char *hostname = NULL; 80static char *hostname;
81
82static void noresp(int ign) 82static 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;
163static unsigned long tmin = ULONG_MAX, tmax, tsum; 163static unsigned long tmin = ULONG_MAX, tmax, tsum;
164static char rcvd_tbl[MAX_DUP_CHK / 8]; 164static char rcvd_tbl[MAX_DUP_CHK / 8];
165 165
166#ifndef CONFIG_FEATURE_FANCY_PING6 166static struct hostent *hostent;
167static
168#endif
169 struct hostent *hostent;
170 167
171static void sendping(int); 168static void sendping(int);
172static void pingstats(int); 169static 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;