]> git.pld-linux.org Git - packages/wget.git/blame - wget-1.8.1-ipv6.patch
- added doc. entry for user_agent to info page
[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,
9c788cc8 67 (char *)&optval, sizeof (optval)) < 0)
160b56ab 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;
9c788cc8 131 int addrlen = sizeof (mysrv); /* see bindport() for discussion of
160b56ab 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
9c788cc8 146diff -ubr wget-1.8.1/src/host.c wget-1.8.1_ipv6/src/host.c
147--- wget-1.8.1/src/host.c Tue Dec 11 08:32:57 2001
148+++ wget-1.8.1_ipv6/src/host.c Tue Jan 15 01:14:05 2002
160b56ab 149@@ -18,6 +18,7 @@
150 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
9c788cc8 151
160b56ab 152 #include <config.h>
153+#include <netdb.h>
9c788cc8 154
160b56ab 155 #include <stdio.h>
156 #include <stdlib.h>
157@@ -65,8 +66,13 @@
158 # endif
159 #endif
9c788cc8 160
160b56ab 161-/* An IPv4 address is simply a 4-byte quantity. */
162-typedef unsigned char ipv4_address[4];
163+#ifdef IPV6
164+int family = AF_INET6;
165+#else
166+int family = AF_INET;
167+#endif
168+
169+
9c788cc8 170
160b56ab 171 /* Mapping between known hosts and to lists of their addresses. */
9c788cc8 172
160b56ab 173@@ -77,7 +83,7 @@
9c788cc8 174
160b56ab 175 struct address_list {
5b08559f 176 int count; /* number of adrresses */
177- ipv4_address *addresses; /* pointer to the string of addresses */
9c788cc8 178+ ip_address *addresses; /* pointer to the string of addresses */
179
5b08559f 180 int faulty; /* number of addresses known not to
9c788cc8 181 work. */
160b56ab 182@@ -101,7 +107,7 @@
9c788cc8 183 unsigned char *ip_store)
160b56ab 184 {
185 assert (index >= al->faulty && index < al->count);
186- memcpy (ip_store, al->addresses + index, sizeof (ipv4_address));
187+ memcpy (ip_store, al->addresses + index, sizeof (ip_address));
188 }
9c788cc8 189
160b56ab 190 /* Check whether two address lists have all their IPs in common. */
191@@ -114,7 +120,7 @@
192 if (al1->count != al2->count)
193 return 0;
194 return 0 == memcmp (al1->addresses, al2->addresses,
5b08559f 195- al1->count * sizeof (ipv4_address));
196+ al1->count * sizeof (ip_address));
160b56ab 197 }
9c788cc8 198
160b56ab 199 /* Mark the INDEXth element of AL as faulty, so that the next time
200@@ -152,11 +158,11 @@
201 assert (count > 0);
202 al->count = count;
203 al->faulty = 0;
204- al->addresses = xmalloc (count * sizeof (ipv4_address));
205+ al->addresses = xmalloc (count * sizeof (ip_address));
206 al->refcount = 1;
9c788cc8 207
160b56ab 208 for (i = 0; i < count; i++)
209- memcpy (al->addresses + i, h_addr_list[i], sizeof (ipv4_address));
210+ memcpy (al->addresses + i, h_addr_list[i], sizeof (ip_address));
9c788cc8 211
160b56ab 212 return al;
213 }
214@@ -169,9 +175,9 @@
215 struct address_list *al = xmalloc (sizeof (struct address_list));
216 al->count = 1;
217 al->faulty = 0;
218- al->addresses = xmalloc (sizeof (ipv4_address));
219+ al->addresses = xmalloc (sizeof (ip_address));
220 al->refcount = 1;
221- memcpy (al->addresses, addr, sizeof (ipv4_address));
222+ memcpy (al->addresses, addr, sizeof (ip_address));
9c788cc8 223
160b56ab 224 return al;
225 }
226@@ -233,13 +239,12 @@
227 lookup_host (const char *host, int silent)
228 {
229 struct address_list *al = NULL;
230- unsigned long addr;
231+ ip_address addr;
232 struct hostent *hptr;
9c788cc8 233
160b56ab 234- /* If the address is of the form d.d.d.d, no further lookup is
235- needed. */
236- addr = (unsigned long)inet_addr (host);
237- if ((int)addr != -1)
238+ /* If the address is of the form that if valid for <family>,
239+ no further lookup is needed. */
240+ if(0>=inet_pton(family,host,addr))
241 {
242 /* ADDR is defined to be in network byte order, which is what
9c788cc8 243 this returns, so we can just copy it to STORE_IP. However,
160b56ab 244@@ -248,15 +253,15 @@
9c788cc8 245 we copy the correct four bytes. */
160b56ab 246 int offset;
247 #ifdef WORDS_BIGENDIAN
248- offset = sizeof (unsigned long) - sizeof (ipv4_address);
249+ offset = sizeof (unsigned long) - sizeof (ip_address);
250 #else
251 offset = 0;
252 #endif
253 return address_list_new_one ((char *)&addr + offset);
254 }
9c788cc8 255
160b56ab 256- /* By now we know that the host name we got is not of the form
257- d.d.d.d. Try to find it in our cache of host names. */
258+ /* By now we know that the host name we got is not numerialcal represantation
259+ for <family>. Try to find it in our cache of host names. */
260 if (host_name_addresses_map)
261 al = hash_table_get (host_name_addresses_map, host);
9c788cc8 262
160b56ab 263@@ -270,8 +275,8 @@
264 if (!silent)
265 logprintf (LOG_VERBOSE, _("Resolving %s... "), host);
9c788cc8 266
160b56ab 267- /* Look up the host using gethostbyname(). */
268- hptr = gethostbyname (host);
269+ /* Look up the host using getipnodebyname(). */
270+ hptr = gethostbyname2(host, family);
271 if (!hptr)
272 {
273 if (!silent)
9c788cc8 274diff -ubr wget-1.8.1/src/host.h wget-1.8.1_ipv6/src/host.h
275--- wget-1.8.1/src/host.h Tue Dec 11 08:32:58 2001
276+++ wget-1.8.1_ipv6/src/host.h Tue Jan 15 01:37:06 2002
277@@ -44,4 +44,26 @@
278
279 void host_cleanup PARAMS ((void));
280
281+
282+#define IPV6
283+/*
284+ IPv6 support added by Thomas Lussnig <lussnig@bewegungsmelder.de>
285+ Date: 15.01.2001 02:36:05
286+ If there are mistakes please inform me, but i will not work till the
287+ morning on it.
288+*/
289+
290+#ifdef IPV6
291+#include <netdb.h>
292+/* An IPv6 address is simply a 16-byte quantity. */
293+typedef unsigned char ip_address[16];
294+typedef struct sockaddr_in6 SOCKADDR_IN;
295+#else
296+/* An IPv4 address is simply a 4-byte quantity. */
297+typedef unsigned char ip_address[4];
298+typedef struct sockaddr_in SOCKADDR_IN;
299+#endif
300+extern int family; /* defined in host.c */
301+
302+
303 #endif /* HOST_H */
304Only in wget-1.8.1_ipv6/src: host.h~
305diff -ubr wget-1.8.1/src/init.c wget-1.8.1_ipv6/src/init.c
306--- wget-1.8.1/src/init.c Thu Dec 13 19:19:03 2001
307+++ wget-1.8.1_ipv6/src/init.c Tue Jan 15 01:34:06 2002
308@@ -526,8 +526,8 @@
309 cmd_address (const char *com, const char *val, void *closure)
310 {
311 struct address_list *al;
312- struct sockaddr_in sin;
313- struct sockaddr_in **target = (struct sockaddr_in **)closure;
314+ SOCKADDR_IN sin;
315+ SOCKADDR_IN **target = (SOCKADDR_IN **)closure;
316
317 memset (&sin, '\0', sizeof (sin));
318
319@@ -538,11 +538,16 @@
320 exec_name, com, val);
321 return 0;
322 }
323+#ifdef IPV6
324+ sin.sin6_family = family;
325+ sin.sin6_port = 0;
326+ address_list_copy_one (al, 0, (unsigned char *)&sin.sin6_addr);
327+#else
328+ sin.sin_family = family;
329+ sin.sin_port = 0;
330 address_list_copy_one (al, 0, (unsigned char *)&sin.sin_addr);
331+#endif
332 address_list_release (al);
333-
334- sin.sin_family = AF_INET;
335- sin.sin_port = 0;
336
337 FREE_MAYBE (*target);
338
339diff -ubr wget-1.8.1/src/options.h wget-1.8.1_ipv6/src/options.h
340--- wget-1.8.1/src/options.h Fri Nov 30 07:39:08 2001
341+++ wget-1.8.1_ipv6/src/options.h Tue Jan 15 01:05:44 2002
342@@ -19,6 +19,7 @@
343
344 /* Needed for FDP. */
345 #include <stdio.h>
346+#include "host.h"
347
348 struct options
349 {
350@@ -153,7 +154,7 @@
351 int page_requisites; /* Whether we need to download all files
352 necessary to display a page properly. */
353
354- struct sockaddr_in *bind_address; /* What local IP address to bind to. */
355+ SOCKADDR_IN *bind_address; /* What local IP address to bind to. */
356
357 #ifdef HAVE_SSL
358 char *sslcertfile; /* external client cert to use. */
This page took 0.126706 seconds and 4 git commands to generate.