Sync ping and ping6 a bit, fix style and indentation.

This commit is contained in:
Denis Vlasenko 2006-09-02 16:13:36 +00:00
parent d53dd3e627
commit cb6874cc66
2 changed files with 32 additions and 35 deletions

View File

@ -31,7 +31,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "busybox.h" #include "busybox.h"
enum { enum {
DEFDATALEN = 56, DEFDATALEN = 56,
MAXIPLEN = 60, MAXIPLEN = 60,
@ -78,7 +77,8 @@ static int in_cksum(unsigned short *buf, int sz)
/* simple version */ /* simple version */
#ifndef CONFIG_FEATURE_FANCY_PING #ifndef CONFIG_FEATURE_FANCY_PING
static char *hostname = NULL; static char *hostname;
static void noresp(int ign) static void noresp(int ign)
{ {
printf("No response from %s\n", hostname); printf("No response from %s\n", hostname);
@ -163,10 +163,7 @@ static int myid, options;
static unsigned long tmin = ULONG_MAX, tmax, tsum; static unsigned long tmin = ULONG_MAX, tmax, tsum;
static char rcvd_tbl[MAX_DUP_CHK / 8]; static char rcvd_tbl[MAX_DUP_CHK / 8];
#ifndef CONFIG_FEATURE_FANCY_PING6 static struct hostent *hostent;
static
#endif
struct hostent *hostent;
static void sendping(int); static void sendping(int);
static void pingstats(int); static void pingstats(int);

View File

@ -68,7 +68,7 @@ static void ping(const char *host);
#ifndef CONFIG_FEATURE_FANCY_PING6 #ifndef CONFIG_FEATURE_FANCY_PING6
static struct hostent *h; static struct hostent *h;
void noresp(int ign) static void noresp(int ign)
{ {
printf("No response from %s\n", h->h_name); printf("No response from %s\n", h->h_name);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -101,8 +101,10 @@ static void ping(const char *host)
c = sendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr), 0, c = sendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr), 0,
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6)); (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in6));
if (c < 0 || c != sizeof(packet)) if (c < 0 || c != sizeof(packet)) {
if (ENABLE_FEATURE_CLEAN_UP) close(pingsock);
bb_perror_msg_and_die("sendto"); bb_perror_msg_and_die("sendto");
}
signal(SIGALRM, noresp); signal(SIGALRM, noresp);
alarm(5); /* give the host 5000ms to respond */ alarm(5); /* give the host 5000ms to respond */
@ -124,6 +126,7 @@ static void ping(const char *host)
break; break;
} }
} }
if (ENABLE_FEATURE_CLEAN_UP) close(pingsock);
printf("%s is alive!\n", h->h_name); printf("%s is alive!\n", h->h_name);
return; return;
} }
@ -150,10 +153,7 @@ static int myid, options;
static unsigned long tmin = ULONG_MAX, tmax, tsum; static unsigned long tmin = ULONG_MAX, tmax, tsum;
static char rcvd_tbl[MAX_DUP_CHK / 8]; static char rcvd_tbl[MAX_DUP_CHK / 8];
# ifdef CONFIG_FEATURE_FANCY_PING static struct hostent *hostent;
extern
# endif
struct hostent *hostent;
static void sendping(int); static void sendping(int);
static void pingstats(int); static void pingstats(int);