#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))
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);
}
//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
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 */
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);
}
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;
}