010-ping6_uclibc_resolv.patch 4.8 KB

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