Updated iputils PKGBUILD + added new patch
[Archlinux-Stable.git] / base / iputils / iputils.patch
blob4e99b75eeb0490fa12c5a10d96e60f83030e18ef
1 --- iputils/ping_common.c.old Thu Mar 14 16:58:47 2002
2 +++ iputils/ping_common.c Thu Mar 14 17:10:54 2002
3 @@ -775,10 +775,10 @@
4 tmdev = llsqrt(tsum2 - tsum * tsum);
6 printf("rtt min/avg/max/mdev = %ld.%03ld/%lu.%03ld/%ld.%03ld/%ld.%03ld ms",
7 - tmin/1000, tmin%1000,
8 + (long)tmin/1000, (long)tmin%1000,
9 (unsigned long)(tsum/1000), (long)(tsum%1000),
10 - tmax/1000, tmax%1000,
11 - tmdev/1000, tmdev%1000
12 + (long)tmax/1000, (long)tmax%1000,
13 + (long)tmdev/1000, (long)tmdev%1000
16 if (pipesize > 1)
17 @@ -809,10 +809,10 @@
18 tavg = tsum / (nreceived + nrepeats);
20 fprintf(stderr, ", min/avg/ewma/max = %ld.%03ld/%lu.%03ld/%d.%03d/%ld.%03ld ms",
21 - tmin/1000, tmin%1000,
22 + (long)tmin/1000, (long)tmin%1000,
23 tavg/1000, tavg%1000,
24 rtt/8000, (rtt/8)%1000,
25 - tmax/1000, tmax%1000
26 + (long)tmax/1000, (long)tmax%1000
29 fprintf(stderr, "\n");
30 --- iputils/rdisc.c-org Wed May 1 00:27:34 2002
31 +++ iputils/rdisc.c Wed May 1 00:32:40 2002
32 @@ -63,6 +63,8 @@
34 #include "SNAPSHOT.h"
36 +#define RDISC_SERVER
38 struct interface
40 struct in_addr address; /* Used to identify the interface */
41 @@ -163,11 +165,8 @@
42 int debugfile;
44 char usage[] =
45 -"Usage: rdisc [-b] [-d] [-s] [-v] [-f] [-a] [-V] [send_address] [receive_address]\n"
46 -#ifdef RDISC_SERVER
47 -" rdisc -r [-b] [-d] [-s] [-v] [-f] [-a] [-V] [-p <preference>] [-T <secs>] \n"
48 -" [send_address] [receive_address]\n"
49 -#endif
50 +"Usage: rdisc -r [-b] [-d] [-s] [-v] [-f] [-a] [-V] [-p <preference>] [-T <secs>] \n"
51 +" [send_address] [receive_address]\n"
55 @@ -875,7 +874,9 @@
56 ((max_adv_int - min_adv_int)
57 * (random() % 1000)/1000);
58 } else {
59 - if (!is_directly_connected(ip->saddr)) {
60 + struct in_addr tmp;
61 + tmp.s_addr = ip->saddr;
62 + if (!is_directly_connected(tmp)) {
63 if (verbose)
64 logtrace("ICMP %s from %s: source not directly connected\n",
65 pr_type((int)icp->type),
66 @@ -945,7 +946,6 @@
68 #ifdef RDISC_SERVER
69 if (responder) {
70 - int i;
72 /* Send out a packet with a preference so that all
73 * hosts will know that we are dead.
74 --- iputils/ping_common.c.countermeasures Tue May 21 10:06:05 2002
75 +++ iputils/ping_common.c Tue May 21 10:12:42 2002
76 @@ -628,7 +628,8 @@
77 tvsub(tv, &tmp_tv);
78 triptime = tv->tv_sec * 1000000 + tv->tv_usec;
79 if (triptime < 0) {
80 - fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures.\n", triptime);
81 + if (options & F_VERBOSE)
82 + fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures.\n", triptime);
83 triptime = 0;
84 if (!(options & F_LATENCY)) {
85 gettimeofday(tv, NULL);
86 --- iputils/ping.c.addrcache 2002-09-20 17:08:11.000000000 +0200
87 +++ iputils/ping.c 2003-05-15 16:41:19.000000000 +0200
88 @@ -1124,6 +1124,12 @@
90 struct hostent *hp;
91 static char buf[4096];
92 + static __u32 addr_cache = 0;
94 + if ( addr == addr_cache )
95 + return buf;
97 + addr_cache = addr;
99 if ((options & F_NUMERIC) ||
100 !(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
101 --- iputils/ping6.c.addrcache 2002-09-20 17:08:11.000000000 +0200
102 +++ iputils/ping6.c 2003-05-15 16:41:19.000000000 +0200
103 @@ -893,7 +893,14 @@
105 char * pr_addr(struct in6_addr *addr)
107 - struct hostent *hp = NULL;
108 + static struct hostent *hp = NULL;
109 + static struct in6_addr addr_cache = {{{0,0,0,0}}};
111 + if ( addr->s6_addr32[0] == addr_cache.s6_addr32[0] &&
112 + addr->s6_addr32[1] == addr_cache.s6_addr32[1] &&
113 + addr->s6_addr32[2] == addr_cache.s6_addr32[2] &&
114 + addr->s6_addr32[3] == addr_cache.s6_addr32[3] )
115 + return hp ? hp->h_name : pr_addr_n(addr);
117 if (!(options&F_NUMERIC))
118 hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6);
119 --- iputils-ss021109-vanilla/ping.c Thu Nov 7 23:53:21 2002
120 +++ iputils/ping.c Sun Jan 12 03:39:24 2003
121 @@ -285,6 +285,9 @@
122 perror("ping: IP_MULTICAST_IF");
123 exit(2);
125 + } else if (icmp_sock >= 0) {
126 + /* We possible tried to SO_BINDTODEVICE() a subinterface like 'eth0:1' */
127 + perror("Warning: cannot bind to specified iface, falling back");
131 --- iputils/ping.c.icmp_seq 2003-09-03 16:45:07.000000000 +0200
132 +++ iputils/ping.c 2003-09-03 16:45:41.000000000 +0200
133 @@ -610,7 +610,7 @@
134 icp->type = ICMP_ECHO;
135 icp->code = 0;
136 icp->checksum = 0;
137 - icp->un.echo.sequence = htons(ntransmitted+1);
138 + icp->un.echo.sequence = htons(ntransmitted);
139 icp->un.echo.id = ident; /* ID */
141 CLR((ntransmitted+1) % mx_dup_ck);
142 --- iputils/ping6.c.icmp_seq 2003-09-03 16:45:20.000000000 +0200
143 +++ iputils/ping6.c 2003-09-03 16:45:34.000000000 +0200
144 @@ -647,7 +647,7 @@
145 icmph->icmp6_type = ICMPV6_ECHO_REQUEST;
146 icmph->icmp6_code = 0;
147 icmph->icmp6_cksum = 0;
148 - icmph->icmp6_sequence = htons(ntransmitted+1);
149 + icmph->icmp6_sequence = htons(ntransmitted);
150 icmph->icmp6_identifier = ident;
152 CLR((ntransmitted+1) % mx_dup_ck);
153 diff -ru iputils/include-glibc/netinet/in.h iputils-clean/include-glibc/netinet/in.h
154 --- iputils/include-glibc/netinet/in.h 2000-06-18 14:57:25.000000000 -0400
155 +++ iputils-clean/include-glibc/netinet/in.h 2003-09-03 11:21:55.000000000 -0400
156 @@ -8,4 +8,45 @@
158 #define SOL_IP 0
160 -#endif /* netinet/in.h */
161 +/* Functions to convert between host and network byte order.
163 + Please note that these functions normally take `unsigned long int' or
164 + `unsigned short int' values as arguments and also return them. But
165 + this was a short-sighted decision since on different systems the types
166 + may have different representations but the values are always the same. */
168 +extern u_int32_t ntohl (u_int32_t __netlong) __THROW __attribute__ ((__const__));
169 +extern u_int16_t ntohs (u_int16_t __netshort)
170 + __THROW __attribute__ ((__const__));
171 +extern u_int32_t htonl (u_int32_t __hostlong)
172 + __THROW __attribute__ ((__const__));
173 +extern u_int16_t htons (u_int16_t __hostshort)
174 + __THROW __attribute__ ((__const__));
176 +#include <endian.h>
178 +/* Get machine dependent optimized versions of byte swapping functions. */
179 +#include <bits/byteswap.h>
181 +#ifdef __OPTIMIZE__
182 +/* We can optimize calls to the conversion functions. Either nothing has
183 + to be done or we are using directly the byte-swapping functions which
184 + often can be inlined. */
185 +# if __BYTE_ORDER == __BIG_ENDIAN
186 +/* The host byte order is the same as network byte order,
187 + so these functions are all just identity. */
188 +# define ntohl(x) (x)
189 +# define ntohs(x) (x)
190 +# define htonl(x) (x)
191 +# define htons(x) (x)
192 +# else
193 +# if __BYTE_ORDER == __LITTLE_ENDIAN
194 +# define ntohl(x) __bswap_32 (x)
195 +# define ntohs(x) __bswap_16 (x)
196 +# define htonl(x) __bswap_32 (x)
197 +# define htons(x) __bswap_16 (x)
198 +# endif
199 +# endif
200 +#endif
202 +#endif /* netinet/in.h */
203 diff -ru iputils/ping6.c iputils-clean/ping6.c
204 --- iputils/ping6.c 2003-09-03 11:22:46.000000000 -0400
205 +++ iputils-clean/ping6.c 2003-09-03 11:15:42.000000000 -0400
206 @@ -879,7 +879,7 @@
207 once = 1;
209 /* Patch bpflet for current identifier. */
210 - insns[1] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __constant_htons(ident), 0, 1);
211 + insns[1] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(ident), 0, 1);
213 if (setsockopt(icmp_sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
214 perror("WARNING: failed to install socket filter\n");
215 diff -ru iputils/ping.c iputils-clean/ping.c
216 --- iputils/ping.c 2003-09-03 11:22:46.000000000 -0400
217 +++ iputils-clean/ping.c 2003-09-03 11:15:26.000000000 -0400
218 @@ -1196,7 +1196,7 @@
219 once = 1;
221 /* Patch bpflet for current identifier. */
222 - insns[2] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __constant_htons(ident), 0, 1);
223 + insns[2] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(ident), 0, 1);
225 if (setsockopt(icmp_sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
226 perror("WARNING: failed to install socket filter\n");
227 diff -urN iputils/clockdiff.c iputils.new/clockdiff.c
228 --- iputils/clockdiff.c 2002-02-22 19:10:59.000000000 -0500
229 +++ iputils.new/clockdiff.c 2003-09-10 09:20:28.000000000 -0400
230 @@ -2,6 +2,7 @@
231 #include <sys/types.h>
232 #include <sys/param.h>
233 #include <stdio.h>
234 +#include <linux/types.h>
235 #include <unistd.h>
236 #include <stdlib.h>
237 #include <math.h>
238 diff -urN iputils/ping6.c iputils.new/ping6.c
239 --- iputils/ping6.c 2003-09-10 17:27:48.000000000 -0400
240 +++ iputils.new/ping6.c 2003-09-10 17:22:43.000000000 -0400
241 @@ -68,8 +68,44 @@
243 #include "ping_common.h"
245 -#include <linux/in6.h>
246 -#include <linux/ipv6.h>
247 +struct ipv6_rt_hdr {
248 + __u8 nexthdr;
249 + __u8 hdrlen;
250 + __u8 type;
251 + __u8 segments_left;
253 + /*
254 + * type specific data
255 + * variable length field
256 + */
259 +struct rt0_hdr {
260 + struct ipv6_rt_hdr rt_hdr;
261 + __u32 bitmap; /* strict/loose bit map */
262 + struct in6_addr addr[0];
264 +#define rt0_type rt_hdr.type;
266 +#define IPV6_SRCRT_TYPE_0 0 /* IPv6 type 0 Routing Header */
267 +struct ipv6hdr {
268 +#if defined(__LITTLE_ENDIAN)
269 + __u8 priority:4,
270 + version:4;
271 +#elif defined(__BIG_ENDIAN)
272 + __u8 version:4,
273 + priority:4;
274 +#endif
275 + __u8 flow_lbl[3];
277 + __u16 payload_len;
278 + __u8 nexthdr;
279 + __u8 hop_limit;
281 + struct in6_addr saddr;
282 + struct in6_addr daddr;
285 #include <linux/icmpv6.h>
287 #define BIT_CLEAR(nr, addr) do { ((__u32 *)(addr))[(nr) >> 5] &= ~(1U << ((nr) & 31)); } while(0)
288 diff -urN iputils/ping_common.h iputils.new/ping_common.h
289 --- iputils/ping_common.h 2002-09-20 11:08:11.000000000 -0400
290 +++ iputils.new/ping_common.h 2003-09-10 17:16:16.000000000 -0400
291 @@ -19,6 +19,7 @@
293 #include <netinet/in.h>
294 #include <arpa/inet.h>
295 +#include <linux/types.h>
296 #include <linux/errqueue.h>
298 #include "SNAPSHOT.h"
299 diff -urN iputils/tftpd.c iputils.new/tftpd.c
300 --- iputils/tftpd.c 2002-01-23 19:31:41.000000000 -0500
301 +++ iputils.new/tftpd.c 2003-09-10 09:39:45.000000000 -0400
302 @@ -57,7 +57,6 @@
304 #include <sys/socket.h>
305 #include <netinet/in.h>
306 -#include <linux/in6.h>
307 #include <netdb.h>
309 #include <setjmp.h>
310 diff -urN iputils/tracepath6.c iputils.new/tracepath6.c
311 --- iputils/tracepath6.c 2001-09-01 22:03:46.000000000 -0400
312 +++ iputils.new/tracepath6.c 2003-09-10 09:40:18.000000000 -0400
313 @@ -14,8 +14,7 @@
314 #include <unistd.h>
315 #include <sys/socket.h>
316 #include <netinet/in.h>
318 -#include <linux/in6.h>
319 +#include <linux/types.h>
320 #include <linux/errqueue.h>
321 #include <errno.h>
322 #include <string.h>
323 diff -urN iputils/tracepath.c iputils.new/tracepath.c
324 --- iputils/tracepath.c 2002-02-22 19:10:59.000000000 -0500
325 +++ iputils.new/tracepath.c 2003-09-10 06:14:35.000000000 -0400
326 @@ -13,6 +13,7 @@
327 #include <stdlib.h>
328 #include <unistd.h>
329 #include <sys/socket.h>
330 +#include <linux/types.h>
331 #include <linux/errqueue.h>
332 #include <errno.h>
333 #include <string.h>
334 diff -urN iputils/traceroute6.c iputils.new/traceroute6.c
335 --- iputils/traceroute6.c 2002-09-20 11:44:22.000000000 -0400
336 +++ iputils.new/traceroute6.c 2003-09-10 10:12:47.000000000 -0400
337 @@ -246,9 +246,24 @@
338 #include <netinet/ip_icmp.h>
339 #include <netinet/udp.h>
341 -#include <linux/ipv6.h>
342 -#include <linux/in6.h>
343 +#include <linux/types.h>
344 +struct ipv6hdr {
345 +#if defined(__LITTLE_ENDIAN)
346 + __u8 priority:4,
347 + version:4;
348 +#elif defined(__BIG_ENDIAN)
349 + __u8 version:4,
350 + priority:4;
351 +#endif
352 + __u8 flow_lbl[3];
354 + __u16 payload_len;
355 + __u8 nexthdr;
356 + __u8 hop_limit;
358 + struct in6_addr saddr;
359 + struct in6_addr daddr;
361 #include <linux/icmpv6.h>
363 #include <arpa/inet.h>
364 --- iputils/arping.c.unaligned 2001-10-06 00:42:47.000000000 +0200
365 +++ iputils/arping.c 2003-10-02 15:14:42.000000000 +0200
366 @@ -332,7 +332,7 @@
367 timeout = atoi(optarg);
368 break;
369 case 'I':
370 - device = optarg;
371 + device = strdup(optarg);
372 break;
373 case 'f':
374 quit_on_reply=1;
375 --- iputils/traceroute6.c.inet_pton 2004-04-22 15:06:28.268797480 +0200
376 +++ iputils/traceroute6.c 2004-04-22 15:06:35.727877941 +0200
377 @@ -538,7 +538,7 @@
378 } else {
379 (void) bzero((char *)&saddr, sizeof(saddr));
380 saddr.sin6_family = AF_INET6;
381 - if (inet_pton(AF_INET6, source, &saddr.sin6_addr) < 0)
382 + if (inet_pton(AF_INET6, source, &saddr.sin6_addr) <= 0)
384 Printf("traceroute: unknown addr %s\n", source);
385 exit(1);
386 --- iputils/traceroute6.c.old 2004-12-07 11:08:57.000000000 +0100
387 +++ iputils/traceroute6.c 2004-12-07 11:14:09.397575536 +0100
388 @@ -352,8 +352,11 @@
389 icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
390 socket_errno = errno;
392 - setuid(getuid());
394 + if(setuid(getuid()) != 0)
396 + perror("traceroute: setuid()");
397 + exit(-1);
399 on = 1;
400 seq = tos = 0;
401 to = (struct sockaddr_in6 *)&whereto;
402 --- iputils/ping6.c.old 2004-12-07 11:08:57.000000000 +0100
403 +++ iputils/ping6.c 2004-12-07 11:13:40.707937024 +0100
404 @@ -223,7 +223,11 @@
405 socket_errno = errno;
407 uid = getuid();
408 - setuid(uid);
409 + if(setuid(uid) != 0)
411 + perror("ping: setuid()");
412 + exit(-1);
415 source.sin6_family = AF_INET6;
416 memset(&firsthop, 0, sizeof(firsthop));
417 --- iputils/ping.c.old 2004-12-07 11:08:57.000000000 +0100
418 +++ iputils/ping.c 2004-12-07 11:13:27.523941296 +0100
419 @@ -119,7 +119,11 @@
420 socket_errno = errno;
422 uid = getuid();
423 - setuid(uid);
424 + if(setuid(uid) != 0)
426 + perror("ping: setuid()");
427 + exit(-1);
430 source.sin_family = AF_INET;
432 --- iputils/doc/ping.8.old 2002-09-27 19:12:47.000000000 +0200
433 +++ iputils/doc/ping.8 2004-12-07 11:09:42.434160144 +0100
434 @@ -112,7 +112,7 @@
435 when finished.
437 \fB-R\fR
438 -Record route.
439 +Record route. (IPv4 only)
440 Includes the RECORD_ROUTE option in the ECHO_REQUEST
441 packet and displays the route buffer on returned packets.
442 Note that the IP header is only large enough for nine such routes.
443 --- iputils/doc/ping.sgml.old 2002-09-20 14:55:50.000000000 +0200
444 +++ iputils/doc/ping.sgml 2004-12-07 11:09:42.435159992 +0100
445 @@ -190,7 +190,7 @@
446 <varlistentry>
447 <term><option/-R/</term>
448 <listitem><para>
449 -Record route.
450 +Record route. (IPv4 only)
451 Includes the RECORD_ROUTE option in the ECHO_REQUEST
452 packet and displays the route buffer on returned packets.
453 Note that the IP header is only large enough for nine such routes.
454 --- iputils/ping.c 2005-05-18 01:37:05.621810488 -0400
455 +++ iputils/ping.c.new 2005-05-18 01:41:27.113018222 -0400
456 @@ -101,7 +101,7 @@ static struct {
457 int cmsg_len;
459 struct sockaddr_in source;
460 -char *device;
461 +char *device=NULL;
462 int pmtudisc = -1;
465 @@ -177,7 +177,7 @@ main(int argc, char **argv)
466 ptr[3] = i4;
467 options |= F_STRICTSOURCE;
468 } else {
469 - device = optarg;
470 + device = strdup(optarg);
472 break;
474 --- iputils/ping6.c 2005-05-18 01:37:05.620833925 -0400
475 +++ iputils/ping6.c.new 2005-05-18 01:41:23.599346390 -0400
476 @@ -155,7 +155,7 @@ static int pr_icmph(__u8 type, __u8 code
477 static void usage(void) __attribute((noreturn));
479 struct sockaddr_in6 source;
480 -char *device;
481 +char *device=NULL;
482 int pmtudisc=-1;
484 static int icmp_sock;
485 @@ -248,7 +248,7 @@ int main(int argc, char *argv[])
487 options |= F_STRICTSOURCE;
488 } else {
489 - device = optarg;
490 + device = strdup(optarg);
492 break;
493 case 'M':
494 diff -ur iputils/arping.c iputils.tom/arping.c
495 --- iputils/arping.c 2005-07-15 13:51:15.533632784 -0700
496 +++ iputils.tom/arping.c 2005-07-15 13:50:47.967823000 -0700
497 @@ -59,6 +59,8 @@
498 #define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \
499 ((tv1).tv_usec-(tv2).tv_usec)/1000 )
501 +#define min(x,y) ((x)<(y) ? (x) : (y))
503 void usage(void)
505 fprintf(stderr,
506 @@ -476,7 +478,7 @@
509 he = me;
510 - memset(he.sll_addr, -1, he.sll_halen);
511 + memset(he.sll_addr, -1, min(he.sll_halen, sizeof he.sll_addr));
513 if (!quiet) {
514 printf("ARPING %s ", inet_ntoa(dst));
515 --- iputils/arping.c.orig 2001-10-05 18:42:47.000000000 -0400
516 +++ iputils/arping.c 2005-07-13 13:07:45.406217716 -0400
517 @@ -166,10 +166,12 @@ void catcher(void)
518 if (start.tv_sec==0)
519 start = tv;
521 - if (count-- == 0 || (timeout && MS_TDIFF(tv,start) > timeout*1000 + 500))
522 + if ((timeout && MS_TDIFF(tv,start) > timeout*1000 + 500) ||
523 + ((count == 0) && (!timeout)))
524 finish();
526 if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
527 + count--;
528 send_pack(s, src, dst, &me, &he);
529 if (count == 0 && unsolicited)
530 finish();
531 @@ -510,6 +512,8 @@ main(int argc, char **argv)
532 sigaddset(&sset, SIGINT);
533 sigprocmask(SIG_BLOCK, &sset, &osset);
534 recv_pack(packet, cc, &from);
535 + if(received == count)
536 + exit(0);
537 sigprocmask(SIG_SETMASK, &osset, NULL);
540 --- iputils/tracepath6.c.getaddrinfo 2005-09-08 10:31:47.000000000 +0200
541 +++ iputils/tracepath6.c 2005-09-08 10:31:47.000000000 +0200
542 @@ -280,7 +280,7 @@
543 struct sockaddr_in6 sin;
544 int ttl;
545 char *p;
546 - struct hostent *he;
547 + struct addrinfo hints, *res;
548 int ch;
550 while ((ch = getopt(argc, argv, "nbh?")) != EOF) {
551 @@ -308,20 +308,26 @@
552 perror("socket");
553 exit(1);
555 - sin.sin6_family = AF_INET6;
557 p = strchr(argv[0], '/');
558 if (p) {
559 *p = 0;
562 + memset(&hints, '\0', sizeof(hints));
563 + hints.ai_family = AF_INET6;
564 + if (getaddrinfo(argv[0], NULL, &hints, &res)) {
565 + herror("getaddrinfo");
566 + exit(1);
569 + memcpy(&sin, res->ai_addr, sizeof(struct sockaddr_in6));
570 + freeaddrinfo(res);
572 + if (p) {
573 sin.sin6_port = htons(atoi(p+1));
574 } else
575 sin.sin6_port = htons(0x8000 | getpid());
576 - he = gethostbyname2(argv[0], AF_INET6);
577 - if (he == NULL) {
578 - herror("gethostbyname2");
579 - exit(1);
581 - memcpy(&sin.sin6_addr, he->h_addr, 16);
583 if (connect(fd, (struct sockaddr*)&sin, sizeof(sin)) < 0) {
584 perror("connect");
585 --- iputils/tracepath.c.getaddrinfo 2005-09-08 10:31:47.000000000 +0200
586 +++ iputils/tracepath.c 2005-09-08 11:03:39.000000000 +0200
587 @@ -272,12 +272,12 @@
589 main(int argc, char **argv)
591 - struct hostent *he;
592 int fd;
593 int on;
594 int ttl;
595 char *p;
596 int ch;
597 + struct addrinfo hints, *res;
599 while ((ch = getopt(argc, argv, "nh?")) != EOF) {
600 switch(ch) {
601 @@ -300,20 +300,26 @@
602 perror("socket");
603 exit(1);
605 - target.sin_family = AF_INET;
607 p = strchr(argv[0], '/');
608 if (p) {
609 *p = 0;
612 + memset(&hints, '\0', sizeof(hints));
613 + hints.ai_family = AF_INET;
614 + if (getaddrinfo(argv[0], NULL, &hints, &res)) {
615 + herror("getaddrinfo");
616 + exit(1);
619 + memcpy(&target, res->ai_addr, sizeof(struct sockaddr_in));
620 + freeaddrinfo(res);
622 + if (p)
623 base_port = atoi(p+1);
624 - } else
625 + else
626 base_port = 44444;
627 - he = gethostbyname(argv[0]);
628 - if (he == NULL) {
629 - herror("gethostbyname");
630 - exit(1);
632 - memcpy(&target.sin_addr, he->h_addr, 4);
634 on = IP_PMTUDISC_DO;
635 if (setsockopt(fd, SOL_IP, IP_MTU_DISCOVER, &on, sizeof(on))) {
636 --- iputils/ping.c.flood 2005-09-26 09:26:49.000000000 +0200
637 +++ iputils/ping.c 2005-09-26 13:07:39.000000000 +0200
638 @@ -614,7 +608,7 @@
639 icp->type = ICMP_ECHO;
640 icp->code = 0;
641 icp->checksum = 0;
642 - icp->un.echo.sequence = htons(ntransmitted);
643 + icp->un.echo.sequence = htons(ntransmitted+1);
644 icp->un.echo.id = ident; /* ID */
646 CLR((ntransmitted+1) % mx_dup_ck);
647 diff -ru iputils/ping_common.c iputils-foo/ping_common.c
648 --- iputils/ping_common.c 2005-09-22 15:22:57.000000000 -0400
649 +++ iputils-foo/ping_common.c 2005-09-22 15:24:42.000000000 -0400
650 @@ -584,6 +584,7 @@
651 * destined to other running pings. */
653 iov.iov_len = packlen;
654 + memset(&msg,'\0',sizeof(msg));
655 msg.msg_name = addrbuf;
656 msg.msg_namelen = sizeof(addrbuf);
657 msg.msg_iov = &iov;
658 --- iputils/tracepath6.c.hoplimit 2005-12-13 13:32:56.000000000 +0100
659 +++ iputils/tracepath6.c 2005-12-13 13:35:01.000000000 +0100
660 @@ -359,8 +359,8 @@
661 perror("IP_RECVERR");
662 exit(1);
664 - if (setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &on, sizeof(on))) {
665 - perror("IPV6_HOPLIMIT");
666 + if (setsockopt(fd, SOL_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on))) {
667 + perror("IPV6_RECVHOPLIMIT");
668 exit(1);
670 if (mapped && setsockopt(fd, SOL_IP, IP_RECVTTL, &on, sizeof(on))) {
671 --- iputils/ping6.c.hoplimit 2005-12-13 13:32:56.000000000 +0100
672 +++ iputils/ping6.c 2005-12-13 13:34:04.000000000 +0100
673 @@ -521,13 +521,10 @@
677 - if (1) {
678 - int on = 1;
679 - if (setsockopt(icmp_sock, IPPROTO_IPV6, IPV6_HOPLIMIT,
680 - &on, sizeof(on)) == -1) {
681 - perror ("can't receive hop limit");
682 - exit(2);
684 + int on = 1;
685 + if (setsockopt(icmp_sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on))) {
686 + perror("setsockopt(IPV6_RECVHOPLIMIT)");
687 + exit(2);
690 if (options&F_FLOWINFO) {
691 --- iputils/ping6.c.gcc41 2006-01-25 16:21:47.000000000 +0100
692 +++ iputils/ping6.c 2006-01-25 16:21:47.000000000 +0100
693 @@ -383,7 +383,7 @@
694 exit(2);
696 alen = sizeof(source);
697 - if (getsockname(probe_fd, (struct sockaddr*)&source, &alen) == -1) {
698 + if (getsockname(probe_fd, (struct sockaddr*)&source, (socklen_t*)&alen) == -1) {
699 perror("getsockname");
700 exit(2);
702 @@ -599,6 +599,7 @@
703 int net_errors = 0;
704 int local_errors = 0;
705 int saved_errno = errno;
706 + ssize_t wr_ret;
708 iov.iov_base = &icmph;
709 iov.iov_len = sizeof(icmph);
710 @@ -629,7 +630,7 @@
711 if (options & F_QUIET)
712 goto out;
713 if (options & F_FLOOD)
714 - write(STDOUT_FILENO, "E", 1);
715 + wr_ret = write(STDOUT_FILENO, "E", 1);
716 else if (e->ee_errno != EMSGSIZE)
717 fprintf(stderr, "ping: local error: %s\n", strerror(e->ee_errno));
718 else
719 @@ -652,7 +653,7 @@
720 if (options & F_QUIET)
721 goto out;
722 if (options & F_FLOOD) {
723 - write(STDOUT_FILENO, "\bE", 2);
724 + wr_ret = write(STDOUT_FILENO, "\bE", 2);
725 } else {
726 printf("From %s icmp_seq=%u ", pr_addr(&sin6->sin6_addr), ntohs(icmph.icmp6_sequence));
727 pr_icmph(e->ee_type, e->ee_code, e->ee_info);
728 @@ -795,7 +796,8 @@
729 return 0;
730 nerrors++;
731 if (options & F_FLOOD) {
732 - write(STDOUT_FILENO, "\bE", 2);
733 + ssize_t wr_ret;
734 + wr_ret = write(STDOUT_FILENO, "\bE", 2);
735 return 0;
737 printf("From %s: icmp_seq=%u ", pr_addr(&from->sin6_addr), ntohs(icmph1->icmp6_sequence));
738 --- iputils/arping.c.gcc41 2006-01-25 16:21:47.000000000 +0100
739 +++ iputils/arping.c 2006-01-25 16:21:47.000000000 +0100
740 @@ -449,7 +449,7 @@
741 perror("connect");
742 exit(2);
744 - if (getsockname(probe_fd, (struct sockaddr*)&saddr, &alen) == -1) {
745 + if (getsockname(probe_fd, (struct sockaddr*)&saddr, (socklen_t*)&alen) == -1) {
746 perror("getsockname");
747 exit(2);
749 @@ -468,7 +468,7 @@
751 if (1) {
752 int alen = sizeof(me);
753 - if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) {
754 + if (getsockname(s, (struct sockaddr*)&me, (socklen_t*)&alen) == -1) {
755 perror("getsockname");
756 exit(2);
758 @@ -499,13 +499,13 @@
760 while(1) {
761 sigset_t sset, osset;
762 - char packet[4096];
763 + unsigned char packet[4096];
764 struct sockaddr_ll from;
765 int alen = sizeof(from);
766 int cc;
768 if ((cc = recvfrom(s, packet, sizeof(packet), 0,
769 - (struct sockaddr *)&from, &alen)) < 0) {
770 + (struct sockaddr *)&from, (socklen_t*)&alen)) < 0) {
771 perror("arping: recvfrom");
772 continue;
774 --- iputils/traceroute6.c.gcc41 2006-01-25 16:21:47.000000000 +0100
775 +++ iputils/traceroute6.c 2006-01-25 16:21:47.000000000 +0100
776 @@ -529,7 +529,7 @@
777 exit(1);
779 alen = sizeof(saddr);
780 - if (getsockname(probe_fd, (struct sockaddr*)&saddr, &alen) == -1) {
781 + if (getsockname(probe_fd, (struct sockaddr*)&saddr, (socklen_t*)&alen) == -1) {
782 perror("getsockname");
783 exit(1);
785 @@ -656,7 +656,7 @@
787 if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) {
788 cc=recvfrom(icmp_sock, (char *)packet, sizeof(packet), 0,
789 - (struct sockaddr *)from, &fromlen);
790 + (struct sockaddr *)from, (socklen_t*)&fromlen);
793 return(cc);
794 --- iputils/tftpd.c.gcc41 2006-01-25 16:21:47.000000000 +0100
795 +++ iputils/tftpd.c 2006-01-25 16:21:47.000000000 +0100
796 @@ -126,7 +126,7 @@
798 fromlen = sizeof (from);
799 n = recvfrom(0, buf, sizeof (buf), 0,
800 - (struct sockaddr *)&from, &fromlen);
801 + (struct sockaddr *)&from, (socklen_t*)&fromlen);
802 if (n < 0) {
803 if (errno != EAGAIN)
804 syslog(LOG_ERR, "recvfrom: %m\n");
805 @@ -164,9 +164,9 @@
806 * than one tftpd being started up to service
807 * a single request from a single client.
809 - j = sizeof from;
810 + j = sizeof (from);
811 i = recvfrom(0, buf, sizeof (buf), 0,
812 - (struct sockaddr *)&from, &j);
813 + (struct sockaddr *)&from, (socklen_t*)&j);
814 if (i > 0) {
815 n = i;
816 fromlen = j;
817 --- iputils/clockdiff.c.gcc41 2006-01-25 16:21:47.000000000 +0100
818 +++ iputils/clockdiff.c 2006-01-25 16:21:47.000000000 +0100
819 @@ -148,7 +148,7 @@
820 if (select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout)) {
821 length = sizeof(struct sockaddr_in);
822 cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0,
823 - (struct sockaddr *)NULL, &length);
824 + (struct sockaddr *)NULL, (socklen_t*)&length);
825 if (cc < 0)
826 return -1;
827 goto empty;
828 @@ -214,7 +214,7 @@
830 (void)gettimeofday(&tv1, (struct timezone *)0);
831 cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0,
832 - (struct sockaddr *)NULL, &length);
833 + (struct sockaddr *)NULL, (socklen_t*)&length);
835 if (cc < 0)
836 return(-1);
837 @@ -326,7 +326,7 @@
838 if (select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout)) {
839 length = sizeof(struct sockaddr_in);
840 cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0,
841 - (struct sockaddr *)NULL, &length);
842 + (struct sockaddr *)NULL, (socklen_t*)&length);
843 if (cc < 0)
844 return -1;
845 goto empty;
846 @@ -396,7 +396,7 @@
848 (void)gettimeofday(&tv1, (struct timezone *)0);
849 cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0,
850 - (struct sockaddr *)NULL, &length);
851 + (struct sockaddr *)NULL, (socklen_t*)&length);
853 if (cc < 0)
854 return(-1);
855 @@ -539,6 +539,7 @@
856 struct hostent * hp;
857 char hostname[MAXHOSTNAMELEN];
858 int s_errno = 0;
859 + int nice_ret;
861 if (argc < 2) {
862 setuid(getuid());
863 @@ -606,7 +607,7 @@
864 rspace[1] = ip_opt_len;
865 rspace[2] = 5;
866 rspace[3] = IPOPT_TS_PRESPEC;
867 - if (getsockname(sock_raw, (struct sockaddr*)&myaddr, &addrlen) == -1) {
868 + if (getsockname(sock_raw, (struct sockaddr*)&myaddr, (socklen_t*)&addrlen) == -1) {
869 perror("getsockname");
870 exit(1);
872 @@ -623,8 +624,13 @@
873 ip_opt_len = 0;
877 - nice(-16);
878 + nice_ret = nice(-16);
879 + if (nice_ret < 0) {
880 + if (errno)
881 + perror("nice");
882 + else
883 + fprintf(stderr, "nice: unknown failure\n");
886 if ((measure_status = (ip_opt_len ? measure_opt : measure)(&server)) < 0) {
887 if (errno)
888 --- iputils/rdisc.c.gcc41 2006-01-25 16:21:47.000000000 +0100
889 +++ iputils/rdisc.c 2006-01-25 16:21:47.000000000 +0100
890 @@ -454,7 +454,7 @@
891 int cc;
893 cc=recvfrom(s, (char *)packet, len, 0,
894 - (struct sockaddr *)&from, &fromlen);
895 + (struct sockaddr *)&from, (socklen_t*)&fromlen);
896 if (cc<0) {
897 if (errno == EINTR)
898 continue;
899 --- iputils/rarpd.c.gcc41 2001-12-02 19:45:06.000000000 +0100
900 +++ iputils/rarpd.c 2006-01-25 16:21:47.000000000 +0100
901 @@ -154,8 +154,8 @@
902 ifl->index = index;
903 ifl->hatype = ifrp->ifr_hwaddr.sa_family;
904 memcpy(ifl->lladdr, ifrp->ifr_hwaddr.sa_data, 14);
905 - strncpy(ifl->name, ifrp->ifr_name, IFNAMSIZ);
906 - p = strchr(ifl->name, ':');
907 + strncpy((char*)ifl->name, ifrp->ifr_name, IFNAMSIZ);
908 + p = strchr((char*)ifl->name, ':');
909 if (p)
910 *p = 0;
911 if (verbose)
912 @@ -423,7 +423,7 @@
913 unsigned char *ptr;
914 int n;
916 - n = recvfrom(fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sll, &sll_len);
917 + n = recvfrom(fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sll, (socklen_t*)&sll_len);
918 if (n<0) {
919 if (errno != EINTR && errno != EAGAIN)
920 syslog(LOG_ERR, "recvfrom: %m");
921 @@ -531,7 +531,7 @@
922 /* Update our ARP cache. Probably, this guy
923 will not able to make ARP (if it is broken)
925 - arp_advise(sll.sll_ifindex, rmap->lladdr, rmap->lladdr_len, rmap->ipaddr);
926 + arp_advise(sll.sll_ifindex,(unsigned char *)rmap->lladdr, rmap->lladdr_len, rmap->ipaddr);
928 /* Sendto is blocking, but with 5sec timeout */
929 alarm(5);
930 @@ -673,8 +673,15 @@
931 perror("rarpd: fork");
932 exit(1);
934 + int chdir_ret = chdir("/");
935 + if (chdir_ret != 0) {
936 + if (errno)
937 + perror("chdir");
938 + else
939 + fprintf(stderr, "chdir: Uknown error\n");
942 - chdir("/");
944 fd = open("/dev/null", O_RDWR);
945 if (fd >= 0) {
946 dup2(fd, 0);
947 --- iputils/ping_common.c.gcc41 2006-01-25 16:21:47.000000000 +0100
948 +++ iputils/ping_common.c 2006-01-25 16:21:47.000000000 +0100
949 @@ -284,6 +284,7 @@
950 static int oom_count;
951 static int tokens;
952 int i;
953 + ssize_t wr_ret;
955 /* Have we already sent enough? If we have, return an arbitrary positive value. */
956 if (exiting || (npackets && ntransmitted >= npackets && !deadline))
957 @@ -327,7 +328,7 @@
958 * high preload or pipe size is very confusing. */
959 if ((preload < screen_width && pipesize < screen_width) ||
960 in_flight() < screen_width)
961 - write(STDOUT_FILENO, ".", 1);
962 + wr_ret = write(STDOUT_FILENO, ".", 1);
964 return interval - tokens;
966 @@ -380,7 +381,7 @@
968 if (i == 0 && !(options & F_QUIET)) {
969 if (options & F_FLOOD)
970 - write(STDOUT_FILENO, "E", 1);
971 + wr_ret = write(STDOUT_FILENO, "E", 1);
972 else
973 perror("ping: sendmsg");
975 @@ -402,8 +403,8 @@
976 rcvbuf = hold = alloc * preload;
977 if (hold < 65536)
978 hold = 65536;
979 - setsockopt(icmp_sock, SOL_SOCKET, SO_RCVBUF, (char *)&hold, sizeof(hold));
980 - if (getsockopt(icmp_sock, SOL_SOCKET, SO_RCVBUF, (char *)&hold, &tmplen) == 0) {
981 + setsockopt(icmp_sock, SOL_SOCKET, SO_RCVBUF, (char *)&hold, (socklen_t)sizeof(hold));
982 + if (getsockopt(icmp_sock, SOL_SOCKET, SO_RCVBUF, (char *)&hold, (socklen_t*)&tmplen) == 0) {
983 if (hold < rcvbuf)
984 fprintf(stderr, "WARNING: probably, rcvbuf is not enough to hold preload.\n");
986 @@ -650,7 +651,8 @@
988 int dupflag = 0;
989 long triptime = 0;
991 + ssize_t wr_ret;
993 ++nreceived;
994 if (!csfailed)
995 acknowledge(seq);
996 @@ -706,9 +708,9 @@
998 if (options & F_FLOOD) {
999 if (!csfailed)
1000 - write(STDOUT_FILENO, "\b \b", 3);
1001 + wr_ret = write(STDOUT_FILENO, "\b \b", 3);
1002 else
1003 - write(STDOUT_FILENO, "\bC", 1);
1004 + wr_ret = write(STDOUT_FILENO, "\bC", 1);
1005 } else {
1006 int i;
1007 __u8 *cp, *dp;
1008 --- iputils/ping.c.gcc41 2006-01-25 16:21:47.000000000 +0100
1009 +++ iputils/ping.c 2006-01-25 16:21:47.000000000 +0100
1010 @@ -314,7 +314,7 @@
1013 alen = sizeof(source);
1014 - if (getsockname(probe_fd, (struct sockaddr*)&source, &alen) == -1) {
1015 + if (getsockname(probe_fd, (struct sockaddr*)&source, (socklen_t*)&alen) == -1) {
1016 perror("getsockname");
1017 exit(2);
1019 @@ -517,6 +517,7 @@
1020 int net_errors = 0;
1021 int local_errors = 0;
1022 int saved_errno = errno;
1023 + ssize_t wr_ret;
1025 iov.iov_base = &icmph;
1026 iov.iov_len = sizeof(icmph);
1027 @@ -547,7 +548,7 @@
1028 if (options & F_QUIET)
1029 goto out;
1030 if (options & F_FLOOD)
1031 - write(STDOUT_FILENO, "E", 1);
1032 + wr_ret = write(STDOUT_FILENO, "E", 1);
1033 else if (e->ee_errno != EMSGSIZE)
1034 fprintf(stderr, "ping: local error: %s\n", strerror(e->ee_errno));
1035 else
1036 @@ -583,7 +584,7 @@
1037 if (options & F_QUIET)
1038 goto out;
1039 if (options & F_FLOOD) {
1040 - write(STDOUT_FILENO, "\bE", 2);
1041 + wr_ret = write(STDOUT_FILENO, "\bE", 2);
1042 } else {
1043 printf("From %s icmp_seq=%u ", pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
1044 pr_icmph(e->ee_type, e->ee_code, e->ee_info, NULL);
1045 @@ -677,6 +678,7 @@
1046 struct iphdr *ip;
1047 int hlen;
1048 int csfailed;
1049 + ssize_t wr_ret;
1051 /* Check the IP header */
1052 ip = (struct iphdr *)buf;
1053 @@ -748,7 +750,7 @@
1054 return !error_pkt;
1055 if (options & F_FLOOD) {
1056 if (error_pkt)
1057 - write(STDOUT_FILENO, "\bE", 2);
1058 + wr_ret = write(STDOUT_FILENO, "\bE", 2);
1059 return !error_pkt;
1061 printf("From %s: icmp_seq=%u ",
1062 @@ -765,9 +767,9 @@
1064 if ((options & F_FLOOD) && !(options & (F_VERBOSE|F_QUIET))) {
1065 if (!csfailed)
1066 - write(STDOUT_FILENO, "!E", 2);
1067 + wr_ret = write(STDOUT_FILENO, "!E", 2);
1068 else
1069 - write(STDOUT_FILENO, "!EC", 3);
1070 + wr_ret = write(STDOUT_FILENO, "!EC", 3);
1071 return 0;
1073 if (!(options & F_VERBOSE) || uid)
1074 --- iputils/ping6.c.OLD 2006-02-06 10:34:35.000000000 +0100
1075 +++ iputils/ping6.c 2006-02-06 10:35:38.000000000 +0100
1076 @@ -353,7 +353,7 @@
1077 hostname = target;
1079 if (ipv6_addr_any(&source.sin6_addr)) {
1080 - int alen;
1081 + socklen_t alen;
1082 int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0);
1084 if (probe_fd < 0) {
1085 --- iputils/ping.c.OLD 2006-02-06 10:34:35.000000000 +0100
1086 +++ iputils/ping.c 2006-02-06 10:34:35.000000000 +0100
1087 @@ -253,7 +253,7 @@
1090 if (source.sin_addr.s_addr == 0) {
1091 - int alen;
1092 + socklen_t alen;
1093 struct sockaddr_in dst = whereto;
1094 int probe_fd = socket(AF_INET, SOCK_DGRAM, 0);
1096 @@ -855,9 +855,36 @@
1097 case ICMP_SR_FAILED:
1098 printf("Source Route Failed\n");
1099 break;
1100 + case ICMP_NET_UNKNOWN:
1101 + printf("Destination Net Unknown\n");
1102 + break;
1103 + case ICMP_HOST_UNKNOWN:
1104 + printf("Destination Host Unknown\n");
1105 + break;
1106 + case ICMP_HOST_ISOLATED:
1107 + printf("Source Host Isolated\n");
1108 + break;
1109 + case ICMP_NET_ANO:
1110 + printf("Destination Net Prohibited\n");
1111 + break;
1112 + case ICMP_HOST_ANO:
1113 + printf("Destination Host Prohibited\n");
1114 + break;
1115 + case ICMP_NET_UNR_TOS:
1116 + printf("Destination Net Unreachable for Type of Service\n");
1117 + break;
1118 + case ICMP_HOST_UNR_TOS:
1119 + printf("Destination Host Unreachable for Type of Service\n");
1120 + break;
1121 case ICMP_PKT_FILTERED:
1122 printf("Packet filtered\n");
1123 break;
1124 + case ICMP_PREC_VIOLATION:
1125 + printf("Precedence Violation\n");
1126 + break;
1127 + case ICMP_PREC_CUTOFF:
1128 + printf("Precedence Cutoff\n");
1129 + break;
1130 default:
1131 printf("Dest Unreachable, Bad Code: %d\n", code);
1132 break;
1133 --- iputils/ping_common.c.OLD 2006-02-06 10:34:35.000000000 +0100
1134 +++ iputils/ping_common.c 2006-02-06 10:34:35.000000000 +0100
1135 @@ -67,7 +67,7 @@
1136 int ii, jj, kk;
1137 int pat[16];
1138 char *cp;
1139 - char *bp = outpack+8;
1140 + unsigned char *bp = outpack+8;
1142 for (cp = patp; *cp; cp++) {
1143 if (!isxdigit(*cp)) {
1144 @@ -393,7 +393,7 @@
1145 void sock_setbufs(int icmp_sock, int alloc)
1147 int rcvbuf, hold;
1148 - int tmplen = sizeof(hold);
1149 + socklen_t tmplen = sizeof(hold);
1151 if (!sndbuf)
1152 sndbuf = alloc;
1153 @@ -464,7 +464,7 @@
1155 if (!(options & F_PINGFILLED)) {
1156 int i;
1157 - char *p = outpack+8;
1158 + unsigned char *p = outpack+8;
1160 /* Do not forget about case of small datalen,
1161 * fill timestamp area too!
1162 @@ -819,7 +819,7 @@
1164 if (pipesize > 1)
1165 printf(", pipe %d", pipesize);
1166 - if (ntransmitted > 1 && (!interval || (options&(F_FLOOD|F_ADAPTIVE)))) {
1167 + if (ntransmitted > 1 && nreceived && (!interval || (options&(F_FLOOD|F_ADAPTIVE)))) {
1168 int ipg = (1000000*(long long)tv.tv_sec+tv.tv_usec)/(ntransmitted-1);
1169 printf(", ipg/ewma %d.%03d/%d.%03d ms",
1170 ipg/1000, ipg%1000, rtt/8000, (rtt/8)%1000);