--- iputils/ping_common.c.old Thu Mar 14 16:58:47 2002 +++ iputils/ping_common.c Thu Mar 14 17:10:54 2002 @@ -775,10 +775,10 @@ tmdev = llsqrt(tsum2 - tsum * tsum); printf("rtt min/avg/max/mdev = %ld.%03ld/%lu.%03ld/%ld.%03ld/%ld.%03ld ms", - tmin/1000, tmin%1000, + (long)tmin/1000, (long)tmin%1000, (unsigned long)(tsum/1000), (long)(tsum%1000), - tmax/1000, tmax%1000, - tmdev/1000, tmdev%1000 + (long)tmax/1000, (long)tmax%1000, + (long)tmdev/1000, (long)tmdev%1000 ); } if (pipesize > 1) @@ -809,10 +809,10 @@ tavg = tsum / (nreceived + nrepeats); fprintf(stderr, ", min/avg/ewma/max = %ld.%03ld/%lu.%03ld/%d.%03d/%ld.%03ld ms", - tmin/1000, tmin%1000, + (long)tmin/1000, (long)tmin%1000, tavg/1000, tavg%1000, rtt/8000, (rtt/8)%1000, - tmax/1000, tmax%1000 + (long)tmax/1000, (long)tmax%1000 ); } fprintf(stderr, "\n"); --- iputils/rdisc.c-org Wed May 1 00:27:34 2002 +++ iputils/rdisc.c Wed May 1 00:32:40 2002 @@ -63,6 +63,8 @@ #include "SNAPSHOT.h" +#define RDISC_SERVER + struct interface { struct in_addr address; /* Used to identify the interface */ @@ -163,11 +165,8 @@ int debugfile; char usage[] = -"Usage: rdisc [-b] [-d] [-s] [-v] [-f] [-a] [-V] [send_address] [receive_address]\n" -#ifdef RDISC_SERVER -" rdisc -r [-b] [-d] [-s] [-v] [-f] [-a] [-V] [-p ] [-T ] \n" -" [send_address] [receive_address]\n" -#endif +"Usage: rdisc -r [-b] [-d] [-s] [-v] [-f] [-a] [-V] [-p ] [-T ] \n" +" [send_address] [receive_address]\n" ; @@ -875,7 +874,9 @@ ((max_adv_int - min_adv_int) * (random() % 1000)/1000); } else { - if (!is_directly_connected(ip->saddr)) { + struct in_addr tmp; + tmp.s_addr = ip->saddr; + if (!is_directly_connected(tmp)) { if (verbose) logtrace("ICMP %s from %s: source not directly connected\n", pr_type((int)icp->type), @@ -945,7 +946,6 @@ { #ifdef RDISC_SERVER if (responder) { - int i; /* Send out a packet with a preference so that all * hosts will know that we are dead. --- iputils/ping_common.c.countermeasures Tue May 21 10:06:05 2002 +++ iputils/ping_common.c Tue May 21 10:12:42 2002 @@ -628,7 +628,8 @@ tvsub(tv, &tmp_tv); triptime = tv->tv_sec * 1000000 + tv->tv_usec; if (triptime < 0) { - fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures.\n", triptime); + if (options & F_VERBOSE) + fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures.\n", triptime); triptime = 0; if (!(options & F_LATENCY)) { gettimeofday(tv, NULL); --- iputils/ping.c.addrcache 2002-09-20 17:08:11.000000000 +0200 +++ iputils/ping.c 2003-05-15 16:41:19.000000000 +0200 @@ -1124,6 +1124,12 @@ { struct hostent *hp; static char buf[4096]; + static __u32 addr_cache = 0; + + if ( addr == addr_cache ) + return buf; + + addr_cache = addr; if ((options & F_NUMERIC) || !(hp = gethostbyaddr((char *)&addr, 4, AF_INET))) --- iputils/ping6.c.addrcache 2002-09-20 17:08:11.000000000 +0200 +++ iputils/ping6.c 2003-05-15 16:41:19.000000000 +0200 @@ -893,7 +893,14 @@ */ char * pr_addr(struct in6_addr *addr) { - struct hostent *hp = NULL; + static struct hostent *hp = NULL; + static struct in6_addr addr_cache = {{{0,0,0,0}}}; + + if ( addr->s6_addr32[0] == addr_cache.s6_addr32[0] && + addr->s6_addr32[1] == addr_cache.s6_addr32[1] && + addr->s6_addr32[2] == addr_cache.s6_addr32[2] && + addr->s6_addr32[3] == addr_cache.s6_addr32[3] ) + return hp ? hp->h_name : pr_addr_n(addr); if (!(options&F_NUMERIC)) hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6); --- iputils-ss021109-vanilla/ping.c Thu Nov 7 23:53:21 2002 +++ iputils/ping.c Sun Jan 12 03:39:24 2003 @@ -285,6 +285,9 @@ perror("ping: IP_MULTICAST_IF"); exit(2); } + } else if (icmp_sock >= 0) { + /* We possible tried to SO_BINDTODEVICE() a subinterface like 'eth0:1' */ + perror("Warning: cannot bind to specified iface, falling back"); } } } --- iputils/ping.c.icmp_seq 2003-09-03 16:45:07.000000000 +0200 +++ iputils/ping.c 2003-09-03 16:45:41.000000000 +0200 @@ -610,7 +610,7 @@ icp->type = ICMP_ECHO; icp->code = 0; icp->checksum = 0; - icp->un.echo.sequence = htons(ntransmitted+1); + icp->un.echo.sequence = htons(ntransmitted); icp->un.echo.id = ident; /* ID */ CLR((ntransmitted+1) % mx_dup_ck); --- iputils/ping6.c.icmp_seq 2003-09-03 16:45:20.000000000 +0200 +++ iputils/ping6.c 2003-09-03 16:45:34.000000000 +0200 @@ -647,7 +647,7 @@ icmph->icmp6_type = ICMPV6_ECHO_REQUEST; icmph->icmp6_code = 0; icmph->icmp6_cksum = 0; - icmph->icmp6_sequence = htons(ntransmitted+1); + icmph->icmp6_sequence = htons(ntransmitted); icmph->icmp6_identifier = ident; CLR((ntransmitted+1) % mx_dup_ck); diff -ru iputils/include-glibc/netinet/in.h iputils-clean/include-glibc/netinet/in.h --- iputils/include-glibc/netinet/in.h 2000-06-18 14:57:25.000000000 -0400 +++ iputils-clean/include-glibc/netinet/in.h 2003-09-03 11:21:55.000000000 -0400 @@ -8,4 +8,45 @@ #define SOL_IP 0 -#endif /* netinet/in.h */ +/* Functions to convert between host and network byte order. + + Please note that these functions normally take `unsigned long int' or + `unsigned short int' values as arguments and also return them. But + this was a short-sighted decision since on different systems the types + may have different representations but the values are always the same. */ + +extern u_int32_t ntohl (u_int32_t __netlong) __THROW __attribute__ ((__const__)); +extern u_int16_t ntohs (u_int16_t __netshort) + __THROW __attribute__ ((__const__)); +extern u_int32_t htonl (u_int32_t __hostlong) + __THROW __attribute__ ((__const__)); +extern u_int16_t htons (u_int16_t __hostshort) + __THROW __attribute__ ((__const__)); + +#include + +/* Get machine dependent optimized versions of byte swapping functions. */ +#include + +#ifdef __OPTIMIZE__ +/* We can optimize calls to the conversion functions. Either nothing has + to be done or we are using directly the byte-swapping functions which + often can be inlined. */ +# if __BYTE_ORDER == __BIG_ENDIAN +/* The host byte order is the same as network byte order, + so these functions are all just identity. */ +# define ntohl(x) (x) +# define ntohs(x) (x) +# define htonl(x) (x) +# define htons(x) (x) +# else +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define ntohl(x) __bswap_32 (x) +# define ntohs(x) __bswap_16 (x) +# define htonl(x) __bswap_32 (x) +# define htons(x) __bswap_16 (x) +# endif +# endif +#endif + +#endif /* netinet/in.h */ diff -ru iputils/ping6.c iputils-clean/ping6.c --- iputils/ping6.c 2003-09-03 11:22:46.000000000 -0400 +++ iputils-clean/ping6.c 2003-09-03 11:15:42.000000000 -0400 @@ -879,7 +879,7 @@ once = 1; /* Patch bpflet for current identifier. */ - insns[1] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __constant_htons(ident), 0, 1); + insns[1] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(ident), 0, 1); if (setsockopt(icmp_sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter))) perror("WARNING: failed to install socket filter\n"); diff -ru iputils/ping.c iputils-clean/ping.c --- iputils/ping.c 2003-09-03 11:22:46.000000000 -0400 +++ iputils-clean/ping.c 2003-09-03 11:15:26.000000000 -0400 @@ -1196,7 +1196,7 @@ once = 1; /* Patch bpflet for current identifier. */ - insns[2] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __constant_htons(ident), 0, 1); + insns[2] = (struct sock_filter)BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(ident), 0, 1); if (setsockopt(icmp_sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter))) perror("WARNING: failed to install socket filter\n"); diff -urN iputils/clockdiff.c iputils.new/clockdiff.c --- iputils/clockdiff.c 2002-02-22 19:10:59.000000000 -0500 +++ iputils.new/clockdiff.c 2003-09-10 09:20:28.000000000 -0400 @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff -urN iputils/ping6.c iputils.new/ping6.c --- iputils/ping6.c 2003-09-10 17:27:48.000000000 -0400 +++ iputils.new/ping6.c 2003-09-10 17:22:43.000000000 -0400 @@ -68,8 +68,44 @@ */ #include "ping_common.h" -#include -#include +struct ipv6_rt_hdr { + __u8 nexthdr; + __u8 hdrlen; + __u8 type; + __u8 segments_left; + + /* + * type specific data + * variable length field + */ +}; + +struct rt0_hdr { + struct ipv6_rt_hdr rt_hdr; + __u32 bitmap; /* strict/loose bit map */ + struct in6_addr addr[0]; + +#define rt0_type rt_hdr.type; +}; +#define IPV6_SRCRT_TYPE_0 0 /* IPv6 type 0 Routing Header */ +struct ipv6hdr { +#if defined(__LITTLE_ENDIAN) + __u8 priority:4, + version:4; +#elif defined(__BIG_ENDIAN) + __u8 version:4, + priority:4; +#endif + __u8 flow_lbl[3]; + + __u16 payload_len; + __u8 nexthdr; + __u8 hop_limit; + + struct in6_addr saddr; + struct in6_addr daddr; +}; + #include #define BIT_CLEAR(nr, addr) do { ((__u32 *)(addr))[(nr) >> 5] &= ~(1U << ((nr) & 31)); } while(0) diff -urN iputils/ping_common.h iputils.new/ping_common.h --- iputils/ping_common.h 2002-09-20 11:08:11.000000000 -0400 +++ iputils.new/ping_common.h 2003-09-10 17:16:16.000000000 -0400 @@ -19,6 +19,7 @@ #include #include +#include #include #include "SNAPSHOT.h" diff -urN iputils/tftpd.c iputils.new/tftpd.c --- iputils/tftpd.c 2002-01-23 19:31:41.000000000 -0500 +++ iputils.new/tftpd.c 2003-09-10 09:39:45.000000000 -0400 @@ -57,7 +57,6 @@ #include #include -#include #include #include diff -urN iputils/tracepath6.c iputils.new/tracepath6.c --- iputils/tracepath6.c 2001-09-01 22:03:46.000000000 -0400 +++ iputils.new/tracepath6.c 2003-09-10 09:40:18.000000000 -0400 @@ -14,8 +14,7 @@ #include #include #include - -#include +#include #include #include #include diff -urN iputils/tracepath.c iputils.new/tracepath.c --- iputils/tracepath.c 2002-02-22 19:10:59.000000000 -0500 +++ iputils.new/tracepath.c 2003-09-10 06:14:35.000000000 -0400 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff -urN iputils/traceroute6.c iputils.new/traceroute6.c --- iputils/traceroute6.c 2002-09-20 11:44:22.000000000 -0400 +++ iputils.new/traceroute6.c 2003-09-10 10:12:47.000000000 -0400 @@ -246,9 +246,24 @@ #include #include -#include -#include +#include +struct ipv6hdr { +#if defined(__LITTLE_ENDIAN) + __u8 priority:4, + version:4; +#elif defined(__BIG_ENDIAN) + __u8 version:4, + priority:4; +#endif + __u8 flow_lbl[3]; + + __u16 payload_len; + __u8 nexthdr; + __u8 hop_limit; + struct in6_addr saddr; + struct in6_addr daddr; +}; #include #include --- iputils/arping.c.unaligned 2001-10-06 00:42:47.000000000 +0200 +++ iputils/arping.c 2003-10-02 15:14:42.000000000 +0200 @@ -332,7 +332,7 @@ timeout = atoi(optarg); break; case 'I': - device = optarg; + device = strdup(optarg); break; case 'f': quit_on_reply=1; --- iputils/traceroute6.c.inet_pton 2004-04-22 15:06:28.268797480 +0200 +++ iputils/traceroute6.c 2004-04-22 15:06:35.727877941 +0200 @@ -538,7 +538,7 @@ } else { (void) bzero((char *)&saddr, sizeof(saddr)); saddr.sin6_family = AF_INET6; - if (inet_pton(AF_INET6, source, &saddr.sin6_addr) < 0) + if (inet_pton(AF_INET6, source, &saddr.sin6_addr) <= 0) { Printf("traceroute: unknown addr %s\n", source); exit(1); --- iputils/traceroute6.c.old 2004-12-07 11:08:57.000000000 +0100 +++ iputils/traceroute6.c 2004-12-07 11:14:09.397575536 +0100 @@ -352,8 +352,11 @@ icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); socket_errno = errno; - setuid(getuid()); - + if(setuid(getuid()) != 0) + { + perror("traceroute: setuid()"); + exit(-1); + } on = 1; seq = tos = 0; to = (struct sockaddr_in6 *)&whereto; --- iputils/ping6.c.old 2004-12-07 11:08:57.000000000 +0100 +++ iputils/ping6.c 2004-12-07 11:13:40.707937024 +0100 @@ -223,7 +223,11 @@ socket_errno = errno; uid = getuid(); - setuid(uid); + if(setuid(uid) != 0) + { + perror("ping: setuid()"); + exit(-1); + } source.sin6_family = AF_INET6; memset(&firsthop, 0, sizeof(firsthop)); --- iputils/ping.c.old 2004-12-07 11:08:57.000000000 +0100 +++ iputils/ping.c 2004-12-07 11:13:27.523941296 +0100 @@ -119,7 +119,11 @@ socket_errno = errno; uid = getuid(); - setuid(uid); + if(setuid(uid) != 0) + { + perror("ping: setuid()"); + exit(-1); + } source.sin_family = AF_INET; --- iputils/doc/ping.8.old 2002-09-27 19:12:47.000000000 +0200 +++ iputils/doc/ping.8 2004-12-07 11:09:42.434160144 +0100 @@ -112,7 +112,7 @@ when finished. .TP \fB-R\fR -Record route. +Record route. (IPv4 only) Includes the RECORD_ROUTE option in the ECHO_REQUEST packet and displays the route buffer on returned packets. Note that the IP header is only large enough for nine such routes. --- iputils/doc/ping.sgml.old 2002-09-20 14:55:50.000000000 +0200 +++ iputils/doc/ping.sgml 2004-12-07 11:09:42.435159992 +0100 @@ -190,7 +190,7 @@