ping return 1 if can't ping
authorTim Riker <tim@rikers.org>
Sat, 18 May 2002 09:16:04 +0000 (09:16 -0000)
committerTim Riker <tim@rikers.org>
Sat, 18 May 2002 09:16:04 +0000 (09:16 -0000)
networking/ping.c

index e3ba2ed27f5374fd11ba21f1dcf7a0dd05172ed8..dd559648686458f452f52aa9b6e5cd9a977650d7 100644 (file)
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: ping.c,v 1.50 2002/03/21 14:04:43 andersen Exp $
+ * $Id: ping.c,v 1.51 2002/05/18 09:16:04 timr Exp $
  * Mini ping implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -147,7 +147,7 @@ static const int PINGINTERVAL = 1;          /* second */
 #define        CLR(bit)        (A(bit) &= (~B(bit)))
 #define        TST(bit)        (A(bit) & B(bit))
 
-static void ping(const char *host);
+static int ping(const char *host);
 
 /* common routines */
 static int in_cksum(unsigned short *buf, int sz)
@@ -414,7 +414,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
                                        icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
 }
 
-static void ping(const char *host)
+static int ping(const char *host)
 {
        char packet[datalen + MAXIPLEN + MAXICMPLEN];
        int sockopt;
@@ -468,6 +468,7 @@ static void ping(const char *host)
                        break;
        }
        pingstats(0);
+       return(nreceived > 0);
 }
 
 extern int ping_main(int argc, char **argv)
@@ -509,8 +510,7 @@ extern int ping_main(int argc, char **argv)
                show_usage();
 
        myid = getpid() & 0xFFFF;
-       ping(*argv);
-       return EXIT_SUCCESS;
+       return ping(*argv);
 }
 #endif /* ! CONFIG_FEATURE_FANCY_PING */