-/*
+/*
* fping: fast-ping, file-ping, favorite-ping, funky-ping
*
* Ping a list of target hosts in a round robin fashion.
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
- * by Stanford University. The name of the University may not be used
- * to endorse or promote products derived from this software without
+ * by Stanford University. The name of the University may not be used
+ * to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
/* times get *100 because all times are calculated in 10 usec units, not ms */
unsigned int retry = DEFAULT_RETRY;
-unsigned int timeout = DEFAULT_TIMEOUT * 100;
+unsigned int timeout = DEFAULT_TIMEOUT * 100;
unsigned int interval = DEFAULT_INTERVAL * 100;
unsigned int perhost_interval = DEFAULT_PERHOST_INTERVAL * 100;
float backoff = DEFAULT_BACKOFF_FACTOR;
num_othericmprcvd = 0; /* total non-echo-reply ICMP received */
struct timeval current_time; /* current time (pseudo) */
-struct timeval start_time;
+struct timeval start_time;
struct timeval end_time;
struct timeval last_send_time; /* time last ping was sent */
struct timeval next_report_time; /* time next -Q report is expected */
Inputs: int argc, char** argv
Description:
-
+
Main program entry point
************************************************************/
int c, i, n;
char *buf;
uid_t uid;
- int tos = 0;
+ int tos = 0;
HOST_ENTRY *cursor;
prog = argv[0];
netdata_flag = 1;
break;
- case 'd':
+ case 'd':
case 'n':
name_flag = 1;
break;
alive_flag = 1;
break;
- case 'H':
+ case 'H':
if( !( ttl = ( u_int )atoi( optarg ) ))
usage(1);
- break;
+ break;
#if defined( DEBUG ) || defined( _DEBUG )
case 'z':
printf( "%s: comments to %s\n", argv[0], EMAIL );
exit( 0 );
- case 'f':
+ case 'f':
filename = optarg;
break;
/* validate various option settings */
if (ttl > 255) {
- fprintf(stderr, "ttl %u out of range\n", ttl);
+ fprintf(stderr, "ttl %u out of range\n", ttl);
exit(1);
- }
+ }
if( unreachable_flag && alive_flag )
{
}/* IF */
if( ( interval < MIN_INTERVAL * 100 ||
- perhost_interval < MIN_PERHOST_INTERVAL * 100 )
+ perhost_interval < MIN_PERHOST_INTERVAL * 100 )
&& getuid() )
{
fprintf( stderr, "%s: these options are too risky for mere mortals.\n", prog );
}
}
-#if HAVE_SO_TIMESTAMP
+#if HAVE_SO_TIMESTAMP
{
int opt = 1;
if (setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) {
last_send_time.tv_sec = current_time.tv_sec - 10000;
#if defined( DEBUG ) || defined( _DEBUG )
- if( randomly_lose_flag )
+ if( randomly_lose_flag )
srandom( start_time.tv_usec );
#endif /* DEBUG || _DEBUG */
void add_cidr(char *addr)
{
char *addr_end;
- char *mask_str;
+ char *mask_str;
unsigned long mask;
unsigned long bitmask;
int ret;
{
printf( "%s", h->host );
- if( verbose_flag )
+ if( verbose_flag )
printf( " is unreachable" );
printf( "\n" );
if( num_noaddress )
exit( 2 );
else if( num_alive != num_hosts )
- exit( 1 );
+ exit( 1 );
exit(0);
return 0;
}
-#if HAVE_SO_TIMESTAMP
+#if HAVE_SO_TIMESTAMP
// ancilliary data
struct cmsghdr *cmsg;
for(cmsg = CMSG_FIRSTHDR(&recv_msghdr);
getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
printf( "received packet too short for ICMP (%d bytes from %s)\n", (int) reply_buf_len, buf);
}
- return 0; /* too short */
+ return 0; /* too short */
}
icp = (struct icmp6_hdr *) reply_buf;
h->num_recv_total++;
#if defined( DEBUG ) || defined( _DEBUG )
- if( trace_flag )
+ if( trace_flag )
printf( "received [%d] from %s\n", this_count, h->host );
#endif /* DEBUG || _DEBUG */
if(!quiet_flag)
print_warning("%s: %s\n", name, gai_strerror(ret_ga));
num_noaddress++;
- return;
+ return;
}
// NOTE: we could/should loop with res on all addresses like this:
print_warning("%s: %s\n", name, gai_strerror(ret_ga));
}
num_noaddress++;
- return;
+ return;
}
printname = namebuf;
}
print_warning("%s: %s\n", name, gai_strerror(ret_ga));
}
num_noaddress++;
- return;
+ return;
}
if(name_flag) {
Description:
timeval_diff now returns result in hundredths of milliseconds
- ie, tens of microseconds
+ ie, tens of microseconds
************************************************************/
i = ev_last;
while(1) {
i_prev = i->ev_prev;
- if(i_prev == NULL ||
+ if(i_prev == NULL ||
h->ev_time.tv_sec > i_prev->ev_time.tv_sec ||
(h->ev_time.tv_sec == i_prev->ev_time.tv_sec &&
h->ev_time.tv_usec >= i_prev->ev_time.tv_usec))
fprintf(out, " -A show targets by address\n" );
fprintf(out, " -b n amount of ping data to send, in bytes (default %d)\n", DEFAULT_PING_DATA_SIZE);
fprintf(out, " -B f set exponential backoff factor to f\n" );
- fprintf(out, " -c n count of pings to send to each target (default %d)\n", count );
+ fprintf(out, " -c n count of pings to send to each target (default %d)\n", count );
fprintf(out, " -C n same as -c, report results in verbose format\n" );
fprintf(out, " -D print timestamp before each output line\n" );
fprintf(out, " -e show elapsed time on return packets\n" );