head 1.4; access; symbols pkgsrc-2013Q2:1.4.0.54 pkgsrc-2013Q2-base:1.4 pkgsrc-2012Q4:1.4.0.52 pkgsrc-2012Q4-base:1.4 pkgsrc-2011Q4:1.4.0.50 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q2:1.4.0.48 pkgsrc-2011Q2-base:1.4 pkgsrc-2009Q4:1.4.0.46 pkgsrc-2009Q4-base:1.4 pkgsrc-2008Q4:1.4.0.44 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.42 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.40 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.38 pkgsrc-2008Q2-base:1.4 pkgsrc-2008Q1:1.4.0.36 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.34 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.32 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.30 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.28 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.26 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.24 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.22 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.20 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.18 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.16 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.14 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.4.0.12 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.10 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.8 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.6 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.4.0.4 pkgsrc-2004Q1-base:1.4 pkgsrc-2003Q4:1.4.0.2 pkgsrc-2003Q4-base:1.4 netbsd-1-6-1:1.3.0.6 netbsd-1-6-1-base:1.3 netbsd-1-6:1.3.0.8 netbsd-1-6-RELEASE-base:1.3 pkgviews:1.3.0.4 pkgviews-base:1.3 buildlink2:1.3.0.2 buildlink2-base:1.3 netbsd-1-5-PATCH003:1.3 netbsd-1-5-PATCH001:1.1.1.1 netbsd-1-5-RELEASE:1.1.1.1 netbsd-1-4-PATCH003:1.1.1.1 FreeBSD-current-2000-05-19:1.1.1.1 FREEBSD:1.1.1; locks; strict; comment @# @; 1.4 date 2003.03.24.15.14.34; author bouyer; state dead; branches; next 1.3; 1.3 date 2002.02.18.18.40.42; author abs; state Exp; branches; next 1.2; 1.2 date 2001.08.23.17.15.15; author abs; state Exp; branches; next 1.1; 1.1 date 2000.05.19.10.20.36; author abs; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2000.05.19.10.20.36; author abs; state Exp; branches; next ; desc @@ 1.4 log @Upgrade to 2.4b2. Lots of change since 1.20, but it should be backward-compatible. 2.0 was a substential rewrite. Main changes: support some traditional ping features: loop mode, specify size of data packets, specify how many pings to send, interpret ICMPs other than ICMP Echo response. make timings in tenths of milliseconds do exponential backoff on retries port to more systems do better checking on whether received ICMP is for us added -g option for generating IPs from a start to an end value @ text @$NetBSD: patch-ab,v 1.3 2002/02/18 18:40:42 abs Exp $ --- fping.c.orig Fri Feb 18 19:29:52 2022 +++ fping.c @@@@ -153,7 +153,7 @@@@ #include #include -#ifdef _POSIX_SOURCE +#if defined(_POSIX_SOURCE) || defined(__NetBSD__) #include #endif @@@@ -185,7 +185,9 @@@@ extern char *optarg; extern int optind,opterr; +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__linux__) extern char *sys_errlist[]; +#endif #ifdef __cplusplus @@@@ -234,9 +236,9 @@@@ int timeout = DEFAULT_TIMEOUT; int interval = DEFAULT_INTERVAL; -long max_reply=0; -long min_reply=10000; -int total_replies=0; +long max_reply=0; /* usec */ +long min_reply=10000; /* usec */ +int total_replies=0; /* usec */ double sum_replies=0; struct timeval timeout_timeval; @@@@ -385,6 +387,7 @@@@ } if (!ping_file) errno_crash_and_burn("fopen"); while(fgets(line,132,ping_file)) { + line[132-1] = '\0'; sscanf(line,"%s",host); if ((!*host) || (host[0]=='#')) /* magic to avoid comments */ continue; @@@@ -411,8 +414,8 @@@@ cursor=cursor->next; } - gettimeofday(&start_time,&tz); cursor=rrlist; + gettimeofday(&start_time,&tz); while (num_waiting) { /* while pings are outstanding */ if ( (timeval_diff(¤t_time,&cursor->last_time)> timeout) || cursor->num_packets_sent==0) { @@@@ -455,11 +458,11 @@@@ min_reply=0; max_reply=0; total_replies=1; sum_replies=0; } - fprintf(stderr," %8d msec (min round trip time)\n",min_reply); - fprintf(stderr," %8d msec (avg round trip time)\n",(int)sum_replies/total_replies); - fprintf(stderr," %8d msec (max round trip time)\n",max_reply); + fprintf(stderr," %8.3f msec (min round trip time)\n",min_reply/1000.0); + fprintf(stderr," %8.3f msec (avg round trip time)\n",sum_replies/total_replies/1000.0); + fprintf(stderr," %8.3f msec (max round trip time)\n",max_reply/1000.0); fprintf(stderr," %8.3f sec (elapsed real time)\n", - timeval_diff( &end_time,&start_time)/1000.0); + timeval_diff( &end_time,&start_time)/1000000.0); fprintf(stderr,"\n"); } @@@@ -493,8 +496,6 @@@@ struct icmp *icp = (struct icmp *) buffer; int n,len; - gettimeofday(&h->last_time,&tz); - icp->icmp_type = ICMP_ECHO; icp->icmp_code = 0; icp->icmp_cksum = 0; @@@@ -504,12 +505,15 @@@@ #define SIZE_PACK_SENT (sizeof(h->num_packets_sent)) #define SIZE_LAST_TIME (sizeof(h->last_time)) - bcopy(&h->last_time,&buffer[SIZE_ICMP_HDR],SIZE_LAST_TIME); bcopy(&h->num_packets_sent, &buffer[SIZE_ICMP_HDR+SIZE_LAST_TIME], SIZE_PACK_SENT); len = SIZE_ICMP_HDR+SIZE_LAST_TIME+SIZE_PACK_SENT; + /* set the time at the very last possible point */ + gettimeofday(&h->last_time,&tz); + bcopy(&h->last_time,&buffer[SIZE_ICMP_HDR],SIZE_LAST_TIME); + icp->icmp_cksum = in_cksum( (u_short *)icp, len ); n = sendto( s, buffer, len, 0, (struct sockaddr *)&h->saddr, @@@@ -578,10 +582,12 @@@@ return 1; /* packet received, don't about it anymore */ } + /* get time of receipt as close to the real time as possible */ + gettimeofday(¤t_time,&tz); + n=icp->icmp_seq; h=table[n]; - gettimeofday(¤t_time,&tz); bcopy(&icp->icmp_data[0],&sent_time,sizeof(sent_time)); bcopy(&icp->icmp_data[SIZE_LAST_TIME],&the_index, sizeof(the_index)); this_reply = timeval_diff(¤t_time,&sent_time); @@@@ -594,7 +600,7 @@@@ if (dns_flag) printf("%s",get_host_by_address(response_addr.sin_addr)); else printf("%s",h->host); if (verbose_flag) printf(" is alive"); - if (elapsed_flag) printf(" (%d msec)",this_reply); + if (elapsed_flag) printf(" (%.3f msec)",this_reply/1000.0); printf("\n"); } num_alive++; @@@@ -649,7 +655,7 @@@@ u_long ipaddress = inet_addr(host); - if ( (ipaddress == -1) && + if ( (ipaddress == INADDR_NONE) && ( ((host_ent=gethostbyname(host)) == 0) || ((host_add = (struct in_addr *) *(host_ent->h_addr_list))==0)) ) { @@@@ -669,7 +675,7 @@@@ bzero((char*) &p->saddr, sizeof(p->saddr)); p->saddr.sin_family = AF_INET; - if (ipaddress==-1) p->saddr.sin_addr = *host_add; + if (ipaddress==INADDR_NONE) p->saddr.sin_addr = *host_add; else p->saddr.sin_addr.s_addr = ipaddress; if (!rrlist) { @@@@ -756,7 +762,7 @@@@ temp = (((a->tv_sec*1000000)+ a->tv_usec) - - ((b->tv_sec*1000000)+ b->tv_usec))/1000; + ((b->tv_sec*1000000)+ b->tv_usec)); return (long) temp; @ 1.3 log @Updated fping to 1.20nb1 When on an alpha you cannot be lazy and assume -1 matches INADDR_NONE Now mono.org's new alpha can run rconfig... This should make norm happy. @ text @d1 1 a1 1 $NetBSD$ @ 1.2 log @Fix for Linux @ text @d3 1 a3 1 --- fping.c.orig Thu Aug 23 18:10:14 2001 d5 9 d120 18 d147 1 @ 1.1 log @Initial revision @ text @d3 2 a4 2 --- fping.c.orig Mon Sep 20 13:10:23 1999 +++ fping.c Mon Sep 20 13:15:05 1999 d9 1 a9 1 +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) @ 1.1.1.1 log @fping 1.20 - Quickly ping many hosts w/o flooding the network @ text @@