Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
1 --- src/sub-func.c.orig 2003-03-19 13:28:15.000000000 +0100
2 +++ src/sub-func.c 2003-07-28 10:35:53.000000000 +0200
3 @@ -1267,7 +1267,7 @@
4 }
5 #endif
7 -#if defined(HAVE_GETHOSTBYNAME2) && defined(HAVE_INET_NTOP)
8 +#if defined(HAVE_GETHOSTBYNAME2) && defined(HAVE_INET_NTOP) && defined(AF_INET6)
9 char *
10 _resolv_v6_ghbn2 (char *raddr, struct dnsresp *d_resp, char *extra)
11 {
12 @@ -1308,7 +1308,7 @@
13 }
14 #endif
16 -#if defined(HAVE_GETADDRINFO) && defined(HAVE_INET_NTOP)
17 +#if defined(HAVE_GETADDRINFO) && defined(HAVE_INET_NTOP) && defined(AF_INET6)
18 char *
19 _resolv_v6_gai (char *raddr, struct dnsresp *d_resp, char *extra)
20 {
21 @@ -1393,13 +1393,19 @@
22 snprintf(d_resp->str, 127, "%s%s", inet_ntoa (sin->sin_addr), extra);
23 d_resp->type = AF_INET;
24 }
25 +#ifdef AF_INET6
26 if (res->ai_family == PF_INET6) {
27 sin6 = (struct sockaddr_in6 *) res->ai_addr;
28 snprintf (retaddr, 1023, "%s%s", inet_ntop (AF_INET6, &sin6->sin6_addr, ip6addr, 128), extra);
29 snprintf (d_resp->str, 127, "%s%s", inet_ntop (AF_INET6, &sin6->sin6_addr, ip6addr, 128), extra);
30 d_resp->type = AF_INET6;
31 }
32 +#endif
33 +#ifdef AF_INET6
34 if (res->ai_next && (res->ai_family == PF_INET || res->ai_family == PF_INET6))
35 +#else
36 + if (res->ai_next && res->ai_family == PF_INET)
37 +#endif
38 d_resp = new_dnsresp (d_resp);
39 res = res->ai_next;
40 }
41 @@ -1460,14 +1466,20 @@
42 if ((f_gethostbyname2 || f_getaddrinfo) && f_inet_ntop)
43 ipv6_cap = 1;
45 +#ifdef AF_INET6
46 if (family != PF_INET && family != PF_INET6 && family != PF_UNSPEC)
47 +#else
48 + if (family != PF_INET && family != PF_UNSPEC)
49 +#endif
50 return NULL;
52 if (family == PF_INET && !ipv4_cap)
53 return NULL;
55 +#ifdef AF_INET6
56 if (family == PF_INET6 && !ipv6_cap)
57 return NULL;
58 +#endif
60 if (family == PF_UNSPEC && (!ipv4_cap && !ipv6_cap))
61 return NULL;
62 @@ -1475,8 +1487,10 @@
63 if (strlen (addr) > 1023)
64 return NULL;
66 +#ifdef AF_INET6
67 if (family == PF_UNSPEC && !ipv4_cap)
68 family = PF_INET6;
69 +#endif
71 if (family == PF_UNSPEC && !ipv6_cap)
72 family = PF_INET;
73 @@ -1508,6 +1522,7 @@
74 return retaddr;
75 }
77 +#ifdef AF_INET6
78 if (family == PF_INET6) {
79 if (f_getaddrinfo) {
80 tmpstr = _resolv_v6_gai (raddr, d_resp, extra);
81 @@ -1525,6 +1540,7 @@
82 return retaddr;
83 }
84 }
85 +#endif
87 if (family == PF_UNSPEC) {
88 if (f_getaddrinfo) {
89 --- src/sub.c.orig 2003-03-19 13:28:16.000000000 +0100
90 +++ src/sub.c 2003-07-28 10:37:10.000000000 +0200
91 @@ -496,6 +496,7 @@
92 ifarg_cur->type = IFT_V6;
93 }
95 +#if AF_INET6
96 if (abox->type == AT_V6 && abox->resolv) {
97 d_resp_start = d_resp_cur = (struct dnsresp *) malloc (sizeof (struct dnsresp));
98 d_resp_start->next = NULL;
99 @@ -526,6 +527,7 @@
101 free_dnsresp (d_resp_start);
102 }
103 +#endif
105 if (abox->type == AT_INT) {
106 if_cur = if_start;
107 @@ -585,12 +587,14 @@
108 d_resp_cur = d_resp_start;
109 while (d_resp_cur) {
110 strncpy (ifarg_cur->cmdstr, abox->str, 127);
111 +#if AF_INET6
112 if (d_resp_cur->type == AF_INET6) {
113 strncpy (ifarg_cur->p_v6addr, d_resp_cur->str, 43);
114 ifarg_cur->type = IFT_V6;
116 mk_ipv6addr (&ifarg_cur->v6ad, ifarg_cur->p_v6addr);
117 }
118 +#endif
119 if (d_resp_cur->type == AF_INET) {
120 tmpstr = strstr (d_resp_cur->str, " ");
121 if (tmpstr != NULL && (strlen (tmpstr) > 0)) {