package/mtr: add mtr
[openwrt-working-2016/.git] / package / network / services / mtr / patches / 100-disabled-ipv6-fix.patch
1 --- a/net.c
2 +++ b/net.c
3 @@ -307,9 +307,11 @@ void net_send_tcp(int index)
4    struct sockaddr_storage local;
5    struct sockaddr_storage remote;
6    struct sockaddr_in *local4 = (struct sockaddr_in *) &local;
7 -  struct sockaddr_in6 *local6 = (struct sockaddr_in6 *) &local;
8    struct sockaddr_in *remote4 = (struct sockaddr_in *) &remote;
9 +#ifdef ENABLE_IPV6
10 +  struct sockaddr_in6 *local6 = (struct sockaddr_in6 *) &local;
11    struct sockaddr_in6 *remote6 = (struct sockaddr_in6 *) &remote;
12 +#endif
13    socklen_t len;
14  
15    ttl = index + 1;
16 @@ -566,8 +568,10 @@ void net_send_query(int index)
17  
18    /* sendto() assumes packet length includes the IPv4 header but not the 
19       IPv6 header. */
20 -  spacketsize = abs(packetsize)        -
21 -               ( ( af == AF_INET ) ? 0 : sizeof (struct ip6_hdr) );
22 +  spacketsize = abs(packetsize);
23 +#ifdef ENABLE_IPV6
24 +  spacketsize -= ( ( af == AF_INET ) ? 0 : sizeof (struct ip6_hdr) );
25 +#endif
26    rv = sendto(sendsock, packet, spacketsize, 0, remotesockaddr, salen);
27    if (first && (rv < 0) && ((errno == EINVAL) || (errno == EMSGSIZE))) {
28      /* Try the first packet again using host byte order. */
29 --- a/dns.c
30 +++ b/dns.c
31 @@ -49,7 +49,7 @@
32  #include <unistd.h>
33  #include <fcntl.h>
34  //#include <ctype.h>
35 -//#include <string.h>
36 +#include <string.h>
37  #include <stdio.h>
38  #include <stdlib.h>
39  #include <signal.h>
40 --- a/net.h
41 +++ b/net.h
42 @@ -20,6 +20,7 @@
43  #include <netdb.h>
44  #include <arpa/inet.h>
45  #include <netinet/in.h>
46 +#include <sys/select.h>
47  #include <sys/socket.h>
48  #ifdef ENABLE_IPV6
49  #include <netinet/ip6.h>