add chaos_calmer branch
[15.05/openwrt.git] / package / network / utils / iputils / patches / 010-ping6_uclibc_resolv.patch
1 diff --git a/ping6.c b/ping6.c
2 index c5ff881..ef2243f 100644
3 --- a/ping6.c
4 +++ b/ping6.c
5 @@ -71,9 +71,11 @@ char copyright[] =
6  #include <linux/filter.h>
7  #include <netinet/ip6.h>
8  #include <netinet/icmp6.h>
9 +#ifndef __UCLIBC__
10  #include <resolv.h>
11  
12  #include "ping6_niquery.h"
13 +#endif /* __UCLIBC__ */
14  
15  #ifndef SOL_IPV6
16  #define SOL_IPV6 IPPROTO_IPV6
17 @@ -154,6 +156,7 @@ int pmtudisc=-1;
18  
19  static int icmp_sock;
20  
21 +#ifndef __UCLIBC__
22  #include <openssl/md5.h>
23  
24  /* Node Information query */
25 @@ -165,6 +168,7 @@ int ni_subject_type = 0;
26  char *ni_group;
27  
28  __u8 ni_nonce[8];
29 +#endif /* __UCLIBC__ */
30  
31  static struct in6_addr in6_anyaddr;
32  static __inline__ int ipv6_addr_any(struct in6_addr *addr)
33 @@ -223,6 +227,7 @@ unsigned int if_name2index(const char *ifname)
34         return i;
35  }
36  
37 +#ifndef __UCLIBC__
38  struct niquery_option {
39         char *name;
40         int namelen;
41 @@ -512,6 +517,7 @@ char *ni_groupaddr(const char *name)
42                 strcat(nigroup_buf, q);
43         return nigroup_buf;
44  }
45 +#endif /* __UCLIBC__ */
46  
47  int main(int argc, char *argv[])
48  {
49 @@ -595,12 +601,14 @@ int main(int argc, char *argv[])
50                 case 'V':
51                         printf("ping6 utility, iputils-ss%s\n", SNAPSHOT);
52                         exit(0);
53 +#ifndef __UCLIBC__
54                 case 'N':
55                         if (niquery_option_handler(optarg) < 0) {
56                                 usage();
57                                 break;
58                         }
59                         break;
60 +#endif /* __UCLIBC__ */
61                 COMMON_OPTIONS
62                         common_options(ch);
63                         break;
64 @@ -663,6 +671,7 @@ int main(int argc, char *argv[])
65                 argc--;
66         }
67  
68 +#ifndef __UCLIBC__
69         if (ni_query >= 0) {
70                 int i;
71                 for (i = 0; i < 8; i++)
72 @@ -674,15 +683,20 @@ int main(int argc, char *argv[])
73                         ni_subject_type = NI_SUBJ_IPV6;
74                 }
75         }
76 +#endif /* __UCLIBC__ */
77  
78         if (argc > 1)
79                 usage();
80         else if (argc == 1) {
81                 target = *argv;
82         } else {
83 +#ifndef __UCLIBC__
84                 if (ni_query < 0 && ni_subject_type != NI_SUBJ_NAME)
85 +#endif /* __UCLIBC__ */
86                         usage();
87 +#ifndef __UCLIBC__
88                 target = ni_group;
89 +#endif /* __UCLIBC__ */
90         }
91  
92         memset(&hints, 0, sizeof(hints));
93 @@ -817,7 +831,11 @@ int main(int argc, char *argv[])
94                 exit(2);
95         }
96  
97 +#ifndef __UCLIBC__
98         if (datalen >= sizeof(struct timeval) && (ni_query < 0)) {
99 +#else
100 +       if (datalen >= sizeof(struct timeval)) {
101 +#endif /* __UCLIBC__ */
102                 /* can we time transfer */
103                 timing = 1;
104         }
105 @@ -866,9 +884,11 @@ int main(int argc, char *argv[])
106                 ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &filter);
107         }
108  
109 +#ifndef __UCLIBC__
110         if (ni_query >= 0)
111                 ICMP6_FILTER_SETPASS(ICMPV6_NI_REPLY, &filter);
112         else
113 +#endif /* __UCLIBC__ */
114                 ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filter);
115  
116         err = setsockopt(icmp_sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
117 @@ -1100,6 +1120,7 @@ int build_echo(__u8 *_icmph)
118         return cc;
119  }
120  
121 +#ifndef __UCLIBC__
122  int build_niquery(__u8 *_nih)
123  {
124         struct ni_hdr *nih;
125 @@ -1125,6 +1146,7 @@ int build_niquery(__u8 *_nih)
126  
127         return cc;
128  }
129 +#endif /* __UCLIBC__ */
130  
131  int send_probe(void)
132  {
133 @@ -1132,9 +1154,11 @@ int send_probe(void)
134  
135         CLR((ntransmitted+1) % mx_dup_ck);
136  
137 +#ifndef __UCLIBC__
138         if (ni_query >= 0)
139                 len = build_niquery(outpack);
140         else
141 +#endif /* __UCLIBC__ */
142                 len = build_echo(outpack);
143  
144         if (cmsglen == 0) {
145 @@ -1176,6 +1200,7 @@ static void putchar_safe(char c)
146                 printf("\\%03o", c);
147  }
148  
149 +#ifndef __UCLIBC__
150  void pr_niquery_reply_name(struct ni_hdr *nih, int len)
151  {
152         __u8 *h = (__u8 *)(nih + 1);
153 @@ -1304,6 +1329,7 @@ void pr_niquery_reply(__u8 *_nih, int len)
154         }
155         putchar(';');
156  }
157 +#endif /* __UCLIBC__ */
158  
159  /*
160   * parse_reply --
161 @@ -1353,6 +1379,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
162                                       hops, 0, tv, pr_addr(&from->sin6_addr),
163                                       pr_echo_reply))
164                         return 0;
165 +#ifndef __UCLIBC__
166         } else if (icmph->icmp6_type == ICMPV6_NI_REPLY) {
167                 struct ni_hdr *nih = (struct ni_hdr *)icmph;
168                 __u16 seq = ntohs(*(__u16 *)nih->ni_nonce);
169 @@ -1363,6 +1390,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
170                                       hops, 0, tv, pr_addr(&from->sin6_addr),
171                                       pr_niquery_reply))
172                         return 0;
173 +#endif /* __UCLIBC__ */
174         } else {
175                 int nexthdr;
176                 struct ip6_hdr *iph1 = (struct ip6_hdr*)(icmph+1);
177 @@ -1557,7 +1585,9 @@ void usage(void)
178  "Usage: ping6 [-LUdfnqrvVaAD] [-c count] [-i interval] [-w deadline]\n"
179  "             [-p pattern] [-s packetsize] [-t ttl] [-I interface]\n"
180  "             [-M pmtudisc-hint] [-S sndbuf] [-F flowlabel] [-Q tclass]\n"
181 +#ifndef __UCLIBC__
182  "             [[-N nodeinfo-option] ...]\n"
183 +#endif /* __UCLIBC__ */
184  "             [hop1 ...] destination\n");
185         exit(2);
186  }
187 diff --git a/ping6_niquery.h b/ping6_niquery.h
188 index 61a5cfa..34c31f8 100644
189 --- a/ping6_niquery.h
190 +++ b/ping6_niquery.h
191 @@ -1,3 +1,4 @@
192 +#ifndef __UCLIBC__
193  #include <asm/byteorder.h>
194  
195  /* Node Information Query */
196 @@ -45,3 +46,4 @@ struct ni_hdr {
197  #define NI_IPV4ADDR_F_TRUNCATE         NI_IPV6ADDR_F_TRUNCATE
198  #define NI_IPV4ADDR_F_ALL              NI_IPV6ADDR_F_ALL
199  
200 +#endif /* __UCLIBC__ */