freebsd-ports/net/fping/files/patch-02
2001-04-14 07:55:41 +00:00

114 lines
4.1 KiB
Text

--- fping.c.orig Wed Jan 8 12:29:43 1997
+++ fping.c Sat Apr 14 00:43:43 2001
@@ -208,6 +208,10 @@
#include <arpa/inet.h>
#include <netdb.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
/* RS6000 has sys/select.h */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -219,7 +223,9 @@
extern char *optarg;
extern int optind,opterr;
+#if !(defined(BSD) && (BSD >= 199103))
extern char *sys_errlist[];
+#endif
extern int h_errno;
#ifdef __cplusplus
@@ -321,13 +327,13 @@
struct timeval last_send_time; /* time of last packet sent */
int num_sent; /* number of ping packets sent */
int num_recv; /* number of pings received */
- int max_reply; /* longest response time */
- int min_reply; /* shortest response time */
+ long max_reply; /* longest response time */
+ long min_reply; /* shortest response time */
int total_time; /* sum of response times */
int num_sent_i; /* number of ping packets sent */
int num_recv_i; /* number of pings received */
- int max_reply_i; /* longest response time */
- int min_reply_i; /* shortest response time */
+ long max_reply_i; /* longest response time */
+ long min_reply_i; /* shortest response time */
int total_time_i; /* sum of response times */
int *resp_times; /* individual response times */
#ifdef DEBUG
@@ -475,7 +481,7 @@
/*seteuid(getuid());*/
- prog = argv[0];
+ prog = (prog = strrchr(argv[0], '/')) ? prog + 1 : argv[0];
ident = getpid() & 0xFFFF;
verbose_flag = 1;
@@ -524,8 +530,8 @@
usage(); break;
#endif
case 'v':
- printf("%s: Version %s $Date: 1997/01/08 20:29:33 $\n",argv[0], VERSION);
- printf("%s: comments to fping@networking.Stanford.EDU\n",argv[0]);
+ printf("%s: FreeBSD port based on Version %s $Date: 1997/01/08 20:29:33 $\n",argv[0], VERSION);
+ printf("%s: comments to fping@networking.Stanford.EDU\n",argv[0]);
exit(0);
case 'f':
#ifdef ENABLE_F_OPTION
@@ -671,6 +677,7 @@
}
if (!ping_file) errno_crash_and_burn("fopen");
while(fgets(line,132,ping_file)) {
+ line[132-1] = '\0';
if (sscanf(line,"%s",host) != 1)
continue;
if ((!*host) || (host[0]=='#')) /* magic to avoid comments */
@@ -1033,7 +1040,6 @@
memset(buffer, 0, ping_pkt_size * sizeof(char));
icp = (struct icmp *) buffer;
- gettimeofday(&h->last_send_time,&tz);
icp->icmp_type = ICMP_ECHO;
icp->icmp_code = 0;
icp->icmp_cksum = 0;
@@ -1041,6 +1047,8 @@
icp->icmp_id = ident;
pdp = (PING_DATA *) (buffer + SIZE_ICMP_HDR);
+ /* set the time at the very last possible point */
+ gettimeofday(&h->last_send_time,&tz);
pdp->ping_ts = h->last_send_time;
pdp->ping_count = h->num_sent;
@@ -1099,6 +1107,10 @@
result=recvfrom_wto(s,buffer,4096,
(struct sockaddr *)&response_addr,select_time);
+
+ /* get time of receipt as close to the real time as possible */
+ gettimeofday(&current_time,&tz);
+
if (result<0) { return 0; } /* timeout */
#ifdef DEBUG
@@ -1107,7 +1119,7 @@
return 0;
#endif
ip = (struct ip *) buffer;
-#if defined(__alpha__) && __STDC__
+#if defined(__alpha__) && defined(__osf1__) && __STDC__
/* The alpha headers are decidedly broken.
* Using an ANSI compiler, it provides ip_vhl instead of ip_hl and
* ip_v. So, to get ip_hl, we mask off the bottom four bits.
@@ -1144,7 +1156,6 @@
h=table[n];
/* received ping is cool, so process it */
- gettimeofday(&current_time,&tz);
h->waiting = 0;
h->timeout = timeout;
h->num_recv++; h->num_recv_i++;