X-Git-Url: http://git.rot13.org/?p=bcm963xx.git;a=blobdiff_plain;f=userapps%2Fopensource%2Fbusybox%2Fnetworking%2Fping.c;h=0a2ba499ebbd59a2a28171a10fcf5c00c1e5a490;hp=00fa7cafb03ba46c8df8a190bf925485c21d5b5b;hb=6adeba4d92a546ebbadde2562283ee6b984b22c1;hpb=dacd86d83a9fb430cca42cb78a67f9d46e289f5c diff --git a/userapps/opensource/busybox/networking/ping.c b/userapps/opensource/busybox/networking/ping.c index 00fa7caf..0a2ba499 100755 --- a/userapps/opensource/busybox/networking/ping.c +++ b/userapps/opensource/busybox/networking/ping.c @@ -62,7 +62,7 @@ static const int PINGINTERVAL = 1; /* second */ #define O_QUIET (1 << 0) #define O_LOG 2 - +#define PING_PID_FILE "/var/pingPid" #define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */ #define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */ #define SET(bit) (A(bit) |= B(bit)) @@ -210,13 +210,19 @@ static void logStat(int finish) memcpy(&addr, hostent->h_addr, sizeof(ip)); strncpy(ip,inet_ntoa(addr),16); /* IP, sent, receive, lost, min, max, average */ + if( nreceived ) fprintf(pingFile,"IP = %s Sent = %ld Receive = %ld Lost = %ld Min = %lu.%lu ms Max = %lu.%lu ms Average = %lu.%lu ms \n", ip, ntransmitted, nreceived, (ntransmitted-nreceived), (tmin / 10), (tmin % 10), (tmax / 10), (tmax % 10), ((tsum / (nreceived + nrepeats)) / 10), ((tsum / (nreceived + nrepeats)) % 10)); - + else + fprintf(pingFile,"IP = %s Sent = %ld Receive = %ld Lost = %ld Min = %lu.%lu ms Max = %lu.%lu ms Average = %lu.%lu ms \n", + ip, ntransmitted, nreceived, (ntransmitted-nreceived), + (tmin / 10), (tmin % 10), + (tmin / 10), (tmin % 10), + (tmin / 10), (tmin % 10)); fclose(pingFile); } @@ -248,8 +254,7 @@ static void pingstats(int junk) //BRCM begin if (options & O_LOG) { logStat(1); - if (access("/var/pingPid",F_OK) == 0) - unlink("/var/pingPid"); + remove_file(PING_PID_FILE,FILEUTILS_FORCE); } //BRCM end @@ -446,7 +451,7 @@ static void ping(const char *host) extern int ping_main(int argc, char **argv) { - FILE *fd; + // FILE *fd; char *thisarg; datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */ @@ -476,7 +481,7 @@ extern int ping_main(int argc, char **argv) break; //BRCM begin case 'l': - if ((pingPid = fopen ("/var/pingPid", "w")) != NULL) { + if ((pingPid = fopen (PING_PID_FILE, "w")) != NULL) { fprintf(pingPid,"%d\n",getpid()); (void)fclose(pingPid); } @@ -497,9 +502,7 @@ extern int ping_main(int argc, char **argv) ping(*argv); if (options & O_LOG) { - if (access("/var/pingPid",F_OK) == 0) { - unlink("/var/pingPid"); - } + remove_file(PING_PID_FILE,FILEUTILS_FORCE); } return EXIT_SUCCESS; }