]> git.pld-linux.org Git - packages/wget.git/blame - wget-1.8.1-ipv6.patch
- now pl.po is in source package
[packages/wget.git] / wget-1.8.1-ipv6.patch
CommitLineData
160b56ab 1diff -ubr wget-1.8.1/src/connect.c wget-1.8.1_ipv6/src/connect.c
2--- wget-1.8.1/src/connect.c Tue Nov 27 14:55:40 2001
3+++ wget-1.8.1_ipv6/src/connect.c Tue Jan 15 01:09:23 2002
4@@ -55,6 +55,8 @@
5 extern int errno;
6 #endif
7
8+#define IPV6
9+
10 /* Variables shared by bindport and acceptport: */
11 static int msock = -1;
12 static struct sockaddr *addr;
13@@ -78,13 +80,18 @@
14 int
15 connect_to_one (const unsigned char *addr, unsigned short port, int silent)
16 {
17- struct sockaddr_in sock_name;
18+ SOCKADDR_IN sock_name;
19 int sock, save_errno;
20-
21 /* Set port and protocol */
22- sock_name.sin_family = AF_INET;
23+#ifdef IPV6
24+ sock_name.sin6_family = family;
25+ sock_name.sin6_port = htons (port);
26+ memcpy ((unsigned char *)&sock_name.sin6_addr, addr, sizeof(ip_address));
27+#else
28+ sock_name.sin_family = family;
29 sock_name.sin_port = htons (port);
30- memcpy ((unsigned char *)&sock_name.sin_addr, addr, 4);
31+ memcpy ((unsigned char *)&sock_name.sin_addr, addr, sizeof(ip_address));
32+#endif
33
34 if (!silent)
35 {
36@@ -99,7 +106,7 @@
37 }
38
39 /* Make an internet socket, stream type. */
40- sock = socket (AF_INET, SOCK_STREAM, 0);
41+ sock = socket (family, SOCK_STREAM, 0);
42 if (sock < 0)
43 goto out;
44
45@@ -151,7 +158,7 @@
46 address_list_get_bounds (al, &start, &end);
47 for (i = start; i < end; i++)
48 {
49- unsigned char addr[4];
50+ ip_address addr;
51 int sock;
52 address_list_copy_one (al, i, addr);
53
54@@ -210,11 +217,11 @@
55 bindport (unsigned short *port)
56 {
57 int optval = 1;
58- static struct sockaddr_in srv;
59+ static SOCKADDR_IN srv={0};
60
61 msock = -1;
62 addr = (struct sockaddr *) &srv;
63- if ((msock = socket (AF_INET, SOCK_STREAM, 0)) < 0)
64+ if ((msock = socket (family, SOCK_STREAM, 0)) < 0)
65 return CONSOCKERR;
66 if (setsockopt (msock, SOL_SOCKET, SO_REUSEADDR,
67 (char *)&optval, sizeof (optval)) < 0)
68@@ -222,14 +229,21 @@
69
70 if (opt.bind_address == NULL)
71 {
72- srv.sin_family = AF_INET;
73+#ifdef IPV6
74+ srv.sin6_family = family;
75+#else
76+ srv.sin_family = family;
77 srv.sin_addr.s_addr = htonl (INADDR_ANY);
78+#endif
79 }
80 else
81 srv = *opt.bind_address;
82-
83+#ifdef IPV6
84+ srv.sin6_port = htons (*port);
85+#else
86 srv.sin_port = htons (*port);
87- if (bind (msock, addr, sizeof (struct sockaddr_in)) < 0)
88+#endif
89+ if (bind (msock, addr, sizeof (SOCKADDR_IN)) < 0)
90 {
91 CLOSE (msock);
92 msock = -1;
93@@ -241,14 +255,18 @@
94 /* #### addrlen should be a 32-bit type, which int is not
95 guaranteed to be. Oh, and don't try to make it a size_t,
96 because that can be 64-bit. */
97- int addrlen = sizeof (struct sockaddr_in);
98+ int addrlen = sizeof (SOCKADDR_IN);
99 if (getsockname (msock, addr, &addrlen) < 0)
91ab8a1d
MM
100 {
101 CLOSE (msock);
102 msock = -1;
103 return CONPORTERR;
104 }
160b56ab 105+#ifdef IPV6
106+ *port = ntohs (srv.sin6_port);
107+#else
108 *port = ntohs (srv.sin_port);
109+#endif
110 }
111 if (listen (msock, 1) < 0)
112 {
113@@ -292,7 +310,7 @@
114 uerr_t
115 acceptport (int *sock)
116 {
117- int addrlen = sizeof (struct sockaddr_in);
118+ int addrlen = sizeof (SOCKADDR_IN);
119
120 #ifdef HAVE_SELECT
121 if (select_fd (msock, opt.timeout, 0) <= 0)
122@@ -322,8 +340,8 @@
123 unsigned char *
124 conaddr (int fd)
125 {
126- static unsigned char res[4];
127- struct sockaddr_in mysrv;
128+ static ip_address res;
129+ SOCKADDR_IN mysrv;
130 struct sockaddr *myaddr;
131 int addrlen = sizeof (mysrv); /* see bindport() for discussion of
132 using `int' here. */
133@@ -331,7 +349,11 @@
134 myaddr = (struct sockaddr *) (&mysrv);
135 if (getsockname (fd, myaddr, (int *)&addrlen) < 0)
136 return NULL;
137- memcpy (res, &mysrv.sin_addr, 4);
138+#ifdef IPV6
139+ memcpy (res, &mysrv.sin6_addr, sizeof(ip_address));
140+#else
141+ memcpy (res, &mysrv.sin_addr, sizeof(ip_address));
142+#endif
143 return res;
144 }
145
5b08559f 146diff -ubr wget-1.8.1/src/init.c wget-1.8.1_ipv6/src/init.c
147--- wget-1.8.1/src/init.c Thu Dec 13 19:19:03 2001
148+++ wget-1.8.1_ipv6/src/init.c Tue Jan 15 01:34:06 2002
149@@ -526,8 +526,8 @@
150 cmd_address (const char *com, const char *val, void *closure)
151 {
152 struct address_list *al;
153- struct sockaddr_in sin;
154- struct sockaddr_in **target = (struct sockaddr_in **)closure;
155+ SOCKADDR_IN sin;
156+ SOCKADDR_IN **target = (SOCKADDR_IN **)closure;
157
158 memset (&sin, '\0', sizeof (sin));
159
160@@ -538,11 +538,16 @@
161 exec_name, com, val);
162 return 0;
163 }
164+#ifdef IPV6
165+ sin.sin6_family = family;
166+ sin.sin6_port = 0;
167+ address_list_copy_one (al, 0, (unsigned char *)&sin.sin6_addr);
168+#else
169+ sin.sin_family = family;
170+ sin.sin_port = 0;
171 address_list_copy_one (al, 0, (unsigned char *)&sin.sin_addr);
172+#endif
173 address_list_release (al);
174-
175- sin.sin_family = AF_INET;
176- sin.sin_port = 0;
177
178 FREE_MAYBE (*target);
179
180diff -ubr wget-1.8.1/src/options.h wget-1.8.1_ipv6/src/options.h
181--- wget-1.8.1/src/options.h Fri Nov 30 07:39:08 2001
182+++ wget-1.8.1_ipv6/src/options.h Tue Jan 15 01:05:44 2002
183@@ -19,6 +19,7 @@
184
185 /* Needed for FDP. */
186 #include <stdio.h>
187+#include "host.h"
188
189 struct options
190 {
191@@ -153,7 +154,7 @@
192 int page_requisites; /* Whether we need to download all files
193 necessary to display a page properly. */
194
195- struct sockaddr_in *bind_address; /* What local IP address to bind to. */
196+ SOCKADDR_IN *bind_address; /* What local IP address to bind to. */
197
198 #ifdef HAVE_SSL
199 char *sslcertfile; /* external client cert to use. */
200
201diff -urN wget-1.8.1/src/host.c wget-1.8.1_ipv6/src/host.c
202--- wget-1.8.1/src/host.c Tue Dec 11 09:32:57 2001
203+++ wget-1.8.1_ipv6/src/host.c Mon Apr 1 20:49:22 2002
160b56ab 204@@ -18,6 +18,7 @@
205 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
5b08559f 206
160b56ab 207 #include <config.h>
208+#include <netdb.h>
5b08559f 209
160b56ab 210 #include <stdio.h>
211 #include <stdlib.h>
212@@ -65,8 +66,13 @@
213 # endif
214 #endif
5b08559f 215
160b56ab 216-/* An IPv4 address is simply a 4-byte quantity. */
217-typedef unsigned char ipv4_address[4];
218+#ifdef IPV6
219+int family = AF_INET6;
220+#else
221+int family = AF_INET;
222+#endif
223+
224+
5b08559f 225
160b56ab 226 /* Mapping between known hosts and to lists of their addresses. */
5b08559f 227
160b56ab 228@@ -77,7 +83,7 @@
5b08559f 229
160b56ab 230 struct address_list {
5b08559f 231 int count; /* number of adrresses */
232- ipv4_address *addresses; /* pointer to the string of addresses */
233+ ip_address *addresses; /* pointer to the string of addresses */
234
235 int faulty; /* number of addresses known not to
236 work. */
160b56ab 237@@ -101,7 +107,7 @@
5b08559f 238 unsigned char *ip_store)
160b56ab 239 {
240 assert (index >= al->faulty && index < al->count);
241- memcpy (ip_store, al->addresses + index, sizeof (ipv4_address));
242+ memcpy (ip_store, al->addresses + index, sizeof (ip_address));
243 }
5b08559f 244
160b56ab 245 /* Check whether two address lists have all their IPs in common. */
246@@ -114,7 +120,7 @@
247 if (al1->count != al2->count)
248 return 0;
249 return 0 == memcmp (al1->addresses, al2->addresses,
5b08559f 250- al1->count * sizeof (ipv4_address));
251+ al1->count * sizeof (ip_address));
160b56ab 252 }
5b08559f 253
160b56ab 254 /* Mark the INDEXth element of AL as faulty, so that the next time
255@@ -152,11 +158,11 @@
256 assert (count > 0);
257 al->count = count;
258 al->faulty = 0;
259- al->addresses = xmalloc (count * sizeof (ipv4_address));
260+ al->addresses = xmalloc (count * sizeof (ip_address));
261 al->refcount = 1;
5b08559f 262
160b56ab 263 for (i = 0; i < count; i++)
264- memcpy (al->addresses + i, h_addr_list[i], sizeof (ipv4_address));
265+ memcpy (al->addresses + i, h_addr_list[i], sizeof (ip_address));
5b08559f 266
160b56ab 267 return al;
268 }
269@@ -169,9 +175,9 @@
270 struct address_list *al = xmalloc (sizeof (struct address_list));
271 al->count = 1;
272 al->faulty = 0;
273- al->addresses = xmalloc (sizeof (ipv4_address));
274+ al->addresses = xmalloc (sizeof (ip_address));
275 al->refcount = 1;
276- memcpy (al->addresses, addr, sizeof (ipv4_address));
277+ memcpy (al->addresses, addr, sizeof (ip_address));
5b08559f 278
160b56ab 279 return al;
280 }
281@@ -233,13 +239,12 @@
282 lookup_host (const char *host, int silent)
283 {
284 struct address_list *al = NULL;
285- unsigned long addr;
286+ ip_address addr;
287 struct hostent *hptr;
5b08559f 288
160b56ab 289- /* If the address is of the form d.d.d.d, no further lookup is
290- needed. */
291- addr = (unsigned long)inet_addr (host);
292- if ((int)addr != -1)
293+ /* If the address is of the form that if valid for <family>,
294+ no further lookup is needed. */
295+ if(0>=inet_pton(family,host,addr))
296 {
297 /* ADDR is defined to be in network byte order, which is what
5b08559f 298 this returns, so we can just copy it to STORE_IP. However,
160b56ab 299@@ -248,15 +253,15 @@
5b08559f 300 we copy the correct four bytes. */
160b56ab 301 int offset;
302 #ifdef WORDS_BIGENDIAN
303- offset = sizeof (unsigned long) - sizeof (ipv4_address);
304+ offset = sizeof (unsigned long) - sizeof (ip_address);
305 #else
306 offset = 0;
307 #endif
308 return address_list_new_one ((char *)&addr + offset);
309 }
5b08559f 310
160b56ab 311- /* By now we know that the host name we got is not of the form
312- d.d.d.d. Try to find it in our cache of host names. */
313+ /* By now we know that the host name we got is not numerialcal represantation
314+ for <family>. Try to find it in our cache of host names. */
315 if (host_name_addresses_map)
316 al = hash_table_get (host_name_addresses_map, host);
5b08559f 317
160b56ab 318@@ -270,8 +275,8 @@
319 if (!silent)
320 logprintf (LOG_VERBOSE, _("Resolving %s... "), host);
5b08559f 321
160b56ab 322- /* Look up the host using gethostbyname(). */
323- hptr = gethostbyname (host);
324+ /* Look up the host using getipnodebyname(). */
325+ hptr = gethostbyname2(host, family);
326 if (!hptr)
327 {
328 if (!silent)
This page took 0.056411 seconds and 4 git commands to generate.