reorganize/rationalize/format package menuconfig,
[openwrt.git] / package / fping / patches / debian-10.patch
1 --- fping-2.4b2-to-ipv6.orig/fping.8
2 +++ fping-2.4b2-to-ipv6/fping.8
3 @@ -1,4 +1,4 @@
4 -.TH fping l
5 +.TH fping 8
6 .SH NAME
7 fping \- send ICMP ECHO_REQUEST packets to network hosts
8 .SH SYNOPSIS
9 @@ -152,7 +152,7 @@
10 example none the less.
11 .nf
12
13 -#!/usr/local/bin/perl
14 +#!/usr/bin/perl
15 require 'open2.pl';
16
17 $MAILTO = "root";
18 @@ -178,7 +178,7 @@
19 that are currently reachable.
20 .nf
21
22 -#!/usr/local/bin/perl
23 +#!/usr/bin/perl
24
25 $hosts_to_backup = `cat /etc/hosts.backup | fping -a`;
26
27 --- fping-2.4b2-to-ipv6.orig/fping.c
28 +++ fping-2.4b2-to-ipv6/fping.c
29 @@ -42,7 +42,6 @@
30 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
31 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32 */
33 -#define IPV6 1 /* This should be a compiler option, or even better be done from the Makefile... ;) */
34
35 #ifndef _NO_PROTO
36 #if !__STDC__ && !defined( __cplusplus ) && !defined( FUNCPROTO ) \
37 @@ -101,13 +100,8 @@
38 #endif
39 #include <netinet/in_systm.h>
40
41 -/* Linux has bizarre ip.h and ip_icmp.h */
42 -#if defined( __linux__ )
43 -#include "linux.h"
44 -#else
45 #include <netinet/ip.h>
46 #include <netinet/ip_icmp.h>
47 -#endif /* defined(__linux__) */
48
49 #include <arpa/inet.h>
50 #include <netdb.h>
51 @@ -150,7 +144,11 @@
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
55 +#ifndef IPV6
56 #define SIZE_ICMP_HDR ICMP_MINLEN /* from ip_icmp.h */
57 +#else
58 +#define SIZE_ICMP_HDR sizeof(FPING_ICMPHDR)
59 +#endif
60 #define MAX_PING_DATA ( MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR )
61
62 /* sized so as to be like traditional ping */
63 @@ -474,6 +472,35 @@
64 sizeof(opton)))
65 err(1, "setsockopt(IPV6_RTHDR)");
66 #endif
67 +#ifndef USE_SIN6_SCOPE_ID
68 +#ifdef IPV6_RECVPKTINFO
69 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &opton,
70 + sizeof(opton)))
71 + err(1, "setsockopt(IPV6_RECVPKTINFO)");
72 +#else /* old adv. API */
73 + if (setsockopt(s, IPPROTO_IPV6, IPV6_PKTINFO, &opton,
74 + sizeof(opton)))
75 + err(1, "setsockopt(IPV6_PKTINFO)");
76 +#endif
77 +#endif /* USE_SIN6_SCOPE_ID */
78 +#ifdef IPV6_RECVHOPLIMIT
79 + if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &opton,
80 + sizeof(opton)))
81 + err(1, "setsockopt(IPV6_RECVHOPLIMIT)");
82 +#else /* old adv. API */
83 + if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &opton,
84 + sizeof(opton)))
85 + err(1, "setsockopt(IPV6_HOPLIMIT)");
86 +#endif
87 +#ifdef IPV6_CHECKSUM
88 +#ifndef SOL_RAW
89 +#define SOL_RAW IPPROTO_IPV6
90 +#endif
91 + opton = 2;
92 + if (setsockopt(s, SOL_RAW, IPV6_CHECKSUM, &opton,
93 + sizeof(opton)))
94 + err(1, "setsockopt(SOL_RAW,IPV6_CHECKSUM)");
95 +#endif
96 #endif
97
98 if( ( uid = getuid() ) )
99 @@ -1112,7 +1139,7 @@
100 /* but allow time for the last one to come in */
101 if( count_flag )
102 {
103 - if( ( cursor->num_sent >= count ) && ( ht > cursor->timeout ) )
104 + if( ( cursor->num_sent >= count ) && ( cursor->num_recv >= count || ht > cursor->timeout ) )
105 {
106 remove_job( cursor );
107 continue;
108 @@ -1382,15 +1409,15 @@
109 if( h->num_recv_i <= h->num_sent_i )
110 {
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 );
116
117 }/* IF */
118 else
119 {
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 );
125
126 }/* ELSE */
127
128 @@ -2165,20 +2192,33 @@
129 struct addrinfo *res, hints;
130 int ret_ga;
131 char *hostname;
132 + size_t len;
133
134 /* getaddrinfo */
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;
141
142 ret_ga = getaddrinfo(name, NULL, &hints, &res);
143 - if (ret_ga) errx(1, "%s", gai_strerror(ret_ga));
144 + if (ret_ga) {
145 + if(!quiet_flag)
146 + warnx("%s", gai_strerror(ret_ga));
147 + num_noaddress++;
148 + return;
149 + }
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) {
155 + if(!quiet_flag)
156 + warnx("getaddrinfo failed");
157 + num_noaddress++;
158 + return;
159 + }
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);
164 #endif
165 } /* add_name() */
This page took 0.044782 seconds and 5 git commands to generate.