1 --- fping-2.4b2-to-ipv6.orig/fping.8
2 +++ fping-2.4b2-to-ipv6/fping.8
7 fping \- send ICMP ECHO_REQUEST packets to network hosts
10 example none the less.
13 -#!/usr/local/bin/perl
19 that are currently reachable.
22 -#!/usr/local/bin/perl
25 $hosts_to_backup = `cat /etc/hosts.backup | fping -a`;
27 --- fping-2.4b2-to-ipv6.orig/fping.c
28 +++ fping-2.4b2-to-ipv6/fping.c
30 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
31 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33 -#define IPV6 1 /* This should be a compiler option, or even better be done from the Makefile... ;) */
36 #if !__STDC__ && !defined( __cplusplus ) && !defined( FUNCPROTO ) \
39 #include <netinet/in_systm.h>
41 -/* Linux has bizarre ip.h and ip_icmp.h */
42 -#if defined( __linux__ )
45 #include <netinet/ip.h>
46 #include <netinet/ip_icmp.h>
47 -#endif /* defined(__linux__) */
49 #include <arpa/inet.h>
52 #define MIN_PING_DATA sizeof( PING_DATA )
53 #define MAX_IP_PACKET 65536 /* (theoretical) max IP packet size */
54 #define SIZE_IP_HDR 20
56 #define SIZE_ICMP_HDR ICMP_MINLEN /* from ip_icmp.h */
58 +#define SIZE_ICMP_HDR sizeof(FPING_ICMPHDR)
60 #define MAX_PING_DATA ( MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR )
62 /* sized so as to be like traditional ping */
65 err(1, "setsockopt(IPV6_RTHDR)");
67 +#ifndef USE_SIN6_SCOPE_ID
68 +#ifdef IPV6_RECVPKTINFO
69 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &opton,
71 + err(1, "setsockopt(IPV6_RECVPKTINFO)");
72 +#else /* old adv. API */
73 + if (setsockopt(s, IPPROTO_IPV6, IPV6_PKTINFO, &opton,
75 + err(1, "setsockopt(IPV6_PKTINFO)");
77 +#endif /* USE_SIN6_SCOPE_ID */
78 +#ifdef IPV6_RECVHOPLIMIT
79 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &opton,
81 + err(1, "setsockopt(IPV6_RECVHOPLIMIT)");
82 +#else /* old adv. API */
83 + if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &opton,
85 + err(1, "setsockopt(IPV6_HOPLIMIT)");
89 +#define SOL_RAW IPPROTO_IPV6
92 + if (setsockopt(s, SOL_RAW, IPV6_CHECKSUM, &opton,
94 + err(1, "setsockopt(SOL_RAW,IPV6_CHECKSUM)");
98 if( ( uid = getuid() ) )
100 /* but allow time for the last one to come in */
103 - if( ( cursor->num_sent >= count ) && ( ht > cursor->timeout ) )
104 + if( ( cursor->num_sent >= count ) && ( cursor->num_recv >= count || ht > cursor->timeout ) )
106 remove_job( cursor );
108 @@ -1382,15 +1409,15 @@
109 if( h->num_recv_i <= h->num_sent_i )
111 fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%",
112 - h->num_sent_i, h->num_recv_i,
113 - ( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i );
114 + h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
115 + ( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i : 0 );
120 fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%",
121 - h->num_sent_i, h->num_recv_i,
122 - ( ( h->num_recv_i * 100 ) / h->num_sent_i ) );
123 + h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
124 + ( ( h->num_recv_i * 100 ) / h->num_sent_i ) : 0 );
128 @@ -2165,20 +2192,33 @@
129 struct addrinfo *res, hints;
135 bzero(&hints, sizeof(struct addrinfo));
136 - hints.ai_flags = AI_CANONNAME;
137 + hints.ai_flags = name_flag ? AI_CANONNAME : 0;
138 hints.ai_family = AF_INET6;
139 hints.ai_socktype = SOCK_RAW;
140 hints.ai_protocol = IPPROTO_ICMPV6;
142 ret_ga = getaddrinfo(name, NULL, &hints, &res);
143 - if (ret_ga) errx(1, "%s", gai_strerror(ret_ga));
146 + warnx("%s", gai_strerror(ret_ga));
150 if (res->ai_canonname) hostname = res->ai_canonname;
151 else hostname = name;
152 - if (!res->ai_addr) errx(1, "getaddrinfo failed");
153 - (void)memcpy(&dst, res->ai_addr, sizeof(FPING_SOCKADDR)); /*res->ai_addrlen);*/
154 + if (!res->ai_addr) {
156 + warnx("getaddrinfo failed");
160 + len = res->ai_addrlen;
161 + if (len > sizeof(FPING_SOCKADDR)) len = sizeof(FPING_SOCKADDR);
162 + (void)memcpy(&dst, res->ai_addr, len);
163 add_addr(name, name, &dst);