Created
April 25, 2012 08:57
-
-
Save richlv/2488322 to your computer and use it in GitHub Desktop.
fping3 trailing whitespace removal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur schweikert-fping-8047122//README modified//README | |
--- schweikert-fping-8047122//README 2012-02-23 23:42:00.000000000 +0200 | |
+++ modified//README 2012-04-25 11:52:39.538064725 +0300 | |
@@ -32,4 +32,4 @@ | |
Original author: Roland Schemers (schemers@stanford.edu) | |
Previous maintainer: RL "Bob" Morgan (morgan@stanford.edu) | |
IPv6 Support: Jeroen Massar (jeroen@unfix.org / jeroen@ipng.nl) | |
- to enable IPV6 compile with -DIPV6 | |
+ to enable IPV6 compile with -DIPV6 | |
diff -ur schweikert-fping-8047122//src/fping.c modified//src/fping.c | |
--- schweikert-fping-8047122//src/fping.c 2012-02-23 23:42:00.000000000 +0200 | |
+++ modified//src/fping.c 2012-04-25 11:52:45.101798767 +0300 | |
@@ -1,4 +1,4 @@ | |
-/* | |
+/* | |
* fping: fast-ping, file-ping, favorite-ping, funky-ping | |
* | |
* Ping a list of target hosts in a round robin fashion. | |
@@ -22,8 +22,8 @@ | |
* 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 | |
@@ -132,7 +132,7 @@ | |
#define MAX_PING_DATA ( MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR ) | |
/* sized so as to be like traditional ping */ | |
-#define DEFAULT_PING_DATA_SIZE ( MIN_PING_DATA + 44 ) | |
+#define DEFAULT_PING_DATA_SIZE ( MIN_PING_DATA + 44 ) | |
/* maxima and minima */ | |
#define MAX_COUNT 10000 | |
@@ -265,7 +265,7 @@ | |
/* 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; | |
@@ -299,7 +299,7 @@ | |
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 last_report_time; /* time last report was printed */ | |
@@ -364,7 +364,7 @@ | |
Inputs: int argc, char** argv | |
Description: | |
- | |
+ | |
Main program entry point | |
************************************************************/ | |
@@ -378,7 +378,7 @@ | |
struct protoent *proto; | |
char *buf; | |
uid_t uid; | |
- int tos = 0; | |
+ int tos = 0; | |
#ifndef IPV6 | |
struct sockaddr_in sa; | |
@@ -391,9 +391,9 @@ | |
/* confirm that ICMP is available on this machine */ | |
#ifndef IPV6 | |
- if( ( proto = getprotobyname( "icmp" ) ) == NULL ) | |
+ if( ( proto = getprotobyname( "icmp" ) ) == NULL ) | |
#else | |
- if( ( proto = getprotobyname( "ipv6-icmp" ) ) == NULL ) | |
+ if( ( proto = getprotobyname( "ipv6-icmp" ) ) == NULL ) | |
#endif | |
crash_and_burn( "icmp: unknown protocol" ); | |
@@ -498,11 +498,11 @@ | |
usage(); | |
break; | |
- | |
+ | |
case 'r': | |
retry = ( unsigned int )atoi( optarg ); | |
break; | |
- | |
+ | |
case 'i': | |
if( !( interval = ( unsigned int )atoi( optarg ) * 100 ) ) | |
usage(); | |
@@ -518,14 +518,14 @@ | |
case 'c': | |
if( !( count = ( unsigned int )atoi( optarg ) ) ) | |
usage(); | |
- | |
+ | |
count_flag = 1; | |
break; | |
- | |
+ | |
case 'C': | |
if( !( count = ( unsigned int )atoi( optarg ) ) ) | |
usage(); | |
- | |
+ | |
count_flag = 1; | |
report_all_rtts_flag = 1; | |
break; | |
@@ -533,7 +533,7 @@ | |
case 'b': | |
if( !( ping_data_size = ( unsigned int )atoi( optarg ) ) ) | |
usage(); | |
- | |
+ | |
break; | |
case 'h': | |
@@ -550,7 +550,7 @@ | |
quiet_flag = 1; | |
if( !( report_interval = ( unsigned int )atoi( optarg ) * 100000 ) ) | |
usage(); | |
- | |
+ | |
break; | |
case 'e': | |
@@ -561,7 +561,7 @@ | |
multif_flag = 1; | |
break; | |
- case 'd': | |
+ case 'd': | |
case 'n': | |
name_flag = 1; | |
break; | |
@@ -573,7 +573,7 @@ | |
case 'B': | |
if( !( backoff = atof( optarg ) ) ) | |
usage(); | |
- | |
+ | |
break; | |
case 's': | |
@@ -597,7 +597,7 @@ | |
case 'z': | |
if( ! ( debugging = ( unsigned int )atoi( optarg ) ) ) | |
usage(); | |
- | |
+ | |
break; | |
#endif /* DEBUG || _DEBUG */ | |
@@ -606,7 +606,7 @@ | |
printf( "%s: comments to %s\n", argv[0], EMAIL ); | |
exit( 0 ); | |
- case 'f': | |
+ case 'f': | |
#ifdef ENABLE_F_OPTION | |
filename = optarg; | |
generate_flag = 0; | |
@@ -687,13 +687,13 @@ | |
{ | |
fprintf( stderr, "%s: specify only one of c, l\n", argv[0] ); | |
usage(); | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
if( ( interval < MIN_INTERVAL * 100 || | |
- perhost_interval < MIN_PERHOST_INTERVAL * 100 || | |
- retry > MAX_RETRY || | |
- timeout < MIN_TIMEOUT * 100 ) | |
+ perhost_interval < MIN_PERHOST_INTERVAL * 100 || | |
+ retry > MAX_RETRY || | |
+ timeout < MIN_TIMEOUT * 100 ) | |
&& getuid() ) | |
{ | |
fprintf( stderr, "%s: these options are too risky for mere mortals.\n", prog ); | |
@@ -702,21 +702,21 @@ | |
usage(); | |
}/* IF */ | |
- | |
+ | |
if( ( ping_data_size > MAX_PING_DATA ) || ( ping_data_size < MIN_PING_DATA ) ) | |
{ | |
fprintf( stderr, "%s: data size %u not valid, must be between %u and %u\n", | |
prog, ping_data_size, (unsigned int) MIN_PING_DATA, (unsigned int) MAX_PING_DATA ); | |
usage(); | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
if( ( backoff > MAX_BACKOFF_FACTOR ) || ( backoff < MIN_BACKOFF_FACTOR ) ) | |
{ | |
fprintf( stderr, "%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n", | |
prog, backoff, MIN_BACKOFF_FACTOR, MAX_BACKOFF_FACTOR ); | |
usage(); | |
- | |
+ | |
}/* IF */ | |
if( count > MAX_COUNT ) | |
@@ -724,37 +724,37 @@ | |
fprintf( stderr, "%s: count %u not valid, must be less than %u\n", | |
prog, count, MAX_COUNT ); | |
usage(); | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
if( alive_flag || unreachable_flag ) | |
verbose_flag = 0; | |
- | |
+ | |
if( count_flag ) | |
{ | |
if( verbose_flag ) | |
per_recv_flag = 1; | |
- | |
+ | |
alive_flag = unreachable_flag = verbose_flag = 0; | |
}/* IF */ | |
- | |
+ | |
if( loop_flag ) | |
{ | |
if( !report_interval ) | |
per_recv_flag = 1; | |
- | |
+ | |
alive_flag = unreachable_flag = verbose_flag = 0; | |
}/* IF */ | |
- | |
+ | |
trials = ( count > retry + 1 ) ? count : retry + 1; | |
#if defined( DEBUG ) || defined( _DEBUG ) | |
if( debugging & DBG_TRACE ) | |
trace_flag = 1; | |
- | |
+ | |
if( ( debugging & DBG_SENT_TIMES ) && !loop_flag ) | |
sent_times_flag = 1; | |
@@ -762,16 +762,16 @@ | |
{ | |
randomly_lose_flag = 1; | |
lose_factor = 1; /* ie, 1/4 */ | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
if( debugging & DBG_RANDOM_LOSE_MANY ) | |
{ | |
randomly_lose_flag = 1; | |
lose_factor = 5; /* ie, 3/4 */ | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
if( debugging & DBG_PRINT_PER_SYSTEM ) | |
print_per_system_flag = 1; | |
@@ -786,7 +786,7 @@ | |
perhost_interval / 10, timeout / 10 ); | |
fprintf( stderr, " ping_data_size = %u, trials = %u\n", | |
ping_data_size, trials ); | |
- | |
+ | |
if( verbose_flag ) fprintf( stderr, " verbose_flag set\n" ); | |
if( multif_flag ) fprintf( stderr, " multif_flag set\n" ); | |
if( name_flag ) fprintf( stderr, " name_flag set\n" ); | |
@@ -825,7 +825,7 @@ | |
/* if no conditions are specified, then assume input from stdin */ | |
if( !*argv && !filename && !generate_flag ) | |
filename = "-"; | |
- | |
+ | |
if( *argv && !generate_flag ) | |
{ | |
while( *argv ) | |
@@ -841,7 +841,7 @@ | |
char line[132]; | |
char host[132]; | |
char *p; | |
- | |
+ | |
if( strcmp( filename, "-" ) == 0 ) | |
ping_file = fdopen( 0, "r" ); | |
else | |
@@ -855,15 +855,15 @@ | |
{ | |
if( sscanf( line, "%s", host ) != 1 ) | |
continue; | |
- | |
+ | |
if( ( !*host ) || ( host[0] == '#' ) ) /* magic to avoid comments */ | |
continue; | |
- | |
+ | |
p = cpystr( host ); | |
add_name( p ); | |
- | |
+ | |
}/* WHILE */ | |
- | |
+ | |
fclose( ping_file ); | |
} | |
else if( *argv && generate_flag ) { | |
@@ -881,7 +881,7 @@ | |
else { | |
usage(); | |
} | |
- | |
+ | |
if( !num_hosts ) | |
exit( 2 ); | |
@@ -913,7 +913,7 @@ | |
{ | |
table[num_jobs] = cursor; | |
cursor->i = num_jobs; | |
- | |
+ | |
/* as long as we're here, put this in so names print out nicely */ | |
if( count_flag || loop_flag ) | |
{ | |
@@ -921,7 +921,7 @@ | |
buf = ( char* ) malloc( n + 1 ); | |
if( !buf ) | |
crash_and_burn( "can't malloc host pad" ); | |
- | |
+ | |
for ( i = 0; i < n; i++ ) | |
buf[i] = ' '; | |
@@ -929,15 +929,15 @@ | |
cursor->pad = buf; | |
}/* IF */ | |
- | |
+ | |
cursor=cursor->ev_next; | |
}/* FOR */ | |
ping_pkt_size = ping_data_size + SIZE_ICMP_HDR; | |
- | |
+ | |
signal( SIGINT, finish ); | |
- | |
+ | |
gettimeofday( &start_time, &tz ); | |
current_time = start_time; | |
@@ -947,7 +947,7 @@ | |
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 */ | |
@@ -962,7 +962,7 @@ | |
void add_cidr(char *addr) | |
{ | |
char *addr_end; | |
- char *mask_str; | |
+ char *mask_str; | |
unsigned long mask; | |
unsigned long bitmask; | |
int ret; | |
@@ -1202,7 +1202,7 @@ | |
Inputs: void (none) | |
Description: | |
- | |
+ | |
Main program clean up and exit point | |
************************************************************/ | |
@@ -1227,11 +1227,11 @@ | |
{ | |
printf( "%s", h->host ); | |
- if( verbose_flag ) | |
+ if( verbose_flag ) | |
printf( " is unreachable" ); | |
- | |
+ | |
printf( "\n" ); | |
- | |
+ | |
}/* IF */ | |
}/* IF */ | |
}/* FOR */ | |
@@ -1249,8 +1249,8 @@ | |
if( num_noaddress ) | |
exit( 2 ); | |
else if( num_alive != num_hosts ) | |
- exit( 1 ); | |
- | |
+ exit( 1 ); | |
+ | |
exit(0); | |
} /* finish() */ | |
@@ -1265,7 +1265,7 @@ | |
Inputs: void (none) | |
Description: | |
- | |
+ | |
************************************************************/ | |
@@ -1305,9 +1305,9 @@ | |
fprintf( stderr, " -" ); | |
}/* FOR */ | |
- | |
+ | |
fprintf( stderr, "\n" ); | |
- | |
+ | |
}/* IF */ | |
else | |
{ | |
@@ -1323,18 +1323,18 @@ | |
fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%", | |
h->num_sent, h->num_recv, | |
( ( h->num_recv * 100 ) / h->num_sent ) ); | |
- | |
+ | |
}/* ELSE */ | |
- | |
+ | |
if( h->num_recv ) | |
{ | |
avg = h->total_time / h->num_recv; | |
fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply ) ); | |
fprintf( stderr, "/%s", sprint_tm( avg ) ); | |
fprintf( stderr, "/%s", sprint_tm( h->max_reply ) ); | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
fprintf(stderr, "\n"); | |
}/* ELSE */ | |
@@ -1348,14 +1348,14 @@ | |
fprintf( stderr, " %s", sprint_tm( resp ) ); | |
else | |
fprintf( stderr, " -" ); | |
- | |
+ | |
fprintf( stderr, "\n" ); | |
}/* FOR */ | |
}/* IF */ | |
#endif /* DEBUG || _DEBUG */ | |
}/* FOR */ | |
- | |
+ | |
free( buf ); | |
} /* print_per_system_stats() */ | |
@@ -1370,7 +1370,7 @@ | |
Inputs: void (none) | |
Description: | |
- | |
+ | |
************************************************************/ | |
@@ -1424,13 +1424,13 @@ | |
fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply_i ) ); | |
fprintf( stderr, "/%s", sprint_tm( avg ) ); | |
fprintf( stderr, "/%s", sprint_tm( h->max_reply_i ) ); | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
fprintf( stderr, "\n" ); | |
h->num_sent_i = h->num_recv_i = h->max_reply_i = | |
h->min_reply_i = h->total_time_i = 0; | |
- | |
+ | |
}/* FOR */ | |
free( buf ); | |
@@ -1447,7 +1447,7 @@ | |
Inputs: void (none) | |
Description: | |
- | |
+ | |
************************************************************/ | |
@@ -1472,7 +1472,7 @@ | |
max_reply = 0; | |
total_replies = 1; | |
sum_replies = 0; | |
- | |
+ | |
}/* IF */ | |
fprintf( stderr, " %s ms (min round trip time)\n", sprint_tm( min_reply ) ); | |
@@ -1515,7 +1515,7 @@ | |
buffer = ( char* )malloc( ( size_t )ping_pkt_size ); | |
if( !buffer ) | |
crash_and_burn( "can't malloc ping packet" ); | |
- | |
+ | |
memset( buffer, 0, ping_pkt_size * sizeof( char ) ); | |
icp = ( FPING_ICMPHDR* )buffer; | |
@@ -1562,13 +1562,13 @@ | |
printf( "%s", h->host ); | |
if( verbose_flag ) | |
printf( " error while sending ping: %s\n", strerror( errno ) ); | |
- | |
+ | |
printf( "\n" ); | |
}/* IF */ | |
- | |
+ | |
num_unreachable++; | |
- remove_job( h ); | |
+ remove_job( h ); | |
free( buffer ); | |
return(0); | |
} | |
@@ -1587,7 +1587,7 @@ | |
h->waiting++; | |
num_pingsent++; | |
last_send_time = h->last_send_time; | |
- | |
+ | |
free( buffer ); | |
return(1); | |
} | |
@@ -1604,7 +1604,7 @@ | |
Returns: int | |
Description: | |
- | |
+ | |
************************************************************/ | |
@@ -1626,7 +1626,7 @@ | |
if( result < 0 ) | |
return 0; /* timeout */ | |
- | |
+ | |
#if defined( DEBUG ) || defined( _DEBUG ) | |
if( randomly_lose_flag ) | |
{ | |
@@ -1657,13 +1657,13 @@ | |
#ifndef IPV6 | |
printf( "received packet too short for ICMP (%d bytes from %s)\n", result, | |
inet_ntoa( response_addr.sin_addr ) ); | |
-#else | |
+#else | |
char buf[INET6_ADDRSTRLEN]; | |
inet_ntop(response_addr.sin6_family, &response_addr.sin6_addr, buf, INET6_ADDRSTRLEN); | |
printf( "received packet too short for ICMP (%d bytes from %s)\n", result, buf); | |
#endif | |
} | |
- return( 1 ); /* too short */ | |
+ return( 1 ); /* too short */ | |
}/* IF */ | |
icp = ( FPING_ICMPHDR* )( buffer + hlen ); | |
@@ -1718,7 +1718,7 @@ | |
#endif | |
#if defined( DEBUG ) || defined( _DEBUG ) | |
- if( trace_flag ) | |
+ if( trace_flag ) | |
printf( "received [%d] from %s\n", this_count, h->host ); | |
#endif /* DEBUG || _DEBUG */ | |
@@ -1733,7 +1733,7 @@ | |
h->total_time += this_reply; | |
h->total_time_i += this_reply; | |
total_replies++; | |
- | |
+ | |
/* note reply time in array, probably */ | |
if( !loop_flag ) | |
{ | |
@@ -1756,21 +1756,21 @@ | |
fprintf( stderr, " [<- %s]", buf); | |
} | |
-#endif | |
+#endif | |
fprintf( stderr, "\n" ); | |
- | |
+ | |
}/* IF */ | |
}/* IF */ | |
else | |
h->resp_times[this_count] = this_reply; | |
- | |
+ | |
}/* IF */ | |
else | |
{ | |
/* count is out of bounds?? */ | |
fprintf( stderr, "%s : duplicate for [%d], %d bytes, %s ms\n", | |
h->host, this_count, result, sprint_tm( this_reply ) ); | |
- | |
+ | |
}/* ELSE */ | |
}/* IF */ | |
@@ -1798,7 +1798,7 @@ | |
} | |
#endif | |
printf( "\n" ); | |
- | |
+ | |
}/* IF */ | |
}/* IF */ | |
@@ -1808,7 +1808,7 @@ | |
printf( "%s%s : [%d], %d bytes, %s ms", | |
h->host, h->pad, this_count, result, sprint_tm( this_reply ) ); | |
printf( " (%s avg, ", sprint_tm( avg ) ); | |
- | |
+ | |
if( h->num_recv <= h->num_sent ) | |
{ | |
printf( "%d%% loss)", | |
@@ -1819,7 +1819,7 @@ | |
{ | |
printf( "%d%% return)", | |
( h->num_recv * 100 ) / h->num_sent ); | |
- | |
+ | |
}/* ELSE */ | |
#ifndef IPV6 | |
if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr ) | |
@@ -1832,9 +1832,9 @@ | |
fprintf( stderr, " [<- %s]", buf); | |
} | |
#endif | |
- | |
+ | |
printf( "\n" ); | |
- | |
+ | |
}/* IF */ | |
/* remove this job, if we are done */ | |
@@ -1843,7 +1843,7 @@ | |
{ | |
remove_job(h); | |
} | |
- | |
+ | |
fflush( stdout ); | |
return num_jobs; | |
@@ -1860,7 +1860,7 @@ | |
Returns: int | |
Description: | |
- | |
+ | |
************************************************************/ | |
@@ -1883,17 +1883,17 @@ | |
{ | |
case ICMP_UNREACH: | |
sent_icmp = ( FPING_ICMPHDR* )( c + 28 ); | |
- | |
+ | |
#ifndef IPV6 | |
sent_icmp = ( struct icmp* )( c + 28 ); | |
- | |
+ | |
if( ( sent_icmp->icmp_type == ICMP_ECHO ) && | |
( ntohs(sent_icmp->icmp_id) == ident ) && | |
( ntohs(sent_icmp->icmp_seq) <= ( n_short )max_seq_sent ) ) | |
{ | |
/* this is a response to a ping we sent */ | |
h = table[ntohs(sent_icmp->icmp_seq) % num_hosts]; | |
- | |
+ | |
if( p->icmp_code > ICMP_UNREACH_MAXTYPE ) | |
{ | |
fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s", | |
@@ -1906,7 +1906,7 @@ | |
{ | |
/* this is a response to a ping we sent */ | |
h = table[ntohs(sent_icmp->icmp6_seq) % num_hosts]; | |
- | |
+ | |
if( p->icmp6_code > ICMP_UNREACH_MAXTYPE ) | |
{ | |
fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s", | |
@@ -1921,7 +1921,7 @@ | |
#else | |
icmp_unreach_str[p->icmp6_code], addr_ascii, h->host ); | |
#endif | |
- | |
+ | |
}/* ELSE */ | |
if( inet_addr( h->host ) == -1 ) | |
@@ -1930,9 +1930,9 @@ | |
#else | |
fprintf( stderr, " (%s)", addr_ascii); | |
#endif | |
- | |
+ | |
fprintf( stderr, "\n" ); | |
- | |
+ | |
}/* IF */ | |
return 1; | |
@@ -1951,7 +1951,7 @@ | |
h = table[ntohs(sent_icmp->icmp_seq) % num_hosts]; | |
fprintf( stderr, "%s from %s for ICMP Echo sent to %s", | |
icmp_type_str[p->icmp_type], inet_ntoa( addr->sin_addr ), h->host ); | |
- | |
+ | |
if( inet_addr( h->host ) == -1 ) | |
fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) ); | |
#else | |
@@ -1963,13 +1963,13 @@ | |
h = table[ntohs(sent_icmp->icmp6_seq) % num_hosts]; | |
fprintf( stderr, "%s from %s for ICMP Echo sent to %s", | |
icmp_type_str[p->icmp6_type], addr_ascii, h->host ); | |
- | |
+ | |
if( inet_addr( h->host ) == -1 ) | |
fprintf( stderr, " (%s)", addr_ascii ); | |
#endif | |
fprintf( stderr, "\n" ); | |
- | |
+ | |
}/* IF */ | |
return 2; | |
@@ -1984,7 +1984,7 @@ | |
case ICMP_MASKREPLY: | |
default: | |
return 0; | |
- | |
+ | |
}/* SWITCH */ | |
} /* handle_random_icmp() */ | |
@@ -2017,7 +2017,7 @@ | |
{ | |
sum += *p++; | |
n -= 2; | |
- | |
+ | |
}/* WHILE */ | |
@@ -2026,13 +2026,13 @@ | |
{ | |
*( unsigned char* )( &odd_byte ) = *( unsigned char* )p; | |
sum += odd_byte; | |
- | |
+ | |
}/* IF */ | |
sum = ( sum >> 16 ) + ( sum & 0xffff ); /* add hi 16 to low 16 */ | |
sum += ( sum >> 16 ); /* add carry */ | |
answer = ~sum; /* ones-complement, truncate*/ | |
- | |
+ | |
return ( answer ); | |
} /* in_cksum() */ | |
@@ -2080,18 +2080,18 @@ | |
}/* IF */ | |
else | |
add_addr( name, name, *ipa ); | |
- | |
+ | |
return; | |
- | |
+ | |
}/* IF */ | |
/* input name is not an IP addr, maybe it's a host name */ | |
- host_ent = gethostbyname( name ); | |
+ host_ent = gethostbyname( name ); | |
if( host_ent == NULL ) | |
- { | |
+ { | |
if( h_errno == TRY_AGAIN ) | |
- { | |
- u_sleep( DNS_TIMEOUT ); | |
+ { | |
+ u_sleep( DNS_TIMEOUT ); | |
host_ent = gethostbyname( name ); | |
}/* IF */ | |
@@ -2108,37 +2108,37 @@ | |
endnetgrent(); | |
if( !quiet_flag ) | |
fprintf( stderr, "%s address not found\n", name ); | |
- | |
+ | |
num_noaddress++; | |
return; | |
- | |
+ | |
}/* IF */ | |
else | |
add_name( cpystr( machine ) ); | |
while( getnetgrent( &machine, &user_ignored, &domain_ignored ) ) | |
add_name( cpystr( machine ) ); | |
- | |
+ | |
endnetgrent(); | |
return; | |
#else | |
if( !quiet_flag ) | |
fprintf( stderr, "%s address not found\n", name ); | |
- | |
+ | |
num_noaddress++; | |
- return ; | |
+ return ; | |
#endif /* NIS_GROUPS */ | |
}/* IF */ | |
}/* IF */ | |
- | |
- host_add = ( struct in_addr* )*( host_ent->h_addr_list ); | |
+ | |
+ host_add = ( struct in_addr* )*( host_ent->h_addr_list ); | |
if( host_add == NULL ) | |
- { | |
+ { | |
if( !quiet_flag ) | |
fprintf( stderr, "%s has no address data\n", name ); | |
- | |
+ | |
num_noaddress++; | |
- return; | |
+ return; | |
}/* IF */ | |
else | |
@@ -2155,11 +2155,11 @@ | |
}/* ELSE IF */ | |
else | |
add_addr( name, name, *host_add ); | |
- | |
+ | |
if( !multif_flag ) | |
break; | |
- host_add = ( struct in_addr* )( host_ent->h_addr_list[++i] ); | |
+ host_add = ( struct in_addr* )( host_ent->h_addr_list[++i] ); | |
}/* WHILE */ | |
}/* ELSE */ | |
@@ -2182,7 +2182,7 @@ | |
if(!quiet_flag) | |
warnx("%s", gai_strerror(ret_ga)); | |
num_noaddress++; | |
- return; | |
+ return; | |
} | |
if (res->ai_canonname) hostname = res->ai_canonname; | |
else hostname = name; | |
@@ -2190,7 +2190,7 @@ | |
if(!quiet_flag) | |
warnx("getaddrinfo failed"); | |
num_noaddress++; | |
- return; | |
+ return; | |
} | |
len = res->ai_addrlen; | |
if (len > sizeof(FPING_SOCKADDR)) len = sizeof(FPING_SOCKADDR); | |
@@ -2223,7 +2223,7 @@ | |
if( !nm ) | |
crash_and_burn( "can't allocate some space for a string" ); | |
- | |
+ | |
strcpy( nm, name ); | |
strcat( nm, " (" ); | |
strcat( nm, as ); | |
@@ -2268,7 +2268,7 @@ | |
p->host = host; | |
#ifndef IPV6 | |
p->saddr.sin_family = AF_INET; | |
- p->saddr.sin_addr = ipaddr; | |
+ p->saddr.sin_addr = ipaddr; | |
#else | |
p->saddr.sin6_family = AF_INET6; | |
(void)memcpy(&p->saddr, ipaddr, sizeof(FPING_SOCKADDR)); | |
@@ -2286,10 +2286,10 @@ | |
i = ( int* )malloc( trials * sizeof( int ) ); | |
if( !i ) | |
crash_and_burn( "can't allocate resp_times array" ); | |
- | |
+ | |
for( n = 1; n < trials; n++ ) | |
i[n] = RESP_UNUSED; | |
- | |
+ | |
p->resp_times = i; | |
}/* IF */ | |
@@ -2301,12 +2301,12 @@ | |
i = ( int* )malloc( trials * sizeof( int ) ); | |
if( !i ) | |
crash_and_burn( "can't allocate sent_times array" ); | |
- | |
+ | |
for( n = 1; n < trials; n++ ) | |
i[n] = RESP_UNUSED; | |
- | |
+ | |
p->sent_times = i; | |
- | |
+ | |
}/* IF */ | |
#endif /* DEBUG || _DEBUG */ | |
@@ -2371,7 +2371,7 @@ | |
#else | |
h = gethostbyaddr( ( char* )&in, sizeof( FPING_SOCKADDR ),AF_INET6 ); | |
#endif | |
- | |
+ | |
if( h == NULL || h->h_name == NULL ) | |
return inet_ntoa( in ); | |
else | |
@@ -2403,12 +2403,12 @@ | |
dst = ( char* )malloc( 1 + strlen( string ) ); | |
if( !dst ) | |
crash_and_burn( "can't allocate some space for a string" ); | |
- | |
+ | |
strcpy( dst, string ); | |
return dst; | |
- | |
+ | |
}/* IF */ | |
- else | |
+ else | |
return NULL; | |
} /* cpystr() */ | |
@@ -2425,12 +2425,12 @@ | |
Description: | |
************************************************************/ | |
- | |
+ | |
void crash_and_burn( char *message ) | |
{ | |
if( verbose_flag ) | |
fprintf( stderr, "%s: %s\n", prog, message ); | |
- | |
+ | |
exit( 4 ); | |
} /* crash_and_burn() */ | |
@@ -2468,7 +2468,7 @@ | |
Description: | |
timeval_diff now returns result in hundredths of milliseconds | |
- ie, tens of microseconds | |
+ ie, tens of microseconds | |
************************************************************/ | |
@@ -2541,9 +2541,9 @@ | |
{ | |
sprintf( buf, "%d.%d", t / 100, ( t % 100 ) / 10 ); | |
return( buf ); | |
- | |
+ | |
}/* IF */ | |
- | |
+ | |
/* >= 100 ms */ | |
sprintf( buf, "%d", t / 100 ); | |
return( buf ); | |
@@ -2651,7 +2651,7 @@ | |
n = recvfrom( s, buf, len, 0, (struct sockaddr *)saddr, &slen ); | |
if( n < 0 ) | |
errno_crash_and_burn( "recvfrom" ); | |
- | |
+ | |
return n; | |
} /* recvfrom_wto() */ | |
@@ -2708,7 +2708,7 @@ | |
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)) | |
@@ -2788,7 +2788,7 @@ | |
fprintf( stderr, " -A show targets by address\n" ); | |
fprintf( stderr, " -b n amount of ping data to send, in bytes (default %d)\n", ping_data_size ); | |
fprintf( stderr, " -B f set exponential backoff factor to f\n" ); | |
- fprintf( stderr, " -c n count of pings to send to each target (default %d)\n", count ); | |
+ fprintf( stderr, " -c n count of pings to send to each target (default %d)\n", count ); | |
fprintf( stderr, " -C n same as -c, report results in verbose format\n" ); | |
fprintf( stderr, " -e show elapsed time on return packets\n" ); | |
fprintf( stderr, " -f file read list of targets from a file ( - means stdin) (only if no -g specified)\n" ); | |
@@ -2814,7 +2814,7 @@ | |
fprintf( stderr, " -u show targets that are unreachable\n" ); | |
fprintf( stderr, " -O n set the type of service (tos) flag on the ICMP packets\n" ); | |
fprintf( stderr, " -v show version\n" ); | |
- | |
+ | |
fprintf( stderr, " targets list of targets to check (if no -f specified)\n" ); | |
fprintf( stderr, "\n"); | |
exit( 3 ); | |
diff -ur schweikert-fping-8047122//src/options.h modified//src/options.h | |
--- schweikert-fping-8047122//src/options.h 2012-02-23 23:42:00.000000000 +0200 | |
+++ modified//src/options.h 2012-04-25 11:52:45.181794948 +0300 | |
@@ -1,20 +1,20 @@ | |
-/* | |
- * Interval is the minimum amount of time between sending a ping packet to | |
+/* | |
+ * Interval is the minimum amount of time between sending a ping packet to | |
* any host. | |
- * | |
- * Perhost_interval is the minimum amount of time between sending a ping | |
+ * | |
+ * Perhost_interval is the minimum amount of time between sending a ping | |
* packet to a particular responding host (when count is > 1) | |
- * | |
+ * | |
* Timeout is the initial amount of time between sending a ping packet to | |
* a particular non-responding host. | |
- * | |
+ * | |
* Retry is the number of ping packets to send to a non-responding host | |
* before giving up (in is-it-alive mode). | |
- * | |
+ * | |
* Backoff factor is how much longer to wait on successive retries. | |
- * | |
- * | |
+ * | |
+ * | |
*/ | |
/* constants */ | |
@@ -32,7 +32,7 @@ | |
#endif | |
-#ifndef DEFAULT_RETRY | |
+#ifndef DEFAULT_RETRY | |
#define DEFAULT_RETRY 3 /* number of times to retry a host */ | |
#endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment