]>
Commit | Line | Data |
---|---|---|
a6284aab AF |
1 | --- XFree86-3.3.3.1/xc/lib/SM/sm_genid.c.ipv6 Sun Oct 4 16:36:38 1998 |
2 | +++ XFree86-3.3.3.1/xc/lib/SM/sm_genid.c Thu Jun 24 12:39:44 1999 | |
047d95d5 AF |
3 | @@ -64,6 +64,7 @@ |
4 | #define XOS_USE_NO_LOCKING | |
5 | #define X_INCLUDE_NETDB_H | |
6 | #include <X11/Xos_r.h> | |
7 | +#include <resolv.h> | |
8 | #endif | |
9 | ||
10 | #else /* WIN32 */ | |
11 | @@ -137,6 +138,7 @@ | |
12 | ||
13 | #if defined(TCPCONN) || defined(STREAMSCONN) | |
14 | { | |
15 | + u_long options; | |
16 | char* inet_addr; | |
17 | char temp[4], *ptr1, *ptr2; | |
18 | unsigned char decimal[4]; | |
19 | @@ -144,7 +146,13 @@ | |
20 | _Xgethostbynameparams hparams; | |
21 | struct hostent *hostp; | |
22 | ||
23 | - if ((hostp = _XGethostbyname (hostname,hparams)) != NULL) | |
24 | + if ((_res.options & RES_INIT) == 0) | |
25 | + (void) res_init (); | |
26 | + options = _res.options; | |
27 | + _res.options &= ~RES_USE_INET6; | |
28 | + hostp = _XGethostbyname (hostname,hparams); | |
29 | + _res.options = options; | |
30 | + if (hostp != NULL) | |
31 | inet_addr = inet_ntoa (*(struct in_addr *)(hostp->h_addr)); | |
32 | else | |
33 | return NULL; | |
a6284aab AF |
34 | --- XFree86-3.3.3.1/xc/lib/X11/ConnDis.c.ipv6 Sat Jan 18 07:51:49 1997 |
35 | +++ XFree86-3.3.3.1/xc/lib/X11/ConnDis.c Thu Jun 24 12:39:45 1999 | |
047d95d5 AF |
36 | @@ -163,7 +163,9 @@ |
37 | ||
38 | if (!lastc) return NULL; /* must have a colon */ | |
39 | ||
40 | - if ((lastp != lastc) && (*(lastc - 1) == ':')) { | |
41 | + /* :: is DECnet, : and ::: are IPv6 */ | |
42 | + if ((lastp != lastc) && (*(lastc - 1) == ':') && | |
43 | + (lastp == lastc-1 || *(lastc - 2) != ':') ) { | |
44 | /* DECnet display specified */ | |
45 | ||
46 | #ifndef DNETCONN | |
47 | @@ -334,7 +336,7 @@ | |
48 | _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr); | |
49 | ||
50 | /* | |
51 | - * The family is given in a socket format (ie AF_INET). This | |
52 | + * The family is given in a socket format (ie AF_INET[6]). This | |
53 | * will convert it to the format used by the authorization and | |
54 | * X protocol (ie FamilyInternet). | |
55 | */ | |
56 | @@ -1026,6 +1028,21 @@ | |
57 | for(i=4; i<8; i++) /* do sin_addr */ | |
58 | xdmcp_data[j++] = ((char *)addr)[i]; | |
59 | for(i=2; i<4; i++) /* do sin_port */ | |
60 | + xdmcp_data[j++] = ((char *)addr)[i]; | |
61 | + break; | |
62 | + } | |
63 | +#endif /* AF_INET */ | |
64 | +#ifdef AF_INET6 | |
65 | + case AF_INET6: | |
66 | + { | |
67 | + /* | |
68 | + * addr will contain a sockaddr_in6 with all | |
69 | + * of the members already in network byte order. | |
70 | + */ | |
71 | + | |
72 | + for(i=20; i<24; i++) /* do sin6_addr last 4 bytes */ | |
73 | + xdmcp_data[j++] = ((char *)addr)[i]; | |
74 | + for(i=2; i<4; i++) /* do sin6_port */ | |
75 | xdmcp_data[j++] = ((char *)addr)[i]; | |
76 | break; | |
77 | } | |
a6284aab AF |
78 | --- XFree86-3.3.3.1/xc/lib/X11/Imakefile.ipv6 Fri Nov 6 17:32:30 1998 |
79 | +++ XFree86-3.3.3.1/xc/lib/X11/Imakefile Thu Jun 24 12:39:46 1999 | |
047d95d5 AF |
80 | @@ -947,6 +947,7 @@ |
81 | InstallLintLibrary(X11,$(LINTLIBDIR)) | |
82 | ||
83 | ||
84 | +SpecialCLibObjectRule(AuGetBest,$(ICONFIGFILES),$(CONN_DEFINES)) | |
85 | LinkSourceFile(AuDispose.c,$(XAUTHSRC)) | |
86 | LinkSourceFile(AuGetBest.c,$(XAUTHSRC)) | |
87 | LinkSourceFile(AuFileName.c,$(XAUTHSRC)) | |
a6284aab AF |
88 | --- XFree86-3.3.3.1/xc/lib/Xau/AuGetBest.c.ipv6 Sun Dec 22 04:20:12 1996 |
89 | +++ XFree86-3.3.3.1/xc/lib/Xau/AuGetBest.c Thu Jun 24 12:39:46 1999 | |
047d95d5 AF |
90 | @@ -49,6 +49,32 @@ |
91 | return 1; | |
92 | } | |
93 | ||
94 | +#if defined(TCPCONN) | |
95 | +#include <netinet/in.h> | |
96 | +#include <X11/X.h> | |
97 | +#define MAPTOIPV4(a) ((char *)(a) + sizeof(struct in6_addr) - \ | |
98 | + sizeof(struct in_addr)) | |
99 | +#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len) | |
100 | +static int | |
101 | +inetMapEqual (a4, l4, a6, l6) | |
102 | + char *a4, *a6; | |
103 | + int l4, l6; | |
104 | +{ | |
105 | + /* compare IPv4 with special IPv6 : mapped, loopback */ | |
106 | + if (l4 == sizeof(struct in6_addr) && l6 == sizeof(struct in_addr)) { | |
107 | + char *a = a4; | |
108 | + a4 = a6; | |
109 | + a6 = a; | |
110 | + } else if (l6 != sizeof(struct in6_addr) || l4 != sizeof(struct in_addr)) | |
111 | + return 0; | |
112 | + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a6)) | |
113 | + return !acmp(a4, MAPTOIPV4(a6), sizeof(*a4)); | |
114 | + else | |
115 | + return (a4[0] == 127 && a4[1] == 0 && a4[2] == 0 && a4[3] == 1 && | |
116 | + acmp(a6, &in6addr_loopback, sizeof(*a6)) == 0); | |
117 | +} | |
118 | +#endif | |
119 | + | |
120 | #if NeedFunctionPrototypes | |
121 | Xauth * | |
122 | XauGetBestAuthByAddr ( | |
123 | @@ -147,6 +173,13 @@ | |
124 | (entry->family == family && | |
125 | ((address_length == entry->address_length && | |
126 | binaryEqual (entry->address, address, (int)address_length)) | |
127 | +#if defined(TCPCONN) | |
128 | + || (family == FamilyInternet && | |
129 | + address_length != entry->address_length && | |
130 | + inetMapEqual ((char *)entry->address, | |
131 | + (int)entry->address_length, | |
132 | + (char *)address, (int)address_length)) | |
133 | +#endif | |
134 | #ifdef hpux | |
135 | || (family == FamilyLocal && | |
136 | fully_qual_address_length == entry->address_length && | |
a6284aab AF |
137 | --- XFree86-3.3.3.1/xc/lib/Xau/Imakefile.ipv6 Fri Nov 6 17:32:44 1998 |
138 | +++ XFree86-3.3.3.1/xc/lib/Xau/Imakefile Thu Jun 24 12:39:46 1999 | |
047d95d5 AF |
139 | @@ -23,6 +23,9 @@ |
140 | INCLUDES = | |
141 | #endif | |
142 | ||
143 | + CONN_DEFINES = ConnectionFlags | |
144 | + DEPEND_DEFINES = $(CONN_DEFINES) | |
145 | + | |
146 | HEADERS = \ | |
147 | Xauth.h | |
148 | ||
149 | @@ -33,6 +36,8 @@ | |
150 | AuRead.o AuUnlock.o AuWrite.o $(K5ENCOBJ) | |
151 | ||
152 | #include <Library.tmpl> | |
153 | + | |
154 | +SpecialCLibObjectRule(AuGetBest,$(ICONFIGFILES),$(CONN_DEFINES)) | |
155 | ||
156 | InstallLinkKitLibrary(Xau,$(LINKKITDIR)/lib) | |
157 | ||
a6284aab AF |
158 | --- XFree86-3.3.3.1/xc/lib/Xmu/CvtStdSel.c.ipv6 Sat Jan 18 07:52:13 1997 |
159 | +++ XFree86-3.3.3.1/xc/lib/Xmu/CvtStdSel.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
160 | @@ -225,7 +225,9 @@ |
161 | if ((hostp = _XGethostbyname (hostname,hparams)) == NULL) | |
162 | return False; | |
163 | ||
164 | - if (hostp->h_addrtype != AF_INET) return False; | |
165 | + if ((hostp->h_addrtype != AF_INET) && | |
166 | + (hostp->h_addrtype != AF_INET6)) | |
167 | + return False; | |
168 | *length = hostp->h_length; | |
169 | *value = XtMalloc(*length); | |
170 | (void) memmove (*value, hostp->h_addr, *length); | |
a6284aab AF |
171 | --- XFree86-3.3.3.1/xc/lib/xtrans/Xtrans.c.ipv6 Thu Jun 24 12:39:35 1999 |
172 | +++ XFree86-3.3.3.1/xc/lib/xtrans/Xtrans.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
173 | @@ -218,7 +218,9 @@ |
174 | * | |
175 | * If the protocol part is missing, then assume INET. | |
176 | * If the protocol part and host part are missing, then assume local. | |
177 | - * If a "::" is found then assume DNET. | |
178 | + * If a "host::" is found then assume DNET. | |
179 | + * For IPv6, pb with possible : in host --> use rightmost : and test | |
180 | + * x:y->inet, x::y->dnet, x:::y->inet(v6) | |
181 | */ | |
182 | ||
183 | char *mybuf, *tmpptr; | |
184 | @@ -289,7 +291,23 @@ | |
185 | ||
186 | _host = mybuf; | |
187 | ||
188 | - if ((mybuf = strchr (mybuf,':')) == NULL) | |
189 | + /* For IPv6, we need the rightmost : in the non-catalog part */ | |
190 | + { | |
191 | + char *p; | |
192 | +#if defined(FONT_t) || defined(FS_t) | |
193 | + char *f = strchr (mybuf, '/'); | |
194 | + if (f) *f = 0; | |
195 | +#endif | |
196 | + p = strrchr (mybuf,':'); | |
197 | + if (p && p > mybuf && p[-1] == ':') | |
198 | + if (p-1 == mybuf || p[-2] != ':') | |
199 | + p--; | |
200 | + mybuf = p; | |
201 | +#if defined(FONT_t) || defined(FS_t) | |
202 | + if (f) *f = '/'; | |
203 | +#endif | |
204 | + } | |
205 | + if (mybuf == NULL) | |
206 | { | |
207 | *protocol = NULL; | |
208 | *host = NULL; | |
a6284aab AF |
209 | --- XFree86-3.3.3.1/xc/lib/xtrans/Xtranssock.c.ipv6 Thu Jun 24 12:39:42 1999 |
210 | +++ XFree86-3.3.3.1/xc/lib/xtrans/Xtranssock.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
211 | @@ -70,6 +70,7 @@ |
212 | #define X_INCLUDE_NETDB_H | |
213 | #define XOS_USE_NO_LOCKING | |
214 | #include <X11/Xos_r.h> | |
215 | +#include <resolv.h> | |
216 | #endif | |
217 | ||
218 | #ifdef UNIXCONN | |
219 | @@ -190,8 +191,8 @@ | |
220 | ||
221 | static Sockettrans2dev Sockettrans2devtab[] = { | |
222 | #ifdef TCPCONN | |
223 | - {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, | |
224 | - {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, | |
225 | + {"inet",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, | |
226 | + {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, | |
227 | #endif /* TCPCONN */ | |
228 | #ifdef UNIXCONN | |
229 | {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0}, | |
230 | @@ -294,7 +295,7 @@ | |
231 | XtransConnInfo ciptr; | |
232 | ||
233 | { | |
234 | - struct sockaddr_in sockname; | |
235 | + struct sockaddr_in6 sockname; | |
236 | #if defined(SVR4) || defined(SCO325) | |
237 | size_t namelen = sizeof sockname; | |
238 | #else | |
239 | @@ -322,7 +323,7 @@ | |
240 | return -1; | |
241 | } | |
242 | ||
243 | - ciptr->family = sockname.sin_family; | |
244 | + ciptr->family = sockname.sin6_family; | |
245 | ciptr->addrlen = namelen; | |
246 | memcpy (ciptr->addr, &sockname, ciptr->addrlen); | |
247 | ||
248 | @@ -341,7 +342,7 @@ | |
249 | XtransConnInfo ciptr; | |
250 | ||
251 | { | |
252 | - struct sockaddr_in sockname; | |
253 | + struct sockaddr_in6 sockname; | |
254 | #if defined(SVR4) || defined(SCO325) | |
255 | size_t namelen = sizeof sockname; | |
256 | #else | |
257 | @@ -410,10 +411,11 @@ | |
258 | } | |
259 | ||
260 | #ifdef TCP_NODELAY | |
261 | - if (Sockettrans2devtab[i].family == AF_INET) | |
262 | + if ((Sockettrans2devtab[i].family == AF_INET) || | |
263 | + (Sockettrans2devtab[i].family == AF_INET6)) | |
264 | { | |
265 | /* | |
266 | - * turn off TCP coalescence for INET sockets | |
267 | + * turn off TCP coalescence for INET[6] sockets | |
268 | */ | |
269 | ||
270 | int tmp = 1; | |
271 | @@ -546,10 +548,11 @@ | |
272 | #ifdef SO_REUSEADDR | |
273 | ||
274 | /* | |
275 | - * SO_REUSEADDR only applied to AF_INET | |
276 | + * SO_REUSEADDR only applied to AF_INET6 | |
277 | */ | |
278 | ||
279 | - if (Sockettrans2devtab[i].family == AF_INET) | |
280 | + if ((Sockettrans2devtab[i].family == AF_INET) || | |
281 | + (Sockettrans2devtab[i].family == AF_INET6)) | |
282 | { | |
283 | int one = 1; | |
284 | setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR, | |
285 | @@ -770,7 +773,8 @@ | |
286 | ||
287 | PRMSG (3, "SocketCreateListener(%x,%d)\n", ciptr, fd, 0); | |
288 | ||
289 | - if (Sockettrans2devtab[ciptr->index].family == AF_INET) | |
290 | + if ((Sockettrans2devtab[ciptr->index].family == AF_INET) || | |
291 | + (Sockettrans2devtab[ciptr->index].family == AF_INET6)) | |
292 | retry = 20; | |
293 | else | |
294 | retry = 0; | |
295 | @@ -793,7 +797,8 @@ | |
296 | #endif /* SO_REUSEDADDR */ | |
297 | } | |
298 | ||
299 | - if (Sockettrans2devtab[ciptr->index].family == AF_INET) { | |
300 | + if ((Sockettrans2devtab[ciptr->index].family == AF_INET) || | |
301 | + (Sockettrans2devtab[ciptr->index].family == AF_INET)) { | |
302 | #ifdef SO_DONTLINGER | |
303 | setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); | |
304 | #else | |
305 | @@ -830,7 +835,7 @@ | |
306 | char *port; | |
307 | ||
308 | { | |
309 | - struct sockaddr_in sockname; | |
310 | + struct sockaddr_in6 sockname; | |
311 | int namelen = sizeof(sockname); | |
312 | int status; | |
313 | short tmpport; | |
314 | @@ -878,22 +883,23 @@ | |
315 | port, 0, 0); | |
316 | return TRANS_CREATE_LISTENER_FAILED; | |
317 | } | |
318 | - sockname.sin_port = servp->s_port; | |
319 | + sockname.sin6_port = servp->s_port; | |
320 | } | |
321 | else | |
322 | { | |
323 | tmpport = (short) atoi (port); | |
324 | - sockname.sin_port = htons (tmpport); | |
325 | + sockname.sin6_port = htons (tmpport); | |
326 | } | |
327 | } | |
328 | else | |
329 | - sockname.sin_port = htons (0); | |
330 | + sockname.sin6_port = htons (0); | |
331 | ||
332 | #ifdef BSD44SOCKETS | |
333 | - sockname.sin_len = sizeof (sockname); | |
334 | + sockname.sin6_len = sizeof (sockname); | |
335 | #endif | |
336 | - sockname.sin_family = AF_INET; | |
337 | - sockname.sin_addr.s_addr = htonl (INADDR_ANY); | |
338 | + sockname.sin6_family = AF_INET6; | |
339 | + sockname.sin6_flowinfo = 0; | |
340 | + sockname.sin6_addr = in6addr_any; | |
341 | ||
342 | if ((status = TRANS(SocketCreateListener) (ciptr, | |
343 | (struct sockaddr *) &sockname, namelen)) < 0) | |
a6284aab | 344 | @@ -1095,7 +1101,7 @@ |
047d95d5 AF |
345 | |
346 | { | |
347 | XtransConnInfo newciptr; | |
348 | - struct sockaddr_in sockname; | |
349 | + struct sockaddr_in6 sockname; | |
350 | int namelen = sizeof(sockname); | |
351 | ||
352 | PRMSG (2, "SocketINETAccept(%x,%d)\n", ciptr, ciptr->fd, 0); | |
a6284aab | 353 | @@ -1258,7 +1264,7 @@ |
047d95d5 AF |
354 | char *port; |
355 | ||
356 | { | |
357 | - struct sockaddr_in sockname; | |
358 | + struct sockaddr_in6 sockname; | |
359 | #if defined(SVR4) || defined(SCO325) | |
360 | size_t namelen = sizeof sockname; | |
361 | #else | |
a6284aab | 362 | @@ -1268,14 +1274,15 @@ |
047d95d5 AF |
363 | _Xgetservbynameparams sparams; |
364 | struct hostent *hostp; | |
365 | struct servent *servp; | |
366 | + u_long options; | |
367 | ||
368 | #define PORTBUFSIZE 64 /* what is a real size for this? */ | |
369 | char portbuf[PORTBUFSIZE]; | |
370 | ||
371 | int ret; | |
372 | short tmpport; | |
373 | - unsigned long tmpaddr; | |
374 | char hostnamebuf[256]; /* tmp space */ | |
375 | + char v[64]; /* Vixie's tmp space */ | |
376 | ||
377 | PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port); | |
378 | ||
a6284aab | 379 | @@ -1311,67 +1318,44 @@ |
047d95d5 AF |
380 | */ |
381 | ||
382 | #ifdef BSD44SOCKETS | |
383 | - sockname.sin_len = sizeof (struct sockaddr_in); | |
384 | + sockname.sin6_len = sizeof (struct sockaddr_in6); | |
385 | #endif | |
386 | - sockname.sin_family = AF_INET; | |
387 | + sockname.sin6_family = AF_INET6; | |
388 | + sockname.sin6_flowinfo = 0; | |
389 | ||
390 | /* | |
391 | - * fill in sin_addr | |
392 | + * fill in sin6_addr | |
393 | */ | |
394 | ||
395 | - /* check for ww.xx.yy.zz host string */ | |
396 | - | |
397 | - if (isascii (host[0]) && isdigit (host[0])) { | |
398 | - tmpaddr = inet_addr (host); /* returns network byte order */ | |
399 | - } else { | |
400 | - tmpaddr = -1; | |
401 | - } | |
402 | - | |
403 | - PRMSG (4,"SocketINETConnect: inet_addr(%s) = %x\n", | |
404 | - host, tmpaddr, 0); | |
405 | + /* ww.xx.yy.zz host string done by _XGethostbyname() */ | |
406 | ||
407 | - if (tmpaddr == -1) | |
408 | - { | |
409 | - if ((hostp = _XGethostbyname(host,hparams)) == NULL) | |
410 | - { | |
411 | - PRMSG (1,"SocketINETConnect: Can't get address for %s\n", | |
412 | - host, 0, 0); | |
413 | - ESET(EINVAL); | |
414 | - return TRANS_CONNECT_FAILED; | |
415 | - } | |
416 | - if (hostp->h_addrtype != AF_INET) /* is IP host? */ | |
417 | - { | |
418 | - PRMSG (1,"SocketINETConnect: not INET host%s\n", | |
419 | - host, 0, 0); | |
420 | - ESET(EPROTOTYPE); | |
421 | - return TRANS_CONNECT_FAILED; | |
422 | - } | |
423 | - | |
424 | -#if defined(CRAY) && defined(OLDTCP) | |
425 | - /* Only Cray UNICOS3 and UNICOS4 will define this */ | |
426 | - { | |
427 | - long t; | |
428 | - memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t)); | |
429 | - sockname.sin_addr = t; | |
430 | - } | |
431 | -#else | |
432 | - memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr, | |
433 | - sizeof (sockname.sin_addr)); | |
434 | -#endif /* CRAY and OLDTCP */ | |
435 | - | |
436 | + if ((_res.options & RES_INIT) == 0) | |
437 | + (void)res_init(); | |
438 | + options = _res.options; | |
439 | + _res.options |= RES_USE_INET6; | |
440 | + | |
441 | + hostp = _XGethostbyname(host,hparams); | |
442 | + _res.options = options; | |
443 | + if (hostp == NULL) | |
444 | + { | |
445 | + PRMSG (1,"SocketINETConnect: Can't get address for %s\n", | |
446 | + host, 0, 0); | |
447 | + ESET(EINVAL); | |
448 | + return TRANS_CONNECT_FAILED; | |
449 | } | |
450 | -else | |
451 | + if (hostp->h_addrtype != AF_INET6) /* is IPv6 host? */ | |
452 | { | |
453 | -#if defined(CRAY) && defined(OLDTCP) | |
454 | - /* Only Cray UNICOS3 and UNICOS4 will define this */ | |
455 | - sockname.sin_addr = tmpaddr; | |
456 | -#else | |
457 | - sockname.sin_addr.s_addr = tmpaddr; | |
458 | -#endif /* CRAY and OLDTCP */ | |
459 | + PRMSG (1,"SocketINETConnect: not INET host%s\n", | |
460 | + host, 0, 0); | |
461 | + ESET(EPROTOTYPE); | |
462 | + return TRANS_CONNECT_FAILED; | |
463 | } | |
464 | + | |
465 | + memcpy ((char *) &sockname.sin6_addr, (char *) hostp->h_addr, | |
466 | + sizeof (sockname.sin6_addr)); | |
467 | ||
468 | /* | |
469 | - * fill in sin_port | |
470 | + * fill in sin6_port | |
471 | */ | |
472 | ||
473 | /* Check for number in the port string */ | |
a6284aab | 474 | @@ -1384,16 +1368,16 @@ |
047d95d5 AF |
475 | portbuf, 0, 0); |
476 | return TRANS_CONNECT_FAILED; | |
477 | } | |
478 | - sockname.sin_port = servp->s_port; | |
479 | + sockname.sin6_port = servp->s_port; | |
480 | } | |
481 | else | |
482 | { | |
483 | tmpport = (short) atoi (portbuf); | |
484 | - sockname.sin_port = htons (tmpport); | |
485 | + sockname.sin6_port = htons (tmpport); | |
486 | } | |
487 | ||
488 | - PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n", | |
489 | - ntohs(sockname.sin_port), 0, 0); | |
490 | + PRMSG (4,"SocketINETConnect: sockname.sin6_port = %d\n", | |
491 | + ntohs(sockname.sin6_port), 0, 0); | |
492 | ||
493 | /* | |
494 | * Do the connect() | |
a6284aab | 495 | @@ -1481,13 +1465,21 @@ |
047d95d5 AF |
496 | * by TRANS(GetHostname)), then the two hostnames are equivalent, |
497 | * and we know that 'host' is really a local host. | |
498 | */ | |
499 | - char specified_local_addr_list[10][4]; | |
500 | + char specified_local_addr_list[10][16]; | |
501 | int scount, equiv, i, j; | |
502 | _Xgethostbynameparams hparams; | |
503 | struct hostent *hostp; | |
504 | + u_long options; | |
505 | ||
506 | - if ((hostp = _XGethostbyname (host,hparams)) == NULL) | |
507 | + if ((_res.options & RES_INIT) == 0) | |
508 | + (void)res_init(); | |
509 | + options = _res.options; | |
510 | + _res.options |= RES_USE_INET6; | |
511 | + | |
512 | + if ((hostp = _XGethostbyname (host,hparams)) == NULL) { | |
513 | + _res.options = options; | |
514 | return (0); | |
515 | + } | |
516 | ||
517 | scount = 0; | |
518 | while (hostp->h_addr_list[scount] && scount <= 8) | |
a6284aab | 519 | @@ -1497,17 +1489,14 @@ |
047d95d5 AF |
520 | * from the 1st call, so we must save the address list. |
521 | */ | |
522 | ||
523 | - specified_local_addr_list[scount][0] = | |
524 | - hostp->h_addr_list[scount][0]; | |
525 | - specified_local_addr_list[scount][1] = | |
526 | - hostp->h_addr_list[scount][1]; | |
527 | - specified_local_addr_list[scount][2] = | |
528 | - hostp->h_addr_list[scount][2]; | |
529 | - specified_local_addr_list[scount][3] = | |
530 | - hostp->h_addr_list[scount][3]; | |
531 | + memcpy(specified_local_addr_list[scount], | |
532 | + hostp->h_addr_list[scount], | |
533 | + hostp->h_length); | |
534 | scount++; | |
535 | } | |
536 | - if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL) | |
537 | + hostp = _XGethostbyname (hostnamebuf,hparams); | |
538 | + _res.options = options; | |
539 | + if (hostp == NULL) | |
540 | return (0); | |
541 | ||
542 | equiv = 0; | |
a6284aab | 543 | @@ -1519,14 +1508,9 @@ |
047d95d5 AF |
544 | |
545 | while (hostp->h_addr_list[j]) | |
546 | { | |
547 | - if ((specified_local_addr_list[i][0] == | |
548 | - hostp->h_addr_list[j][0]) && | |
549 | - (specified_local_addr_list[i][1] == | |
550 | - hostp->h_addr_list[j][1]) && | |
551 | - (specified_local_addr_list[i][2] == | |
552 | - hostp->h_addr_list[j][2]) && | |
553 | - (specified_local_addr_list[i][3] == | |
554 | - hostp->h_addr_list[j][3])) | |
555 | + if (memcmp(specified_local_addr_list[i], | |
556 | + hostp->h_addr_list[j], | |
557 | + hostp->h_length) == 0) | |
558 | { | |
559 | /* They're equal, so we're done */ | |
560 | ||
a6284aab AF |
561 | --- XFree86-3.3.3.1/xc/lib/xtrans/Xtransutil.c.ipv6 Thu Jun 24 12:39:42 1999 |
562 | +++ XFree86-3.3.3.1/xc/lib/xtrans/Xtransutil.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
563 | @@ -84,7 +84,7 @@ |
564 | /* | |
565 | * TRANS(ConvertAddress) converts a sockaddr based address to an | |
566 | * X authorization based address. Some of this is defined as part of | |
567 | - * the ChangeHost protocol. The rest is just doen in a consistent manner. | |
568 | + * the ChangeHost protocol. The rest is just done in a consistent manner. | |
569 | */ | |
570 | ||
571 | int | |
572 | @@ -134,6 +134,32 @@ | |
573 | } | |
574 | break; | |
575 | } | |
576 | + | |
577 | + case AF_INET6: | |
578 | + { | |
579 | + /* | |
580 | + * Check for the hack localhost address ::1. | |
581 | + * In this case, we are really FamilyLocal. | |
582 | + */ | |
583 | + | |
584 | + struct sockaddr_in6 saddr; | |
585 | + int len = sizeof(saddr.sin6_addr); | |
586 | + char *cp = (char *) &saddr.sin6_addr; | |
587 | + | |
588 | + memcpy (&saddr, *addrp, sizeof (struct sockaddr_in6)); | |
589 | + | |
590 | + if (memcmp(cp, (char *)&in6addr_loopback, len) == 0) | |
591 | + { | |
592 | + *familyp=FamilyLocal; | |
593 | + } | |
594 | + else | |
595 | + { | |
596 | + *familyp=FamilyInternet; | |
597 | + *addrlenp=len; | |
598 | + memcpy(*addrp,&saddr.sin6_addr,len); | |
599 | + } | |
600 | + break; | |
601 | + } | |
602 | #endif /* defined(TCPCONN) || defined(STREAMSCONN) || MNX_TCPCONN */ | |
603 | ||
604 | #if defined(DNETCONN) | |
605 | @@ -269,6 +295,18 @@ | |
606 | sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf); | |
607 | break; | |
608 | } | |
609 | + | |
610 | + case AF_INET6: | |
611 | + { | |
612 | + struct sockaddr_in6 *saddr = (struct sockaddr_in6 *) addr; | |
613 | + char portnumbuf[10]; | |
614 | + | |
615 | + sprintf (portnumbuf, "%d", ntohs (saddr->sin6_port)); | |
616 | + networkId = (char *) xalloc (3 + strlen (transName) + | |
617 | + strlen (hostnamebuf) + strlen (portnumbuf)); | |
618 | + sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf); | |
619 | + break; | |
620 | + } | |
621 | #endif /* defined(TCPCONN) || defined(STREAMSCONN) || MNX_TCPCONN */ | |
622 | ||
623 | #if defined(DNETCONN) | |
624 | @@ -377,6 +415,42 @@ | |
625 | addr = hostp->h_name; | |
626 | else | |
627 | addr = inet_ntoa (saddr->sin_addr); | |
628 | + break; | |
629 | + } | |
630 | + | |
631 | + case AF_INET6: | |
632 | + { | |
633 | + struct sockaddr_in6 *saddr = (struct sockaddr_in6 *) peer_addr; | |
634 | + _Xgethostbynameparams hparams; | |
635 | + struct hostent * hostp; | |
636 | + static char v[64]; | |
637 | + | |
638 | +#ifdef SIGALRM | |
639 | + /* | |
640 | + * gethostbyaddr can take a LONG time if the host does not exist. | |
641 | + * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds | |
642 | + * that something is wrong and do not make the user wait. | |
643 | + * gethostbyaddr will continue after a signal, so we have to | |
644 | + * jump out of it. | |
645 | + */ | |
646 | + | |
647 | + nameserver_timedout = 0; | |
648 | + signal (SIGALRM, nameserver_lost); | |
649 | + alarm (4); | |
650 | + if (setjmp(env) == 0) { | |
651 | +#endif | |
652 | + hostp = _XGethostbyaddr ((char *) &saddr->sin6_addr, | |
653 | + sizeof (saddr->sin6_addr), AF_INET6, hparams); | |
654 | +#ifdef SIGALRM | |
655 | + } | |
656 | + alarm (0); | |
657 | +#endif | |
658 | + if (hostp != NULL) | |
659 | + addr = hostp->h_name; | |
660 | + else { | |
661 | + inet_ntop (AF_INET6, &saddr->sin6_addr, v, sizeof (v)); | |
662 | + addr = addrbuf; | |
663 | + } | |
664 | break; | |
665 | } | |
666 | ||
a6284aab AF |
667 | --- XFree86-3.3.3.1/xc/programs/Xserver/os/access.c.ipv6 Thu Jun 24 12:39:34 1999 |
668 | +++ XFree86-3.3.3.1/xc/programs/Xserver/os/access.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
669 | @@ -163,6 +163,7 @@ |
670 | #else | |
671 | #if !defined(AMOEBA) && !defined(MINIX) | |
672 | #include <netdb.h> | |
673 | +#include <resolv.h> | |
674 | #else | |
675 | #ifdef AMOEBA | |
676 | #include <server/ip/gen/netdb.h> | |
677 | @@ -215,10 +216,12 @@ | |
678 | ||
679 | #define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len) | |
680 | #define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len) | |
681 | +#if !defined(TCPCONN) | |
682 | #define addrEqual(fam, address, length, host) \ | |
683 | ((fam) == (host)->family &&\ | |
684 | (length) == (host)->len &&\ | |
685 | !acmp (address, (host)->addr, length)) | |
686 | +#endif | |
687 | ||
688 | static int ConvertAddr( | |
689 | #if NeedFunctionPrototypes | |
690 | @@ -260,6 +263,49 @@ | |
691 | static int LocalHostEnabled = FALSE; | |
692 | static int UsingXdmcp = FALSE; | |
693 | ||
694 | +#if defined(TCPCONN) | |
695 | +#define MAPTOIPV4(a) ((char *)(a) + sizeof(struct in6_addr) - \ | |
696 | + sizeof(struct in_addr)) | |
697 | +#define MAPTOIPV6(d,a) { \ | |
698 | + bzero(&d.s6_addr[0], \ | |
699 | + sizeof(struct in6_addr)-2-sizeof(struct in_addr)); \ | |
700 | + d.s6_addr[10] = d.s6_addr[11] = 0xff; \ | |
701 | + acopy(a, MAPTOIPV4(&d.s6_addr[0]), sizeof(struct in_addr)); \ | |
702 | + } | |
703 | + | |
704 | +static int | |
705 | +addrEqual(fam, addr, len, host) | |
706 | + unsigned char *addr; | |
707 | + register HOST *host; | |
708 | + int fam, len; | |
709 | +{ | |
710 | + char *a4, *a6; | |
711 | + | |
712 | + if (fam != host->family) | |
713 | + return FALSE; | |
714 | + if (len == host->len) | |
715 | + return !acmp (addr, host->addr, len); | |
716 | + if (fam != FamilyInternet) | |
717 | + return FALSE; | |
718 | + | |
719 | + /* compare IPv4 with special IPv6 : mapped, loopback */ | |
720 | + if (len == sizeof(struct in6_addr) && | |
721 | + host->len == sizeof(struct in_addr)) { | |
722 | + a4 = host->addr; | |
723 | + a6 = addr; | |
724 | + } else if (len == sizeof(struct in_addr) && | |
725 | + host->len == sizeof(struct in6_addr)) { | |
726 | + a4 = addr; | |
727 | + a6 = host->addr; | |
728 | + } else | |
729 | + return FALSE; | |
730 | + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a6)) | |
731 | + return !acmp(a4, MAPTOIPV4(a6), sizeof(*a4)); | |
732 | + else | |
733 | + return (a4[0] == 127 && a4[1] == 0 && a4[2] == 0 && a4[3] == 1 && | |
734 | + acmp(a6, &in6addr_loopback, sizeof(*a6)) == 0); | |
735 | +} | |
736 | +#endif | |
737 | ||
738 | /* | |
739 | * called when authorization is not enabled to add the | |
740 | @@ -634,6 +680,7 @@ | |
741 | int family; | |
742 | register HOST *host; | |
743 | register struct ifreq *ifr; | |
744 | + struct in6_addr mapped; | |
745 | ||
746 | #ifdef DNETCONN | |
747 | struct dn_naddr *dnaddr = getnodeadd(); | |
748 | @@ -692,10 +739,32 @@ | |
749 | if (family == -1 || family == FamilyLocal) | |
750 | continue; | |
751 | #ifdef DEF_SELF_DEBUG | |
752 | - if (family == FamilyInternet) | |
753 | - ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n", | |
754 | - ifr->ifr_name, addr[0], addr[1], addr[2], addr[3]); | |
755 | + if (family == FamilyInternet) { | |
756 | + char v[64]; | |
757 | + | |
758 | + ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %s\n", | |
759 | + ifr->ifr_name, | |
760 | + inet_ntop(len == 4 ? AF_INET : AF_INET6, addr, v, 64)); | |
761 | + } | |
762 | #endif | |
763 | + if (family == FamilyInternet) { | |
764 | + if (len == 4) { | |
765 | + /* Mapped IPv4 to IPv6 with special case for loopback */ | |
766 | + if (addr[0] == 127 && addr[1] == 0 && | |
767 | + addr[2] == 0 && addr[3] == 1) | |
768 | + addr = (unsigned char *)&in6addr_loopback; | |
769 | + else { | |
770 | + MAPTOIPV6(mapped, addr); | |
771 | + addr = (unsigned char *) &mapped; | |
772 | + } | |
773 | + len = sizeof(mapped); | |
774 | + } | |
775 | + /* | |
776 | + * Link local addresses are too weird | |
777 | + */ | |
778 | + if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr)) | |
779 | + continue; | |
780 | + } | |
781 | for (host = selfhosts; | |
782 | host && !addrEqual (family, addr, len, host); | |
783 | host = host->next) | |
784 | @@ -724,13 +793,15 @@ | |
785 | /* | |
786 | * ignore 'localhost' entries as they're not useful | |
787 | * on the other end of the wire | |
788 | + * ignore 'link local' entries | |
789 | */ | |
790 | - if (len == 4 && | |
791 | - addr[0] == 127 && addr[1] == 0 && | |
792 | - addr[2] == 0 && addr[3] == 1) | |
793 | + if (acmp(addr, &in6addr_loopback, len)==0) | |
794 | continue; | |
795 | ||
796 | XdmcpRegisterConnection (family, (char *)addr, len); | |
797 | + /* what to do with INET6 ???? */ | |
798 | + if (ifr->ifr_addr.sa_family != AF_INET); | |
799 | + continue; | |
800 | broad_addr = ifr->ifr_addr; | |
801 | ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = | |
802 | htonl (INADDR_BROADCAST); | |
803 | @@ -794,10 +865,22 @@ | |
804 | int family; | |
805 | pointer addr; | |
806 | register HOST *host; | |
807 | + struct in6_addr mapped; | |
808 | ||
809 | family = ConvertAddr(from, &len, (pointer *)&addr); | |
810 | if (family == -1 || family == FamilyLocal) | |
811 | return; | |
812 | + if ((family == FamilyInternet) && (len == 4)) { | |
813 | + /* Mapped IPv4 to IPv6 with special case for loopback */ | |
814 | + if (((char *)addr)[0] == 127 && ((char *)addr)[1] == 0 && | |
815 | + ((char *)addr)[2] == 0 && ((char *)addr)[3] == 1) | |
816 | + addr = (pointer)&in6addr_loopback; | |
817 | + else { | |
818 | + MAPTOIPV6(mapped, addr); | |
819 | + addr = (unsigned char *) &mapped; | |
820 | + } | |
821 | + len = sizeof(mapped); | |
822 | + } | |
823 | for (host = selfhosts; host; host = host->next) | |
824 | { | |
825 | if (addrEqual(family, addr, len, host)) | |
826 | @@ -840,7 +923,7 @@ | |
827 | union { | |
828 | struct sockaddr sa; | |
829 | #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) | |
830 | - struct sockaddr_in in; | |
831 | + struct sockaddr_in6 in; | |
832 | #endif /* TCPCONN || STREAMSCONN */ | |
833 | #ifdef DNETCONN | |
834 | struct sockaddr_dn dn; | |
835 | @@ -978,12 +1061,16 @@ | |
836 | #endif /* SECURE_RPC */ | |
837 | #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) | |
838 | { | |
839 | + if ((_res.options & RES_INIT) == 0) | |
840 | + (void)res_init(); | |
841 | + _res.options |= RES_USE_INET6; | |
842 | + | |
843 | /* host name */ | |
844 | if (family == FamilyInternet && (hp = gethostbyname (hostname)) || | |
845 | (hp = gethostbyname (hostname))) | |
846 | { | |
847 | saddr.sa.sa_family = hp->h_addrtype; | |
848 | - len = sizeof(saddr.sa); | |
849 | + len = sizeof(saddr.in); | |
850 | if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1) | |
851 | { | |
852 | #ifdef h_addr /* new 4.3bsd version of gethostent */ | |
853 | @@ -1072,6 +1159,7 @@ | |
854 | pointer pAddr; | |
855 | { | |
856 | int len; | |
857 | + struct in6_addr mapped; | |
858 | ||
859 | if (!AuthorizedClient(client)) | |
860 | return(BadAccess); | |
861 | @@ -1092,6 +1180,11 @@ | |
862 | break; | |
863 | #endif | |
864 | case FamilyInternet: | |
865 | + if (length == sizeof (struct in_addr)) { | |
866 | + MAPTOIPV6(mapped, pAddr); | |
867 | + pAddr = (char *)& mapped; | |
868 | + length = sizeof(mapped); | |
869 | + } | |
870 | case FamilyDECnet: | |
871 | case FamilyChaos: | |
872 | if ((len = CheckAddr (family, pAddr, length)) < 0) | |
873 | @@ -1174,6 +1267,7 @@ | |
874 | { | |
875 | int len; | |
876 | register HOST *host, **prev; | |
877 | + struct in6_addr mapped; | |
878 | ||
879 | if (!AuthorizedClient(client)) | |
880 | return(BadAccess); | |
881 | @@ -1193,6 +1287,11 @@ | |
882 | break; | |
883 | #endif | |
884 | case FamilyInternet: | |
885 | + if (length == sizeof (struct in_addr)) { | |
886 | + MAPTOIPV6(mapped, pAddr); | |
887 | + pAddr = (char *)& mapped; | |
888 | + length = sizeof(mapped); | |
889 | + } | |
890 | case FamilyDECnet: | |
891 | case FamilyChaos: | |
892 | if ((len = CheckAddr (family, pAddr, length)) < 0) | |
893 | @@ -1236,7 +1335,12 @@ | |
894 | for (host = validhosts; host; host = host->next) | |
895 | { | |
896 | nHosts++; | |
897 | - n += (((host->len + 3) >> 2) << 2) + sizeof(xHostEntry); | |
898 | + len = host->len; | |
899 | + if (host->family == FamilyInternet && | |
900 | + len == sizeof (struct in6_addr) && | |
901 | + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)host->addr)) | |
902 | + len = sizeof (struct in_addr); | |
903 | + n += (((len + 3) >> 2) << 2) + sizeof(xHostEntry); | |
904 | } | |
905 | if (n) | |
906 | { | |
907 | @@ -1247,11 +1351,19 @@ | |
908 | } | |
909 | for (host = validhosts; host; host = host->next) | |
910 | { | |
911 | + char *ad = host->addr; | |
912 | + | |
913 | len = host->len; | |
914 | ((xHostEntry *)ptr)->family = host->family; | |
915 | + if (host->family == FamilyInternet && | |
916 | + len == sizeof (struct in6_addr) && | |
917 | + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)host->addr)) { | |
918 | + len = sizeof (struct in_addr); | |
919 | + ad = MAPTOIPV4(ad); | |
920 | + } | |
921 | ((xHostEntry *)ptr)->length = len; | |
922 | ptr += sizeof(xHostEntry); | |
923 | - acopy (host->addr, ptr, len); | |
924 | + acopy (ad, ptr, len); | |
925 | ptr += ((len + 3) >> 2) << 2; | |
926 | } | |
927 | } else { | |
928 | @@ -1277,11 +1389,7 @@ | |
929 | { | |
930 | #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) || defined(MNX_TCPCONN) | |
931 | case FamilyInternet: | |
932 | -#if !defined(AMOEBA) | |
933 | - if (length == sizeof (struct in_addr)) | |
934 | -#else | |
935 | - if (length == sizeof(ipaddr_t)) | |
936 | -#endif | |
937 | + if (length == sizeof (struct in6_addr)) | |
938 | len = length; | |
939 | else | |
940 | len = -1; | |
941 | @@ -1312,11 +1420,7 @@ | |
942 | * Returns 1 if host is invalid, 0 if we've found it. */ | |
943 | ||
944 | InvalidHost (saddr, len) | |
945 | -#ifndef AMOEBA_ORIG | |
946 | register struct sockaddr *saddr; | |
947 | -#else | |
948 | - register ipaddr_t *saddr; | |
949 | -#endif | |
950 | int len; | |
951 | { | |
952 | int family; | |
953 | @@ -1359,11 +1463,7 @@ | |
954 | ||
955 | static int | |
956 | ConvertAddr (saddr, len, addr) | |
957 | -#ifndef AMOEBA_ORIG | |
958 | register struct sockaddr *saddr; | |
959 | -#else | |
960 | - register ipaddr_t *saddr; | |
961 | -#endif | |
962 | int *len; | |
963 | pointer *addr; | |
964 | { | |
965 | @@ -1381,6 +1481,10 @@ | |
966 | case AF_INET: | |
967 | *len = sizeof (struct in_addr); | |
968 | *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr); | |
969 | + return FamilyInternet; | |
970 | + case AF_INET6: | |
971 | + *len = sizeof (struct in6_addr); | |
972 | + *addr = (pointer) &(((struct sockaddr_in6 *) saddr)->sin6_addr); | |
973 | return FamilyInternet; | |
974 | #endif | |
975 | #ifdef DNETCONN | |
a6284aab AF |
976 | --- XFree86-3.3.3.1/xc/programs/Xserver/os/connection.c.ipv6 Thu Jun 24 12:39:34 1999 |
977 | +++ XFree86-3.3.3.1/xc/programs/Xserver/os/connection.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
978 | @@ -477,6 +477,7 @@ |
979 | int auth_id; | |
980 | { | |
981 | char addr[128]; | |
982 | + char v[64]; | |
983 | char *out = addr; | |
984 | ||
985 | if (!((OsCommPtr)client->osPrivate)->trans_conn) { | |
986 | @@ -499,6 +500,13 @@ | |
987 | sprintf(out, "IP %s port %d", | |
988 | inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr), | |
989 | ntohs(((struct sockaddr_in *) saddr)->sin_port)); | |
990 | + break; | |
991 | + case AF_INET6: | |
992 | + sprintf(out, "IPv6 %s port %d", | |
993 | + inet_ntop(AF_INET6, | |
994 | + &((struct sockaddr_in6 *) saddr)->sin6_addr, | |
995 | + v, sizeof (v)), | |
996 | + ntohs(((struct sockaddr_in6 *) saddr)->sin6_port)); | |
997 | break; | |
998 | #endif | |
999 | #ifdef DNETCONN | |
a6284aab AF |
1000 | --- XFree86-3.3.3.1/xc/programs/Xserver/os/k5auth.c.ipv6 Fri May 10 09:02:15 1996 |
1001 | +++ XFree86-3.3.3.1/xc/programs/Xserver/os/k5auth.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1002 | @@ -277,7 +277,7 @@ |
1003 | long addrlen; | |
1004 | krb5_error_code retval, retval2; | |
1005 | register char n; | |
1006 | - struct sockaddr cli_net_addr; | |
1007 | + struct sockaddr_in6 cli_net_addr; | |
1008 | xReq prefix; | |
1009 | krb5_principal cprinc; | |
1010 | krb5_data buf; | |
1011 | @@ -299,15 +299,15 @@ | |
1012 | } | |
1013 | addrlen = sizeof (cli_net_addr); | |
1014 | if (getpeername(((OsCommPtr)client->osPrivate)->fd, | |
1015 | - &cli_net_addr, &addrlen) == -1) | |
1016 | + (struct sockaddr *)&cli_net_addr, &addrlen) == -1) | |
1017 | { | |
1018 | if (creds) | |
1019 | krb5_free_creds(creds); | |
1020 | return(SendConnSetup(client, "Krb5 stage1: getpeername failed")); | |
1021 | } | |
1022 | - if (cli_net_addr.sa_family == AF_UNSPEC | |
1023 | + if (cli_net_addr.sin6_family == AF_UNSPEC | |
1024 | #if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) | |
1025 | - || cli_net_addr.sa_family == AF_UNIX | |
1026 | + || cli_net_addr.sin6_family == AF_UNIX | |
1027 | #endif | |
1028 | ) /* assume local host */ | |
1029 | { | |
1030 | @@ -324,9 +324,9 @@ | |
1031 | } | |
1032 | else | |
1033 | { | |
1034 | - cli_addr.addrtype = cli_net_addr.sa_family; /* the values | |
1035 | + cli_addr.addrtype = cli_net_addr.sin6_family; /* the values | |
1036 | are compatible */ | |
1037 | - switch (cli_net_addr.sa_family) | |
1038 | + switch (cli_net_addr.sin6_family) | |
1039 | { | |
1040 | #ifdef TCPCONN | |
1041 | case AF_INET: | |
1042 | @@ -334,6 +334,11 @@ | |
1043 | cli_addr.contents = | |
1044 | (krb5_octet *)&((struct sockaddr_in *)&cli_net_addr)->sin_addr; | |
1045 | break; | |
1046 | + case AF_INET6: | |
1047 | + cli_addr.length = sizeof (struct in6_addr); | |
1048 | + cli_addr.contents = | |
1049 | + (krb5_octet *)&(&cli_net_addr)->sin6_addr; | |
1050 | + break; | |
1051 | #endif | |
1052 | #ifdef DNETCONN | |
1053 | case AF_DECnet: | |
1054 | @@ -348,7 +353,7 @@ | |
1055 | if (creds) | |
1056 | krb5_free_creds(creds); | |
1057 | sprintf(kerror, "Krb5 stage1: unknown address family %d from getpeername", | |
1058 | - cli_net_addr.sa_family); | |
1059 | + cli_net_addr.sin6_family); | |
1060 | return(SendConnSetup(client, kerror)); | |
1061 | } | |
1062 | } | |
a6284aab AF |
1063 | --- XFree86-3.3.3.1/xc/programs/Xserver/os/utils.c.ipv6 Thu Jun 24 12:39:34 1999 |
1064 | +++ XFree86-3.3.3.1/xc/programs/Xserver/os/utils.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1065 | @@ -1112,7 +1112,9 @@ |
1066 | ||
1067 | #if defined(TCPCONN) || defined(STREAMSCONN) | |
1068 | #ifndef WIN32 | |
1069 | +#include <netinet/in.h> | |
1070 | #include <netdb.h> | |
1071 | +#include <resolv.h> | |
1072 | #endif | |
1073 | #endif | |
1074 | ||
1075 | @@ -1134,6 +1136,10 @@ | |
1076 | char hname[1024], *hnameptr; | |
1077 | struct hostent *host; | |
1078 | int len; | |
1079 | + | |
1080 | + if ((_res.options & RES_INIT) == 0) | |
1081 | + (void)res_init(); | |
1082 | + _res.options |= RES_USE_INET6; | |
1083 | ||
1084 | gethostname(hname, 1024); | |
1085 | host = gethostbyname(hname); | |
a6284aab AF |
1086 | --- XFree86-3.3.3.1/xc/programs/Xserver/os/xdmcp.c.ipv6 Thu Jun 24 12:39:34 1999 |
1087 | +++ XFree86-3.3.3.1/xc/programs/Xserver/os/xdmcp.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1088 | @@ -38,6 +38,8 @@ |
1089 | #endif | |
1090 | #include <netinet/in.h> | |
1091 | #include <netdb.h> | |
1092 | +#include <resolv.h> | |
1093 | +#undef QUERY | |
1094 | #else | |
1095 | #if defined(MINIX) | |
1096 | #include <net/hton.h> | |
1097 | @@ -81,7 +83,7 @@ | |
1098 | ||
1099 | static int xdmcpSocket, sessionSocket; | |
1100 | static xdmcp_states state; | |
1101 | -static struct sockaddr_in req_sockaddr; | |
1102 | +static struct sockaddr_in6 req_sockaddr; | |
1103 | static int req_socklen; | |
1104 | static CARD32 SessionID; | |
1105 | static CARD32 timeOutTime; | |
1106 | @@ -96,7 +98,7 @@ | |
1107 | ||
1108 | static XdmcpBuffer buffer; | |
1109 | ||
1110 | -static struct sockaddr_in ManagerAddress; | |
1111 | +static struct sockaddr_in6 ManagerAddress; | |
1112 | ||
1113 | static void get_xdmcp_sock( | |
1114 | #if NeedFunctionPrototypes | |
1115 | @@ -112,7 +114,7 @@ | |
1116 | ||
1117 | static void recv_willing_msg( | |
1118 | #if NeedFunctionPrototypes | |
1119 | - struct sockaddr_in */*from*/, | |
1120 | + struct sockaddr_in6 */*from*/, | |
1121 | int /*fromlen*/, | |
1122 | unsigned /*length*/ | |
1123 | #endif | |
1124 | @@ -332,24 +334,27 @@ | |
1125 | ||
1126 | #define MAX_BROADCAST 10 | |
1127 | ||
1128 | -static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST]; | |
1129 | +static struct sockaddr_in6 BroadcastAddresses[MAX_BROADCAST]; | |
1130 | static int NumBroadcastAddresses; | |
1131 | ||
1132 | void | |
1133 | XdmcpRegisterBroadcastAddress (addr) | |
1134 | struct sockaddr_in *addr; | |
1135 | { | |
1136 | - struct sockaddr_in *bcast; | |
1137 | + struct sockaddr_in6 *bcast; | |
1138 | if (NumBroadcastAddresses >= MAX_BROADCAST) | |
1139 | return; | |
1140 | bcast = &BroadcastAddresses[NumBroadcastAddresses++]; | |
1141 | - bzero (bcast, sizeof (struct sockaddr_in)); | |
1142 | + bzero (bcast, sizeof (struct sockaddr_in6)); | |
1143 | + /* mapped the IPv4 broadcast address to IPv6 */ | |
1144 | #ifdef BSD44SOCKETS | |
1145 | - bcast->sin_len = addr->sin_len; | |
1146 | + bcast->sin6_len = sizeof(struct sockaddr_in6); | |
1147 | #endif | |
1148 | - bcast->sin_family = addr->sin_family; | |
1149 | - bcast->sin_port = htons (xdm_udp_port); | |
1150 | - bcast->sin_addr = addr->sin_addr; | |
1151 | + bcast->sin6_family = AF_INET6; | |
1152 | + bcast->sin6_port = htons (xdm_udp_port); | |
1153 | + bcast->sin6_flowinfo = 0; | |
1154 | + bcast->sin6_addr.s6_addr[10] = bcast->sin6_addr.s6_addr[11] = 0xff; | |
1155 | + memmove(&bcast->sin6_addr.s6_addr[12], &addr->sin_addr, 4); | |
1156 | } | |
1157 | ||
1158 | /* | |
1159 | @@ -464,6 +469,13 @@ | |
1160 | XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses); | |
1161 | xdmcpGeneration = serverGeneration; | |
1162 | } | |
1163 | + /* for INET6, try go back to INET, to help not INET6 managers !! */ | |
1164 | + if (type == FamilyInternet && | |
1165 | + addrlen == sizeof (struct in6_addr) && | |
1166 | + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)address)) { | |
1167 | + addrlen = sizeof (struct in_addr); | |
1168 | + address += sizeof (struct in6_addr) - sizeof (struct in_addr); | |
1169 | + } | |
1170 | newAddress = (CARD8 *) xalloc (addrlen * sizeof (CARD8)); | |
1171 | if (!newAddress) | |
1172 | return; | |
1173 | @@ -750,7 +762,7 @@ | |
1174 | ||
1175 | /*ARGSUSED*/ | |
1176 | XdmcpAddHost(from, fromlen, AuthenticationName, hostname, status) | |
1177 | - struct sockaddr_in *from; | |
1178 | + struct sockaddr_in6 *from; | |
1179 | ARRAY8Ptr AuthenticationName, hostname, status; | |
1180 | { | |
1181 | XdmcpSelectHost(from, fromlen, AuthenticationName); | |
1182 | @@ -766,8 +778,8 @@ | |
1183 | static void | |
1184 | receive_packet() | |
1185 | { | |
1186 | - struct sockaddr_in from; | |
1187 | - int fromlen = sizeof(struct sockaddr_in); | |
1188 | + struct sockaddr_in6 from; | |
1189 | + int fromlen = sizeof(struct sockaddr_in6); | |
1190 | XdmcpHeader header; | |
1191 | ||
1192 | /* read message off socket */ | |
1193 | @@ -980,7 +992,7 @@ | |
1194 | #ifndef _MINIX | |
1195 | int soopts = 1; | |
1196 | ||
1197 | - if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | |
1198 | + if ((xdmcpSocket = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) | |
1199 | #else /* MINIX */ | |
1200 | char *udp_device; | |
1201 | int r, s_errno; | |
1202 | @@ -1066,7 +1078,7 @@ | |
1203 | ||
1204 | for (i = 0; i < NumBroadcastAddresses; i++) | |
1205 | XdmcpFlush (xdmcpSocket, &buffer, &BroadcastAddresses[i], | |
1206 | - sizeof (struct sockaddr_in)); | |
1207 | + sizeof (struct sockaddr_in6)); | |
1208 | } | |
1209 | else | |
1210 | { | |
1211 | @@ -1077,7 +1089,7 @@ | |
1212 | ||
1213 | static void | |
1214 | recv_willing_msg(from, fromlen, length) | |
1215 | - struct sockaddr_in *from; | |
1216 | + struct sockaddr_in6 *from; | |
1217 | int fromlen; | |
1218 | unsigned length; | |
1219 | { | |
1220 | @@ -1380,23 +1392,29 @@ | |
1221 | ErrorF("Xserver: missing host name in command line\n"); | |
1222 | exit(1); | |
1223 | } | |
1224 | + | |
1225 | + if ((_res.options & RES_INIT) == 0) | |
1226 | + (void)res_init(); | |
1227 | + _res.options |= RES_USE_INET6; | |
1228 | + | |
1229 | if (!(hep = gethostbyname(argv[i]))) | |
1230 | { | |
1231 | ErrorF("Xserver: unknown host: %s\n", argv[i]); | |
1232 | exit(1); | |
1233 | } | |
1234 | #ifndef _MINIX | |
1235 | - if (hep->h_length == sizeof (struct in_addr)) | |
1236 | + if (hep->h_length == sizeof (struct in6_addr)) | |
1237 | #else | |
1238 | if (hep->h_length == sizeof (ipaddr_t)) | |
1239 | #endif | |
1240 | { | |
1241 | - memmove(&ManagerAddress.sin_addr, hep->h_addr, hep->h_length); | |
1242 | + memmove(&ManagerAddress.sin6_addr, hep->h_addr, hep->h_length); | |
1243 | #ifdef BSD44SOCKETS | |
1244 | - ManagerAddress.sin_len = sizeof(ManagerAddress); | |
1245 | + ManagerAddress.sin6_len = sizeof(ManagerAddress); | |
1246 | #endif | |
1247 | - ManagerAddress.sin_family = AF_INET; | |
1248 | - ManagerAddress.sin_port = htons (xdm_udp_port); | |
1249 | + ManagerAddress.sin6_family = AF_INET6; | |
1250 | + ManagerAddress.sin6_port = htons (xdm_udp_port); | |
1251 | + ManagerAddress.sin6_flowinfo = 0; | |
1252 | } | |
1253 | else | |
1254 | { | |
a6284aab AF |
1255 | --- XFree86-3.3.3.1/xc/programs/lbxproxy/os/connection.c.ipv6 Thu Jun 24 12:39:42 1999 |
1256 | +++ XFree86-3.3.3.1/xc/programs/lbxproxy/os/connection.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1257 | @@ -231,7 +231,7 @@ |
1258 | int retry; /* boolean - retry if addr busy */ | |
1259 | ||
1260 | { | |
1261 | - struct sockaddr_in insock; | |
1262 | + struct sockaddr_in6 insock; | |
1263 | int request; | |
1264 | int retryCount; | |
1265 | #ifndef SO_DONTLINGER | |
1266 | @@ -240,7 +240,7 @@ | |
1267 | #endif /* SO_LINGER */ | |
1268 | #endif /* SO_DONTLINGER */ | |
1269 | ||
1270 | - if ((request = socket (AF_INET, SOCK_STREAM, 0)) < 0) | |
1271 | + if ((request = socket (AF_INET6, SOCK_STREAM, 0)) < 0) | |
1272 | { | |
1273 | Error ("Creating TCP socket"); | |
1274 | return -1; | |
1275 | @@ -255,11 +255,12 @@ | |
1276 | { | |
1277 | bzero ((char *)&insock, sizeof (insock)); | |
1278 | #ifdef BSD44SOCKETS | |
1279 | - insock.sin_len = sizeof(insock); | |
1280 | + insock.sin6_len = sizeof(insock); | |
1281 | #endif | |
1282 | - insock.sin_family = AF_INET; | |
1283 | - insock.sin_port = htons ((unsigned short)(X_TCP_PORT + atoi (display))); | |
1284 | - insock.sin_addr.s_addr = htonl(INADDR_ANY); | |
1285 | + insock.sin6_family = AF_INET6; | |
1286 | + insock.sin6_flowinfo = 0; | |
1287 | + insock.sin6_port = htons ((unsigned short)(X_TCP_PORT + atoi (display))); | |
1288 | + insock.sin6_addr = in6addr_any; | |
1289 | ||
1290 | retryCount = retry ? 19 : 0; | |
1291 | ||
a6284aab | 1292 | @@ -1776,7 +1777,7 @@ |
047d95d5 AF |
1293 | struct sockaddr_un un; |
1294 | #endif /* UNIXCONN */ | |
1295 | #ifdef TCPCONN | |
1296 | - struct sockaddr_in in; | |
1297 | + struct sockaddr_in6 in; | |
1298 | #endif /* TCPCONN */ | |
1299 | #ifdef DNETCONN | |
1300 | struct sockaddr_dn dn; | |
a6284aab | 1301 | @@ -1801,7 +1802,9 @@ |
047d95d5 AF |
1302 | fromlen = sizeof (from); |
1303 | if (!getpeername (newconn, &from.sa, &fromlen)) | |
1304 | { | |
1305 | - if (fromlen && (from.sa.sa_family == AF_INET)) | |
1306 | + if (fromlen && | |
1307 | + ((from.sa.sa_family == AF_INET) || | |
1308 | + (from.sa.sa_family == AF_INET6))) | |
1309 | { | |
1310 | int mi = 1; | |
1311 | setsockopt (newconn, IPPROTO_TCP, TCP_NODELAY, | |
a6284aab AF |
1312 | --- XFree86-3.3.3.1/xc/programs/xauth/gethost.c.ipv6 Sun Sep 13 15:15:53 1998 |
1313 | +++ XFree86-3.3.3.1/xc/programs/xauth/gethost.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1314 | @@ -144,15 +144,21 @@ |
1315 | alarm (4); | |
1316 | if (setjmp(env) == 0) { | |
1317 | #endif | |
1318 | - hp = gethostbyaddr (auth->address, auth->address_length, AF_INET); | |
1319 | + hp = gethostbyaddr (auth->address, auth->address_length, | |
1320 | + auth->address_length == 4 ? AF_INET : AF_INET6); | |
1321 | #ifdef SIGALRM | |
1322 | } | |
1323 | alarm (0); | |
1324 | #endif | |
1325 | if (hp) | |
1326 | return (hp->h_name); | |
1327 | - else | |
1328 | - return (inet_ntoa(*((struct in_addr *)(auth->address)))); | |
1329 | + else { | |
1330 | + static char v[64]; | |
1331 | + | |
1332 | + inet_ntop (auth->address_length == 4 ? AF_INET : AF_INET6, | |
1333 | + auth->address, v, sizeof(v)); | |
1334 | + return (v); | |
1335 | + } | |
1336 | } | |
1337 | #endif | |
1338 | #ifdef DNETCONN | |
1339 | @@ -172,38 +178,26 @@ | |
1340 | } | |
1341 | ||
1342 | #ifdef TCPCONN | |
1343 | -/* | |
1344 | - * cribbed from lib/X/XConnDis.c | |
1345 | - */ | |
1346 | static Bool get_inet_address (name, resultp) | |
1347 | char *name; | |
1348 | - unsigned int *resultp; /* return */ | |
1349 | + struct in6_addr *resultp; /* return */ | |
1350 | { | |
1351 | - unsigned int hostinetaddr = inet_addr (name); | |
1352 | struct hostent *host_ptr; | |
1353 | - struct sockaddr_in inaddr; /* dummy variable for size calcs */ | |
1354 | ||
1355 | -#ifndef INADDR_NONE | |
1356 | -#define INADDR_NONE -1 | |
1357 | -#endif | |
1358 | - | |
1359 | - if (hostinetaddr == INADDR_NONE) { | |
1360 | - if ((host_ptr = gethostbyname (name)) == NULL) { | |
1361 | - /* No such host! */ | |
1362 | - errno = EINVAL; | |
1363 | - return False; | |
1364 | - } | |
1365 | - /* Check the address type for an internet host. */ | |
1366 | - if (host_ptr->h_addrtype != AF_INET) { | |
1367 | - /* Not an Internet host! */ | |
1368 | - errno = EPROTOTYPE; | |
1369 | - return False; | |
1370 | - } | |
1371 | - | |
1372 | - memmove( (char *)&hostinetaddr, (char *)host_ptr->h_addr, | |
1373 | - sizeof(inaddr.sin_addr)); | |
1374 | + if ((host_ptr = gethostbyname (name)) == NULL) { | |
1375 | + /* No such host! */ | |
1376 | + errno = EINVAL; | |
1377 | + return False; | |
1378 | } | |
1379 | - *resultp = hostinetaddr; | |
1380 | + /* Check the address type for an internet host. */ | |
1381 | + if (host_ptr->h_addrtype != AF_INET6) { | |
1382 | + /* Not an Internet host! */ | |
1383 | + errno = EPROTOTYPE; | |
1384 | + return False; | |
1385 | + } | |
1386 | + | |
1387 | + memmove( (char *)resultp, (char *)host_ptr->h_addr, | |
1388 | + host_ptr->h_length); | |
1389 | return True; | |
1390 | } | |
1391 | #endif | |
1392 | @@ -239,8 +233,7 @@ | |
1393 | int len = 0; | |
1394 | char *src = NULL; | |
1395 | #ifdef TCPCONN | |
1396 | - unsigned int hostinetaddr; | |
1397 | - struct sockaddr_in inaddr; /* dummy variable for size calcs */ | |
1398 | + struct in6_addr hostinetaddr; | |
1399 | #endif | |
1400 | #ifdef DNETCONN | |
1401 | struct dn_naddr dnaddr; | |
1402 | @@ -273,7 +266,7 @@ | |
1403 | #ifdef TCPCONN | |
1404 | if (!get_inet_address (host, &hostinetaddr)) return NULL; | |
1405 | src = (char *) &hostinetaddr; | |
1406 | - len = 4; /* sizeof inaddr.sin_addr, would fail on Cray */ | |
1407 | + len = (sizeof hostinetaddr); | |
1408 | break; | |
1409 | #else | |
1410 | return NULL; | |
a6284aab AF |
1411 | --- XFree86-3.3.3.1/xc/programs/xauth/parsedpy.c.ipv6 Mon Feb 16 01:43:19 1998 |
1412 | +++ XFree86-3.3.3.1/xc/programs/xauth/parsedpy.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1413 | @@ -115,12 +115,18 @@ |
1414 | if (!displayname || !displayname[0]) return False; | |
1415 | ||
1416 | /* must have at least :number */ | |
1417 | - ptr = strchr(displayname, ':'); | |
1418 | + /* | |
1419 | + * If a "host::" is found then assume DNET. | |
1420 | + * For IPv6, pb with possible : in host --> use rightmost : and test | |
1421 | + * x:y->inet, x::y->dnet, x:::y->inet(v6) | |
1422 | + */ | |
1423 | + ptr = strrchr(displayname, ':'); | |
1424 | if (!ptr || !ptr[1]) return False; | |
1425 | - if (ptr[1] == ':') { | |
1426 | - if (ptr[2] == '\0') return False; | |
1427 | - dnet = True; | |
1428 | - } | |
1429 | + if (ptr > displayname && ptr[-1] == ':') | |
1430 | + if (ptr-1 == displayname || ptr[-2] != ':') { | |
1431 | + ptr--; | |
1432 | + dnet = True; | |
1433 | + } | |
1434 | ||
1435 | ||
1436 | /* | |
a6284aab AF |
1437 | --- XFree86-3.3.3.1/xc/programs/xauth/xauth.c.ipv6 Wed Apr 27 09:19:54 1994 |
1438 | +++ XFree86-3.3.3.1/xc/programs/xauth/xauth.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1439 | @@ -32,6 +32,8 @@ |
1440 | ||
1441 | #include "xauth.h" | |
1442 | ||
1443 | +#include <netinet/in.h> | |
1444 | +#include <resolv.h> | |
1445 | ||
1446 | /* | |
1447 | * global data | |
1448 | @@ -102,6 +104,10 @@ | |
1449 | int status; | |
1450 | ||
1451 | ProgramName = argv[0]; | |
1452 | + | |
1453 | + if ((_res.options & RES_INIT) == 0) | |
1454 | + (void)res_init(); | |
1455 | + _res.options |= RES_USE_INET6; | |
1456 | ||
1457 | for (i = 1; i < argc; i++) { | |
1458 | char *arg = argv[i]; | |
a6284aab AF |
1459 | --- XFree86-3.3.3.1/xc/programs/xdm/access.c.ipv6 Sat Jan 18 08:02:17 1997 |
1460 | +++ XFree86-3.3.3.1/xc/programs/xdm/access.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1461 | @@ -379,6 +379,11 @@ |
1462 | display->connectionType = FamilyInternet; | |
1463 | break; | |
1464 | #endif | |
1465 | +#ifdef AF_INET6 | |
1466 | + case AF_INET6: | |
1467 | + display->connectionType = FamilyInternet; | |
1468 | + break; | |
1469 | +#endif | |
1470 | #ifdef AF_DECnet | |
1471 | case AF_DECnet: | |
1472 | display->connectionType = FamilyDECnet; | |
a6284aab AF |
1473 | --- XFree86-3.3.3.1/xc/programs/xdm/auth.c.ipv6 Thu Jun 24 12:39:34 1999 |
1474 | +++ XFree86-3.3.3.1/xc/programs/xdm/auth.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1475 | @@ -86,8 +86,8 @@ |
1476 | # endif /* ESIX */ | |
1477 | #endif /* i386 */ | |
1478 | ||
1479 | -#ifdef SVR4 | |
1480 | # include <netdb.h> | |
1481 | +#ifdef SVR4 | |
1482 | # ifndef SCO325 | |
1483 | # include <sys/sockio.h> | |
1484 | # endif | |
1485 | @@ -988,6 +988,21 @@ | |
1486 | Debug ("Skipping localhost address\n"); | |
1487 | continue; | |
1488 | } | |
1489 | + if (len == sizeof (struct in6_addr)) { | |
1490 | + if (bcmp(addr, &in6addr_loopback, len) == 0) | |
1491 | + { | |
1492 | + Debug ("Skipping localhost address\n"); | |
1493 | + continue; | |
1494 | + } | |
1495 | + /* | |
1496 | + * ignore Link local address, the semantic would be weird | |
1497 | + */ | |
1498 | + if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr)) | |
1499 | + { | |
1500 | + Debug ("Skipping link-local address\n"); | |
1501 | + continue; | |
1502 | + } | |
1503 | + } | |
1504 | family = FamilyInternet; | |
1505 | } | |
1506 | Debug ("DefineSelf: write network address, length %d\n", len); | |
1507 | @@ -1014,10 +1029,10 @@ | |
1508 | ||
1509 | union { | |
1510 | struct sockaddr sa; | |
1511 | - struct sockaddr_in in; | |
1512 | + struct sockaddr_in6 in; | |
1513 | } saddr; | |
1514 | ||
1515 | - struct sockaddr_in *inetaddr; | |
1516 | + struct sockaddr_in6 *inetaddr; | |
1517 | ||
1518 | /* hpux: | |
1519 | * Why not use gethostname()? Well, at least on my system, I've had to | |
1520 | @@ -1029,12 +1044,12 @@ | |
1521 | hp = gethostbyname (name.nodename); | |
1522 | if (hp != NULL) { | |
1523 | saddr.sa.sa_family = hp->h_addrtype; | |
1524 | - inetaddr = (struct sockaddr_in *) (&(saddr.sa)); | |
1525 | - memmove( (char *) &(inetaddr->sin_addr), (char *) hp->h_addr, (int) hp->h_length); | |
1526 | + inetaddr = (struct sockaddr_in6 *) (&(saddr.sa)); | |
1527 | + memmove( (char *) &(inetaddr->sin6_addr), (char *) hp->h_addr, (int) hp->h_length); | |
1528 | family = ConvertAddr ( &(saddr.sa), &len, &addr); | |
1529 | if ( family >= 0) { | |
1530 | - writeAddr (FamilyInternet, sizeof (inetaddr->sin_addr), | |
1531 | - (char *) (&inetaddr->sin_addr), file, auth); | |
1532 | + writeAddr (FamilyInternet, sizeof (inetaddr->sin6_addr), | |
1533 | + (char *) (&inetaddr->sin6_addr), file, auth); | |
1534 | } | |
1535 | } | |
1536 | } | |
1537 | @@ -1101,7 +1116,7 @@ | |
1538 | tcp_device= TCP_DEVICE; | |
1539 | fd = open(tcp_device, O_RDWR); | |
1540 | #else | |
1541 | - fd = socket (AF_INET, SOCK_STREAM, 0); | |
1542 | + fd = socket (AF_INET6, SOCK_STREAM, 0); | |
1543 | #endif | |
1544 | DefineSelf (fd, file, auth); | |
1545 | close (fd); | |
1546 | @@ -1133,6 +1148,35 @@ | |
1547 | setAuthNumber (auth, name); | |
1548 | family = ConvertAddr (peer, &peerlen, &addr); | |
1549 | Debug ("writeRemoteAuth: family %d\n", family); | |
1550 | + /* if remote and name, set all the remote addresses */ | |
1551 | + if (family == FamilyInternet) | |
1552 | + { | |
1553 | + struct in6_addr tmp; | |
1554 | + struct hostent *hp; | |
1555 | + char **ad, *colon; | |
1556 | + int af; | |
1557 | + | |
1558 | + if (peerlen == sizeof (struct in6_addr) && | |
1559 | + !IN6_IS_ADDR_V4MAPPED((struct in6_addr *)addr)) | |
1560 | + af = AF_INET6; | |
1561 | + else | |
1562 | + af = AF_INET; | |
1563 | + colon = strrchr(name, ':'); | |
1564 | + if (colon) { | |
1565 | + *colon = 0; | |
1566 | + if (inet_pton(af, name, &tmp) == 0 && | |
1567 | + (hp = gethostbyname2(name, af))) { | |
1568 | + for(ad = hp->h_addr_list; *ad; ad++) { | |
1569 | + Debug ("writeRemoteAuth: %d, %d, %x\n", | |
1570 | + family, hp->h_length, *(int *)*ad); | |
1571 | + writeAddr (family, hp->h_length, *ad, file, auth); | |
1572 | + } | |
1573 | + *colon = ':'; | |
1574 | + return; | |
1575 | + } | |
1576 | + *colon = ':'; | |
1577 | + } | |
1578 | + } | |
1579 | if (family != FamilyLocal) | |
1580 | { | |
1581 | Debug ("writeRemoteAuth: %d, %d, %x\n", | |
a6284aab AF |
1582 | --- XFree86-3.3.3.1/xc/programs/xdm/choose.c.ipv6 Sat Jan 18 08:02:19 1997 |
1583 | +++ XFree86-3.3.3.1/xc/programs/xdm/choose.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1584 | @@ -232,6 +232,22 @@ |
1585 | result_len = 8; | |
1586 | } | |
1587 | break; | |
1588 | + case AF_INET6: | |
1589 | + { | |
1590 | + char *port; | |
1591 | + int portlen; | |
1592 | + ARRAY8Ptr localAddress, getLocalAddress (); | |
1593 | + | |
1594 | + port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen); | |
1595 | + result_buf[0] = netfamily >> 8; | |
1596 | + result_buf[1] = netfamily & 0xFF; | |
1597 | + result_buf[2] = port[0]; | |
1598 | + result_buf[3] = port[1]; | |
1599 | + localAddress = getLocalAddress (); | |
1600 | + memmove( (char *)result_buf+4, (char *)localAddress->data, 16); | |
1601 | + result_len = 20; | |
1602 | + } | |
1603 | + break; | |
1604 | #ifdef AF_DECnet | |
1605 | case AF_DECnet: | |
1606 | break; | |
a6284aab AF |
1607 | --- XFree86-3.3.3.1/xc/programs/xdm/chooser.c.ipv6 Thu Jun 24 12:39:34 1999 |
1608 | +++ XFree86-3.3.3.1/xc/programs/xdm/chooser.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1609 | @@ -88,6 +88,7 @@ |
1610 | #endif | |
1611 | #include <netinet/in.h> | |
1612 | #include <arpa/inet.h> | |
1613 | +#include <resolv.h> | |
1614 | #else /* MINIX */ | |
1615 | #include <net/hton.h> | |
1616 | #include <net/netlib.h> | |
1617 | @@ -347,6 +348,11 @@ | |
1618 | hostAddr.length = 4; | |
1619 | connectionType = FamilyInternet; | |
1620 | break; | |
1621 | + case AF_INET6: | |
1622 | + hostAddr.data = (CARD8 *) &((struct sockaddr_in6 *) addr)->sin6_addr; | |
1623 | + hostAddr.length = 16; | |
1624 | + connectionType = FamilyInternet; | |
1625 | + break; | |
1626 | default: | |
1627 | hostAddr.data = (CARD8 *) ""; | |
1628 | hostAddr.length = 0; | |
1629 | @@ -376,11 +382,12 @@ | |
1630 | switch (addr->sa_family) | |
1631 | { | |
1632 | case AF_INET: | |
1633 | + case AF_INET6: | |
1634 | { | |
1635 | struct hostent *hostent; | |
1636 | char *host; | |
1637 | ||
1638 | - hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, AF_INET); | |
1639 | + hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, addr->sa_family); | |
1640 | if (hostent) | |
1641 | { | |
1642 | XdmcpDisposeARRAY8 (hostname); | |
1643 | @@ -493,7 +500,7 @@ | |
1644 | ARRAY8 hostname; | |
1645 | ARRAY8 status; | |
1646 | int saveHostname = 0; | |
1647 | - struct sockaddr addr; | |
1648 | + struct sockaddr_in6 addr; | |
1649 | int addrlen; | |
1650 | #ifdef MINIX | |
1651 | int r; | |
1652 | @@ -750,6 +757,7 @@ | |
1653 | in_addr.sin_family = AF_INET; | |
1654 | else | |
1655 | { | |
1656 | + /* TODO */ | |
1657 | hostent = gethostbyname (name); | |
1658 | if (!hostent) | |
1659 | return; | |
1660 | @@ -920,7 +928,7 @@ | |
1661 | ref.ref_int= socketFD; | |
1662 | nbio_setcallback(socketFD, ASIO_READ, read_cb, ref); | |
1663 | #else /* !MINIX */ | |
1664 | - if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0) | |
1665 | + if ((socketFD = socket (AF_INET6, SOCK_DGRAM, 0)) < 0) | |
1666 | return 0; | |
1667 | #endif /* MINIX */ | |
1668 | #endif | |
1669 | @@ -950,7 +958,7 @@ | |
1670 | { | |
1671 | if (app_resources.xdmAddress) | |
1672 | { | |
1673 | - struct sockaddr_in in_addr; | |
1674 | + struct sockaddr_in6 in_addr; | |
1675 | struct sockaddr *addr; | |
1676 | int family; | |
1677 | int len; | |
1678 | @@ -970,13 +978,14 @@ | |
1679 | xdm = (char *) app_resources.xdmAddress->data; | |
1680 | family = (xdm[0] << 8) + xdm[1]; | |
1681 | switch (family) { | |
1682 | - case AF_INET: | |
1683 | + case AF_INET6: | |
1684 | #ifdef BSD44SOCKETS | |
1685 | - in_addr.sin_len = sizeof(in_addr); | |
1686 | + in_addr.sin6_len = sizeof(in_addr); | |
1687 | #endif | |
1688 | - in_addr.sin_family = family; | |
1689 | - memmove( &in_addr.sin_port, xdm + 2, 2); | |
1690 | - memmove( &in_addr.sin_addr, xdm + 4, 4); | |
1691 | + in_addr.sin6_family = family; | |
1692 | + in_addr.sin6_flowinfo = 0; | |
1693 | + memmove( &in_addr.sin6_port, xdm + 2, 2); | |
1694 | + memmove( &in_addr.sin6_addr, xdm + 4, 16); | |
1695 | addr = (struct sockaddr *) &in_addr; | |
1696 | len = sizeof (in_addr); | |
1697 | break; | |
1698 | @@ -1172,6 +1181,10 @@ | |
1699 | Arg position[3]; | |
1700 | Dimension width, height; | |
1701 | Position x, y; | |
1702 | + | |
1703 | + if ((_res.options & RES_INIT) == 0) | |
1704 | + (void)res_init(); | |
1705 | + _res.options |= RES_USE_INET6; | |
1706 | ||
1707 | toplevel = XtInitialize (argv[0], "Chooser", options, XtNumber(options), &argc, argv); | |
1708 | ||
a6284aab AF |
1709 | --- XFree86-3.3.3.1/xc/programs/xdm/dm.c.ipv6 Sat Oct 31 21:17:43 1998 |
1710 | +++ XFree86-3.3.3.1/xc/programs/xdm/dm.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1711 | @@ -79,6 +79,8 @@ |
1712 | extern int errno; | |
1713 | #endif | |
1714 | ||
1715 | +#include <netinet/in.h> | |
1716 | +#include <resolv.h> | |
1717 | ||
1718 | #if defined(SVR4) && !defined(SCO) | |
1719 | extern FILE *fdopen(); | |
1720 | @@ -118,6 +120,10 @@ | |
1721 | Title = argv[0]; | |
1722 | TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title; | |
1723 | #endif | |
1724 | + | |
1725 | + if ((_res.options & RES_INIT) == 0) | |
1726 | + (void)res_init(); | |
1727 | + _res.options |= RES_USE_INET6; | |
1728 | ||
1729 | /* | |
1730 | * Step 1 - load configuration parameters | |
a6284aab AF |
1731 | --- XFree86-3.3.3.1/xc/programs/xdm/netaddr.c.ipv6 Sat Jan 18 08:02:21 1997 |
1732 | +++ XFree86-3.3.3.1/xc/programs/xdm/netaddr.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1733 | @@ -65,7 +65,7 @@ |
1734 | #endif | |
1735 | ||
1736 | /* given an XdmcpNetaddr, returns the socket protocol family used, | |
1737 | - e.g., AF_INET */ | |
1738 | + e.g., AF_INET[6] */ | |
1739 | ||
1740 | int NetaddrFamily(netaddrp) | |
1741 | XdmcpNetaddr netaddrp; | |
1742 | @@ -96,6 +96,9 @@ | |
1743 | case AF_INET: | |
1744 | *lenp = 2; | |
1745 | return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port); | |
1746 | + case AF_INET6: | |
1747 | + *lenp = 2; | |
1748 | + return (char *)&(((struct sockaddr_in6 *)netaddrp)->sin6_port); | |
1749 | default: | |
1750 | *lenp = 0; | |
1751 | return NULL; | |
1752 | @@ -125,6 +128,9 @@ | |
1753 | case AF_INET: | |
1754 | *lenp = sizeof (struct in_addr); | |
1755 | return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr); | |
1756 | + case AF_INET6: | |
1757 | + *lenp = sizeof (struct in6_addr); | |
1758 | + return (char *) &(((struct sockaddr_in6 *)netaddrp)->sin6_addr); | |
1759 | #endif | |
1760 | #ifdef DNETCONN | |
1761 | case AF_DECnet: | |
1762 | @@ -177,6 +183,7 @@ | |
1763 | #endif | |
1764 | #ifdef TCPCONN | |
1765 | case AF_INET: | |
1766 | + case AF_INET6: | |
1767 | retval = FamilyInternet; | |
1768 | break; | |
1769 | #endif | |
1770 | @@ -248,6 +255,20 @@ | |
1771 | ||
1772 | Debug ("port %d, host %d.%d.%d.%d\n", | |
1773 | (p[0] << 8) + p[1], t[0], t[1], t[2], t[3]); | |
1774 | + break; | |
1775 | + } | |
1776 | +#endif | |
1777 | +#ifdef AF_INET6 | |
1778 | + case AF_INET6: | |
1779 | + | |
1780 | + p = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_port; | |
1781 | + t = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_addr; | |
1782 | + | |
1783 | + Debug ("port %d, host %2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x\n", | |
1784 | + (p[0] << 8) + p[1], | |
1785 | + t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], | |
1786 | + t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]); | |
1787 | + | |
1788 | break; | |
1789 | } | |
1790 | #endif | |
a6284aab AF |
1791 | --- XFree86-3.3.3.1/xc/programs/xdm/socket.c.ipv6 Sat Jan 18 08:02:24 1997 |
1792 | +++ XFree86-3.3.3.1/xc/programs/xdm/socket.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1793 | @@ -84,7 +84,7 @@ |
1794 | CreateWellKnownSockets () | |
1795 | { | |
1796 | #ifndef MINIX | |
1797 | - struct sockaddr_in sock_addr; | |
1798 | + struct sockaddr_in6 sock_addr; | |
1799 | #else /* MINIX */ | |
1800 | char *tcp_device, *udp_device; | |
1801 | nwio_udpopt_t udpopt; | |
1802 | @@ -103,7 +103,7 @@ | |
1803 | udp_device= UDP_DEVICE; | |
1804 | xdmcpFd = open(udp_device, O_RDWR); | |
1805 | #else | |
1806 | - xdmcpFd = socket (AF_INET, SOCK_DGRAM, 0); | |
1807 | + xdmcpFd = socket (AF_INET6, SOCK_DGRAM, 0); | |
1808 | #endif | |
1809 | if (xdmcpFd == -1) { | |
1810 | LogError ("XDMCP socket creation failed, errno %d\n", errno); | |
1811 | @@ -145,11 +145,12 @@ | |
1812 | /* zero out the entire structure; this avoids 4.4 incompatibilities */ | |
1813 | bzero ((char *) &sock_addr, sizeof (sock_addr)); | |
1814 | #ifdef BSD44SOCKETS | |
1815 | - sock_addr.sin_len = sizeof(sock_addr); | |
1816 | + sock_addr.sin6_len = sizeof(sock_addr); | |
1817 | #endif | |
1818 | - sock_addr.sin_family = AF_INET; | |
1819 | - sock_addr.sin_port = htons ((short) request_port); | |
1820 | - sock_addr.sin_addr.s_addr = htonl (INADDR_ANY); | |
1821 | + sock_addr.sin6_family = AF_INET6; | |
1822 | + sock_addr.sin6_port = htons ((short) request_port); | |
1823 | + sock_addr.sin6_flowinfo = 0; | |
1824 | + sock_addr.sin6_addr = in6addr_any; | |
1825 | if (bind (xdmcpFd, (struct sockaddr *)&sock_addr, sizeof (sock_addr)) == -1) | |
1826 | { | |
1827 | LogError ("error %d binding socket address %d\n", errno, request_port); | |
1828 | @@ -167,7 +168,7 @@ | |
1829 | tcp_device= TCP_DEVICE; | |
1830 | chooserFd = open(tcp_device, O_RDWR); | |
1831 | #else | |
1832 | - chooserFd = socket (AF_INET, SOCK_STREAM, 0); | |
1833 | + chooserFd = socket (AF_INET6, SOCK_STREAM, 0); | |
1834 | #endif | |
1835 | Debug ("Created chooser socket %d\n", chooserFd); | |
1836 | if (chooserFd == -1) | |
1837 | @@ -216,7 +217,7 @@ | |
1838 | char *addr; | |
1839 | int *lenp; | |
1840 | { | |
1841 | - struct sockaddr_in in_addr; | |
1842 | + struct sockaddr_in6 in_addr; | |
1843 | int len; | |
1844 | ||
1845 | len = sizeof in_addr; | |
a6284aab AF |
1846 | --- XFree86-3.3.3.1/xc/programs/xdm/xdmcp.c.ipv6 Sun Feb 1 22:44:04 1998 |
1847 | +++ XFree86-3.3.3.1/xc/programs/xdm/xdmcp.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
1848 | @@ -66,6 +66,8 @@ |
1849 | #include <net/gen/netdb.h> | |
1850 | #endif /* !MINIX */ | |
1851 | ||
1852 | +# include <arpa/inet.h> | |
1853 | + | |
1854 | #ifdef X_NOT_STDC_ENV | |
1855 | #define Time_t long | |
1856 | extern Time_t time (); | |
1857 | @@ -133,8 +135,8 @@ | |
1858 | ARRAY8Ptr address; | |
1859 | char *closure; | |
1860 | { | |
1861 | -#ifdef AF_INET | |
1862 | - struct sockaddr_in in_addr; | |
1863 | +#ifdef AF_INET6 | |
1864 | + struct sockaddr_in6 in_addr; | |
1865 | #endif | |
1866 | #ifdef AF_DECnet | |
1867 | #endif | |
1868 | @@ -143,19 +145,20 @@ | |
1869 | ||
1870 | switch (connectionType) | |
1871 | { | |
1872 | -#ifdef AF_INET | |
1873 | +#ifdef AF_INET6 | |
1874 | case FamilyInternet: | |
1875 | addr = (struct sockaddr *) &in_addr; | |
1876 | bzero ((char *) &in_addr, sizeof (in_addr)); | |
1877 | #ifdef BSD44SOCKETS | |
1878 | - in_addr.sin_len = sizeof(in_addr); | |
1879 | + in_addr.sin6_len = sizeof(in_addr); | |
1880 | #endif | |
1881 | - in_addr.sin_family = AF_INET; | |
1882 | - in_addr.sin_port = htons ((short) XDM_UDP_PORT); | |
1883 | - if (address->length != 4) | |
1884 | + in_addr.sin6_family = AF_INET6; | |
1885 | + in_addr.sin6_flowinfo = 0; | |
1886 | + in_addr.sin6_port = htons ((short) XDM_UDP_PORT); | |
1887 | + if (address->length != 16) | |
1888 | return; | |
1889 | - memmove( (char *) &in_addr.sin_addr, address->data, address->length); | |
1890 | - addrlen = sizeof (struct sockaddr_in); | |
1891 | + memmove( (char *) &in_addr.sin6_addr, address->data, address->length); | |
1892 | + addrlen = sizeof (struct sockaddr_in6); | |
1893 | break; | |
1894 | #endif | |
1895 | #ifdef AF_DECnet | |
1896 | @@ -287,7 +290,7 @@ | |
1897 | ProcessRequestSocket () | |
1898 | { | |
1899 | XdmcpHeader header; | |
1900 | - struct sockaddr_in addr; | |
1901 | + struct sockaddr_in6 addr; | |
1902 | int addrlen = sizeof addr; | |
1903 | #ifdef MINIX | |
1904 | int r; | |
1905 | @@ -486,7 +489,8 @@ | |
1906 | ||
1907 | data = connectionAddress->data; | |
1908 | hostent = gethostbyaddr ((char *)data, | |
1909 | - connectionAddress->length, AF_INET); | |
1910 | + connectionAddress->length, | |
1911 | + connectionAddress->length == 4 ? AF_INET : AF_INET6); | |
1912 | if (sourceAddress && hostent) { | |
1913 | #if defined(__SVR4) && defined(__sun) | |
1914 | /* | |
1915 | @@ -546,11 +550,34 @@ | |
1916 | } | |
1917 | else | |
1918 | { | |
1919 | + if (multiHomed) { | |
1920 | + if (((struct sockaddr_in *) | |
1921 | + originalAddress)->sin_family == AF_INET) { | |
1922 | + data = (CARD8 *) &((struct sockaddr_in *) | |
1923 | + originalAddress)->sin_addr.s_addr; | |
1924 | + goto v4; | |
1925 | + } | |
1926 | + data = (CARD8 *) &((struct sockaddr_in6 *) | |
1927 | + originalAddress)->sin6_addr; | |
1928 | + goto v6; | |
1929 | + } | |
1930 | + if (connectionAddress->length == sizeof (struct in6_addr)) { | |
1931 | + v6: | |
1932 | + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)data)) { | |
1933 | + data += sizeof(struct in6_addr)-sizeof(struct in_addr); | |
1934 | + goto v4; | |
1935 | + } | |
1936 | + if (!getString (name, INET6_ADDRSTRLEN+6)) | |
1937 | + return 0; | |
1938 | + (void) inet_ntop(AF_INET6, data, name, INET6_ADDRSTRLEN); | |
1939 | + sprintf(name+strlen(name), ":%d", displayNumber); | |
1940 | + return name; | |
1941 | + } | |
1942 | + if (connectionAddress->length != 4) | |
1943 | + return 0; | |
1944 | + v4: | |
1945 | if (!getString (name, 25)) | |
1946 | return 0; | |
1947 | - if (multiHomed) | |
1948 | - data = (CARD8 *) &((struct sockaddr_in *)originalAddress)-> | |
1949 | - sin_addr.s_addr; | |
1950 | sprintf(name, "%d.%d.%d.%d:%d", | |
1951 | data[0], data[1], data[2], data[3], displayNumber); | |
1952 | } | |
1953 | @@ -631,6 +658,29 @@ | |
1954 | } | |
1955 | break; | |
1956 | #endif | |
1957 | +#ifdef AF_INET6 | |
1958 | + case AF_INET6: | |
1959 | + { | |
1960 | + struct sockaddr_in6 in_addr; | |
1961 | + | |
1962 | + if (clientAddress.length != 16 || | |
1963 | + clientPort.length != 2) | |
1964 | + { | |
1965 | + goto badAddress; | |
1966 | + } | |
1967 | + bzero ((char *) &in_addr, sizeof (in_addr)); | |
1968 | +#ifdef BSD44SOCKETS | |
1969 | + in_addr.sin6_len = sizeof(in_addr); | |
1970 | +#endif | |
1971 | + in_addr.sin6_family = AF_INET6; | |
1972 | + in_addr.sin6_flowinfo = 0; | |
1973 | + memmove( &in_addr.sin6_addr, clientAddress.data, 16); | |
1974 | + memmove( (char *) &in_addr.sin6_port, clientPort.data, 2); | |
1975 | + client = (struct sockaddr *) &in_addr; | |
1976 | + clientlen = sizeof (in_addr); | |
1977 | + } | |
1978 | + break; | |
1979 | +#endif | |
1980 | #ifdef AF_UNIX | |
1981 | case AF_UNIX: | |
1982 | { | |
1983 | @@ -1199,11 +1249,14 @@ | |
1984 | char *local_name; | |
1985 | ||
1986 | hostent = gethostbyaddr ((char *)connectionAddress->data, | |
1987 | - connectionAddress->length, AF_INET); | |
1988 | + connectionAddress->length, | |
1989 | + connectionAddress->length == 4 ? AF_INET : AF_INET6); | |
1990 | ||
1991 | if (hostent) | |
1992 | local_name = hostent->h_name; | |
1993 | else { | |
1994 | + if (connectionAddress->length != 4) | |
1995 | + break; | |
1996 | /* can't get name, so use emergency fallback */ | |
1997 | sprintf(dotted, "%d.%d.%d.%d", | |
1998 | connectionAddress->data[0], | |
a6284aab AF |
1999 | --- XFree86-3.3.3.1/xc/programs/xfs/difs/main.c.ipv6 Thu Jun 24 12:39:41 1999 |
2000 | +++ XFree86-3.3.3.1/xc/programs/xfs/difs/main.c Thu Jun 24 12:39:47 1999 | |
2001 | @@ -60,6 +60,10 @@ | |
047d95d5 | 2002 | #include "site.h" |
a6284aab | 2003 | #include <unistd.h> |
047d95d5 AF |
2004 | |
2005 | +#include <sys/types.h> | |
2006 | +#include <netinet/in.h> | |
2007 | +#include <resolv.h> | |
2008 | + | |
2009 | char *ConnectionInfo; | |
2010 | int ConnInfoLen; | |
2011 | ||
a6284aab | 2012 | @@ -94,6 +98,10 @@ |
047d95d5 AF |
2013 | |
2014 | argcGlobal = argc; | |
2015 | argvGlobal = argv; | |
2016 | + | |
2017 | + if ((_res.options & RES_INIT) == 0) | |
2018 | + (void)res_init(); | |
2019 | + _res.options |= RES_USE_INET6; | |
2020 | ||
2021 | configfilename = DEFAULT_CONFIG_FILE; | |
2022 | ||
a6284aab AF |
2023 | --- XFree86-3.3.3.1/xc/programs/xfs/os/access.c.ipv6 Sat Jan 18 08:02:45 1997 |
2024 | +++ XFree86-3.3.3.1/xc/programs/xfs/os/access.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
2025 | @@ -93,7 +93,7 @@ |
2026 | char hname[64]; | |
2027 | struct hostent *hp; | |
2028 | ||
2029 | - addr->addr_len = sizeof(struct in_addr); | |
2030 | + addr->addr_len = sizeof(struct in6_addr); | |
2031 | addr->address = (pointer) fsalloc(addr->addr_len); | |
2032 | if (!addr->address) | |
2033 | return FSBadAlloc; | |
a6284aab AF |
2034 | --- XFree86-3.3.3.1/xc/programs/xfwp/xfwp.c.ipv6 Fri Jan 23 00:53:25 1998 |
2035 | +++ XFree86-3.3.3.1/xc/programs/xfwp/xfwp.c Thu Jun 24 14:22:13 1999 | |
047d95d5 AF |
2036 | @@ -57,6 +57,7 @@ |
2037 | #endif | |
2038 | #include <sys/wait.h> | |
2039 | #include <netdb.h> | |
2040 | +#include <resolv.h> | |
2041 | #if defined(_ANSI_SOURCE) && defined(__bsdi__) | |
2042 | #undef _ANSI_SOURCE | |
2043 | #include <signal.h> | |
2044 | @@ -163,13 +164,13 @@ | |
2045 | main (int argc, char * argv[]) | |
2046 | { | |
2047 | struct clientDataStruct client_data; | |
2048 | - struct sockaddr_in dest_server; | |
2049 | + struct sockaddr_in6 dest_server; | |
2050 | struct pm_policy policy; | |
2051 | int pm_listen_array[MAX_TRANSPORTS]; | |
2052 | int pm_conn_counter; | |
2053 | - struct sockaddr_in pm_sockaddr_in; | |
2054 | + struct sockaddr_in6 pm_sockaddr_in6; | |
2055 | int rem_listen_counter; | |
2056 | - struct sockaddr_in rem_sockaddr_in; | |
2057 | + struct sockaddr_in6 rem_sockaddr_in6; | |
2058 | fd_set readable, writable, rinit, winit; | |
2059 | int nfds = 0; | |
2060 | int nready = 0; | |
2061 | @@ -196,6 +197,10 @@ | |
2062 | /* | |
2063 | // now do the rest of the setup | |
2064 | */ | |
2065 | + if ((_res.options & RES_INIT) == 0) | |
2066 | + (void) res_init(); | |
2067 | + _res.options |= RES_USE_INET6; | |
2068 | + | |
2069 | doProcessInputArgs(config_info, argc, argv); | |
2070 | if ((config_status = doHandleConfigFile(config_info)) == FAILURE) | |
2071 | exit(1); | |
2072 | @@ -515,7 +520,7 @@ | |
2073 | { | |
2074 | int this_server; | |
2075 | int one = 1; | |
2076 | - struct sockaddr_in rem_sockaddr_in; | |
2077 | + struct sockaddr_in6 rem_sockaddr_in6; | |
2078 | int port_counter; | |
2079 | int listen_port; | |
2080 | char port_buff[10]; | |
2081 | @@ -578,7 +583,7 @@ | |
2082 | return FAILURE; | |
2083 | } | |
2084 | if ((server_array[this_server]->client_listen_fd = | |
2085 | - socket(AF_INET, SOCK_STREAM, 0)) < 0) | |
2086 | + socket(AF_INET6, SOCK_STREAM, 0)) < 0) | |
2087 | { | |
2088 | #ifdef DEBUG | |
2089 | fprintf(stderr,"doRemClientSetup: socket() call failed!"); | |
a6284aab | 2090 | @@ -599,8 +604,10 @@ |
047d95d5 AF |
2091 | /* |
2092 | // set up the rest of the remote client listener | |
2093 | */ | |
2094 | - bzero((char * ) &rem_sockaddr_in, sizeof(rem_sockaddr_in)); | |
2095 | - rem_sockaddr_in.sin_family = AF_INET; | |
2096 | + bzero((char * ) &rem_sockaddr_in6, sizeof(rem_sockaddr_in6)); | |
2097 | + rem_sockaddr_in6.sin6_family = AF_INET6; | |
047d95d5 AF |
2098 | + rem_sockaddr_in6.sin6_flowinfo = 0; |
2099 | + rem_sockaddr_in6.sin6_addr = in6addr_any; | |
2100 | if (setsockopt(server_array[this_server]->client_listen_fd, | |
2101 | SOL_SOCKET, SO_REUSEADDR, | |
2102 | &one, sizeof(one)) < 0) | |
a6284aab | 2103 | @@ -617,10 +624,10 @@ |
047d95d5 AF |
2104 | } |
2105 | ||
2106 | while (True) { | |
2107 | - rem_sockaddr_in.sin_port = htons(listen_port); | |
2108 | + rem_sockaddr_in6.sin6_port = htons(listen_port); | |
2109 | if (bind(server_array[this_server]->client_listen_fd, | |
2110 | - (struct sockaddr *)&rem_sockaddr_in, | |
2111 | - sizeof(rem_sockaddr_in)) == 0) | |
2112 | + (struct sockaddr *)&rem_sockaddr_in6, | |
2113 | + sizeof(rem_sockaddr_in6)) == 0) | |
2114 | break; | |
2115 | if (errno != EADDRINUSE) | |
2116 | { | |
a6284aab | 2117 | @@ -1003,7 +1010,7 @@ |
047d95d5 AF |
2118 | int server_reason_len; |
2119 | int conn_auth_namelen, conn_auth_datalen; | |
2120 | char throw_away[RWBUFFER_SIZE]; | |
2121 | - struct sockaddr_in server_sockaddr_in; | |
2122 | + struct sockaddr_in6 server_sockaddr_in6; | |
2123 | enum CONFIG_CHECK server_status; | |
2124 | xConnClientPrefix client; | |
2125 | xConnSetupPrefix prefix; | |
a6284aab | 2126 | @@ -1039,10 +1046,10 @@ |
047d95d5 AF |
2127 | int check_sock_fd; |
2128 | struct timeval time_val; | |
2129 | struct timezone time_zone; | |
2130 | - struct sockaddr_in temp_sockaddr_in; | |
2131 | + struct sockaddr_in6 temp_sockaddr_in6; | |
2132 | int retval; | |
2133 | int config_check; | |
2134 | - int addrlen = sizeof(temp_sockaddr_in); | |
2135 | + int addrlen = sizeof(temp_sockaddr_in6); | |
2136 | /* | |
2137 | // start by accepting the connection if you can, use pm_listen_array | |
2138 | // index to index into ICE listen_object list (this is because the | |
a6284aab | 2139 | @@ -1061,17 +1068,17 @@ |
047d95d5 AF |
2140 | // connection; start by using getpeername() to get endpoint info |
2141 | */ | |
2142 | retval = getpeername(temp_sock_fd, | |
2143 | - (struct sockaddr*)&temp_sockaddr_in, | |
2144 | + (struct sockaddr*)&temp_sockaddr_in6, | |
2145 | &addrlen); | |
2146 | ||
2147 | - assert(temp_sockaddr_in.sin_family == AF_INET); | |
2148 | + assert(temp_sockaddr_in6.sin6_family == AF_INET6); | |
2149 | ||
2150 | /* | |
2151 | // then do the configuration check; NOTE: we're not doing anything | |
2152 | - // with the server_sockaddr_in argument | |
2153 | + // with the server_sockaddr_in6 argument | |
2154 | */ | |
2155 | - if ((config_check = doConfigCheck(&temp_sockaddr_in, | |
2156 | - &server_sockaddr_in, | |
2157 | + if ((config_check = doConfigCheck(&temp_sockaddr_in6, | |
2158 | + &server_sockaddr_in6, | |
2159 | config_info, | |
2160 | PMGR, | |
2161 | &log_data)) == FAILURE) | |
a6284aab | 2162 | @@ -1302,17 +1309,18 @@ |
047d95d5 AF |
2163 | // configuration, if connection allowed, allocate |
2164 | // the read/write buffer for this connection; | |
2165 | */ | |
2166 | - struct sockaddr_in temp_sockaddr_in; | |
2167 | - int temp_sock_fd; | |
2168 | - int temp_sock_len; | |
2169 | - int host_count; | |
2170 | - int config_check; | |
2171 | - struct timeval time_val; | |
2172 | - struct timezone time_zone; | |
2173 | + struct sockaddr_in6 temp_sockaddr_in6; | |
2174 | + int temp_sock_fd; | |
2175 | + int temp_sock_len; | |
2176 | + int host_count; | |
2177 | + int config_check; | |
2178 | + struct timeval time_val; | |
2179 | + struct timezone time_zone; | |
2180 | + char v1[64], v2[64]; | |
2181 | ||
2182 | - temp_sock_len = sizeof(temp_sockaddr_in); | |
2183 | + temp_sock_len = sizeof(temp_sockaddr_in6); | |
2184 | if ((temp_sock_fd = accept(fd_counter, | |
2185 | - (struct sockaddr *) &temp_sockaddr_in, | |
2186 | + (struct sockaddr *) &temp_sockaddr_in6, | |
2187 | &temp_sock_len)) < 0) | |
2188 | { | |
2189 | /* | |
a6284aab | 2190 | @@ -1336,7 +1344,7 @@ |
047d95d5 AF |
2191 | if ((server_status = |
2192 | doServerConnectSetup(server_array[listen_counter]->x_server_hostport, | |
2193 | &server_array[listen_counter]->server_fd, | |
2194 | - &server_sockaddr_in)) == FAILURE) | |
2195 | + &server_sockaddr_in6)) == FAILURE) | |
2196 | { | |
2197 | #ifdef DEBUG | |
2198 | fprintf(stderr, | |
a6284aab | 2199 | @@ -1346,7 +1354,7 @@ |
047d95d5 AF |
2200 | } |
2201 | if ((server_status = | |
2202 | doServerConnect(&server_array[listen_counter]->server_fd, | |
2203 | - &server_sockaddr_in)) == FAILURE) | |
2204 | + &server_sockaddr_in6)) == FAILURE) | |
2205 | { | |
2206 | #ifdef DEBUG | |
2207 | fprintf(stderr, | |
a6284aab | 2208 | @@ -1355,15 +1363,18 @@ |
047d95d5 AF |
2209 | return; |
2210 | } | |
2211 | /* | |
2212 | - // derive and save the client IP source and destination address strings | |
2213 | - // for logging purposes (have to do it here while we have them; even if | |
2214 | - // this client connection passes the config check, it might fail the | |
2215 | - // server security checks later); also, init the config_rule_num field | |
2216 | - */ | |
2217 | - log_data.source = Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr))); | |
2218 | - log_data.destination = Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr))); | |
2219 | - strcpy(log_data.source, inet_ntoa(temp_sockaddr_in.sin_addr)); | |
2220 | - strcpy(log_data.destination, inet_ntoa(server_sockaddr_in.sin_addr)); | |
2221 | + // derive and save the client IPv6 source and destination | |
2222 | + // address strings for logging purposes (have to do it here | |
2223 | + // while we have them; even if this client connection passes | |
2224 | + // the config check, it might fail the server security checks later); | |
2225 | + // also, init the config_rule_num field | |
2226 | + */ | |
2227 | + log_data.source = Malloc(strlen(inet_ntop(AF_INET6, | |
2228 | + &temp_sockaddr_in6.sin6_addr, v1, sizeof(v1)))); | |
2229 | + log_data.destination = Malloc(strlen(inet_ntop(AF_INET6, | |
2230 | + &server_sockaddr_in6.sin6_addr, v2, sizeof(v2)))); | |
2231 | + strcpy(log_data.source, v1); | |
2232 | + strcpy(log_data.destination, v2); | |
2233 | log_data.config_rule_num = -1; | |
2234 | /* | |
2235 | // do config check on client source and destination (must do | |
a6284aab | 2236 | @@ -1371,8 +1382,8 @@ |
047d95d5 AF |
2237 | // to query and we may not be able to resolve server name |
2238 | // alone from xfindproxy() | |
2239 | */ | |
2240 | - if ((config_check = doConfigCheck(&temp_sockaddr_in, | |
2241 | - &server_sockaddr_in, | |
2242 | + if ((config_check = doConfigCheck(&temp_sockaddr_in6, | |
2243 | + &server_sockaddr_in6, | |
2244 | config_info, | |
2245 | CLIENT, | |
2246 | &log_data)) == FAILURE) | |
a6284aab | 2247 | @@ -1454,13 +1465,13 @@ |
047d95d5 AF |
2248 | // server security extension or other loggable events) |
2249 | */ | |
2250 | client_conn_array[temp_sock_fd]->source = | |
2251 | - Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr))); | |
2252 | + Malloc(strlen(inet_ntop(AF_INET6, | |
2253 | + &temp_sockaddr_in6.sin6_addr, v1, sizeof(v1)))); | |
2254 | client_conn_array[temp_sock_fd]->destination = | |
2255 | - Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr))); | |
2256 | - strcpy(client_conn_array[temp_sock_fd]->source, | |
2257 | - inet_ntoa(temp_sockaddr_in.sin_addr)); | |
2258 | - strcpy(client_conn_array[temp_sock_fd]->destination, | |
2259 | - inet_ntoa(server_sockaddr_in.sin_addr)); | |
2260 | + Malloc(strlen(inet_ntop(AF_INET6, | |
2261 | + &server_sockaddr_in6.sin6_addr, v2, sizeof(v2)))); | |
2262 | + strcpy(client_conn_array[temp_sock_fd]->source, v1); | |
2263 | + strcpy(client_conn_array[temp_sock_fd]->destination, v2); | |
2264 | /* | |
2265 | // allocate a buffer for the X server connection | |
2266 | // and create the association between client and server | |
a6284aab | 2267 | @@ -1959,7 +1970,7 @@ |
047d95d5 AF |
2268 | fprintf(stderr, "Server replied AUTHENTICATE!\n"); |
2269 | #endif | |
2270 | /* | |
2271 | - // retrieve the client IP source and destination address strings | |
2272 | + // retrieve the client IPv6 source and destination address strings | |
2273 | */ | |
2274 | log_data.source = | |
2275 | Malloc(strlen | |
a6284aab | 2276 | @@ -2030,13 +2041,22 @@ |
047d95d5 AF |
2277 | }/* end if client_conn_array != NULL */ |
2278 | } | |
2279 | ||
2280 | -int doConfigCheck(struct sockaddr_in * source_sockaddr_in, | |
2281 | - struct sockaddr_in * dest_sockaddr_in, | |
2282 | +#define IN6ADDR_MATCH(x,m,y) \ | |
2283 | + match = 1; \ | |
2284 | + for (i = 0; i < sizeof(struct in6_addr) && (m).s6_addr[i] != 0; i++) \ | |
2285 | + if (((x).s6_addr[i] & (m).s6_addr[i]) != (y).s6_addr[i]) { \ | |
2286 | + match = 0; \ | |
2287 | + break; \ | |
2288 | + } | |
2289 | + | |
2290 | +int doConfigCheck(struct sockaddr_in6 * source_sockaddr_in6, | |
2291 | + struct sockaddr_in6 * dest_sockaddr_in6, | |
2292 | struct config * config_info, | |
2293 | int context, | |
2294 | struct log_struct * log_data) | |
2295 | { | |
2296 | int line_counter; | |
2297 | + int i, match; | |
2298 | /* | |
2299 | // look through the config file parse tree for a source IP address | |
2300 | // that matches this request | |
a6284aab | 2301 | @@ -2045,12 +2065,13 @@ |
047d95d5 AF |
2302 | { |
2303 | if (config_info->config_file_data[line_counter] != NULL) | |
2304 | { | |
2305 | - if ((source_sockaddr_in->sin_addr.s_addr & | |
2306 | - (~(config_info->config_file_data[line_counter]->source_net))) == | |
2307 | - config_info->config_file_data[line_counter]->source_host) | |
2308 | + IN6ADDR_MATCH(source_sockaddr_in6->sin6_addr, | |
2309 | + config_info->config_file_data[line_counter]->source_net, | |
2310 | + config_info->config_file_data[line_counter]->source_host); | |
2311 | + if (match) | |
2312 | { | |
2313 | /* | |
2314 | - // okay, the source host and netmask fields pass, see if the | |
2315 | + // okay, the source host and prefix length fields pass, see if the | |
2316 | // config file specifies "permit" or "deny" for this host | |
2317 | */ | |
2318 | if (!strcmp(config_info->config_file_data[line_counter]->permit_deny, | |
a6284aab | 2319 | @@ -2065,9 +2086,10 @@ |
047d95d5 AF |
2320 | /* |
2321 | // compute destination info restrictions | |
2322 | */ | |
2323 | - if ((dest_sockaddr_in->sin_addr.s_addr & | |
2324 | - (~(config_info->config_file_data[line_counter]->dest_net))) == | |
2325 | - config_info->config_file_data[line_counter]->dest_host) | |
2326 | + IN6ADDR_MATCH(dest_sockaddr_in6->sin6_addr, | |
2327 | + config_info->config_file_data[line_counter]->dest_net, | |
2328 | + config_info->config_file_data[line_counter]->dest_host); | |
2329 | + if (match) | |
2330 | { | |
2331 | /* | |
2332 | // you got a match on the destination, so look at | |
a6284aab | 2333 | @@ -2171,9 +2193,10 @@ |
047d95d5 AF |
2334 | /* |
2335 | // compute destination info restrictions | |
2336 | */ | |
2337 | - if ((dest_sockaddr_in->sin_addr.s_addr & | |
2338 | - (~(config_info->config_file_data[line_counter]->dest_net))) == | |
2339 | - config_info->config_file_data[line_counter]->dest_host) | |
2340 | + IN6ADDR_MATCH(dest_sockaddr_in6->sin6_addr, | |
2341 | + config_info->config_file_data[line_counter]->dest_net, | |
2342 | + config_info->config_file_data[line_counter]->dest_host); | |
2343 | + if (match) | |
2344 | { | |
2345 | /* | |
2346 | // you got a match on the destination, so look at | |
a6284aab | 2347 | @@ -2292,7 +2315,7 @@ |
047d95d5 AF |
2348 | if (config_info->config_file_path == NULL) |
2349 | { | |
2350 | if (printConfigVerify) | |
2351 | - fputs("matched default permit 0.0.0.0 255.255.255.255\n", stderr); | |
2352 | + fputs("matched default permit :: 0\n", stderr); | |
2353 | /* | |
2354 | // there's no rule match to save | |
2355 | */ | |
a6284aab | 2356 | @@ -2301,7 +2324,7 @@ |
047d95d5 AF |
2357 | } |
2358 | ||
2359 | if (printConfigVerify) | |
2360 | - fputs("matched default deny 0.0.0.0 255.255.255.255\n", stderr); | |
2361 | + fputs("matched default deny :: 0\n", stderr); | |
2362 | /* | |
2363 | // not in this case either | |
2364 | */ | |
a6284aab | 2365 | @@ -2395,8 +2418,8 @@ |
047d95d5 AF |
2366 | pmGetProxyAddrReplyMsg * pReply; |
2367 | char * pReplyData; | |
2368 | struct hostent * hostptr; | |
2369 | - struct sockaddr_in server_sockaddr_in; | |
2370 | - struct sockaddr_in dummy_sockaddr_in; | |
2371 | + struct sockaddr_in6 server_sockaddr_in6; | |
2372 | + struct sockaddr_in6 dummy_sockaddr_in6; | |
2373 | char * server_name_base; | |
2374 | int config_check; | |
2375 | char * config_failure = "unrecognized server or permission denied"; | |
a6284aab | 2376 | @@ -2497,9 +2520,9 @@ |
047d95d5 AF |
2377 | #endif |
2378 | goto sendFailure; | |
2379 | } | |
2380 | - memset(&server_sockaddr_in, 0, sizeof(server_sockaddr_in)); | |
2381 | - memset(&dummy_sockaddr_in, 0, sizeof(dummy_sockaddr_in)); | |
2382 | - memcpy((char *) &server_sockaddr_in.sin_addr, | |
2383 | + memset(&server_sockaddr_in6, 0, sizeof(server_sockaddr_in6)); | |
2384 | + memset(&dummy_sockaddr_in6, 0, sizeof(dummy_sockaddr_in6)); | |
2385 | + memcpy((char *) &server_sockaddr_in6.sin6_addr, | |
2386 | hostptr->h_addr, | |
2387 | hostptr->h_length); | |
2388 | ||
a6284aab | 2389 | @@ -2509,11 +2532,11 @@ |
047d95d5 AF |
2390 | // NOTE: source configuration will always match (see XFWP man |
2391 | // page) unless sysadmin explicitly chooses to deny | |
2392 | */ | |
2393 | - memcpy((char *) &dummy_sockaddr_in.sin_addr, | |
2394 | + memcpy((char *) &dummy_sockaddr_in6.sin6_addr, | |
2395 | hostptr->h_addr, | |
2396 | hostptr->h_length); | |
2397 | - if ((config_check = doConfigCheck(&dummy_sockaddr_in, | |
2398 | - &server_sockaddr_in, | |
2399 | + if ((config_check = doConfigCheck(&dummy_sockaddr_in6, | |
2400 | + &server_sockaddr_in6, | |
2401 | global_data.config_info, | |
2402 | FINDPROXY, | |
2403 | &log_data)) == FAILURE) | |
a6284aab | 2404 | @@ -2759,7 +2782,7 @@ |
047d95d5 AF |
2405 | |
2406 | int doServerConnectSetup(char * x_server_hostport, | |
2407 | int * server_connect_fd, | |
2408 | - struct sockaddr_in * server_sockaddr_in) | |
2409 | + struct sockaddr_in6 * server_sockaddr_in6) | |
2410 | { | |
2411 | struct hostent * hostptr; | |
2412 | char * server_name_base; | |
a6284aab | 2413 | @@ -2796,7 +2819,7 @@ |
047d95d5 AF |
2414 | #endif |
2415 | return; | |
2416 | } | |
2417 | - if ((*server_connect_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | |
2418 | + if ((*server_connect_fd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) | |
2419 | { | |
2420 | #ifdef DEBUG | |
2421 | fprintf(stderr, | |
a6284aab | 2422 | @@ -2805,20 +2828,20 @@ |
047d95d5 AF |
2423 | #endif |
2424 | return FAILURE; | |
2425 | } | |
2426 | - memset(server_sockaddr_in, 0, sizeof(*server_sockaddr_in)); | |
2427 | - server_sockaddr_in->sin_family = hostptr->h_addrtype; | |
2428 | - memcpy((char *) &server_sockaddr_in->sin_addr, | |
2429 | + memset(server_sockaddr_in6, 0, sizeof(*server_sockaddr_in6)); | |
2430 | + server_sockaddr_in6->sin6_family = hostptr->h_addrtype; | |
047d95d5 AF |
2431 | + memcpy((char *) &server_sockaddr_in6->sin6_addr, |
2432 | hostptr->h_addr, | |
2433 | hostptr->h_length); | |
2434 | - server_sockaddr_in->sin_port = htons(server_port); | |
2435 | + server_sockaddr_in6->sin6_port = htons(server_port); | |
2436 | return SUCCESS; | |
2437 | } | |
2438 | ||
2439 | int doServerConnect(int * server_connect_fd, | |
2440 | - struct sockaddr_in * server_sockaddr_in) | |
2441 | + struct sockaddr_in6 * server_sockaddr_in6) | |
2442 | { | |
2443 | - if(connect(*server_connect_fd, (struct sockaddr * )server_sockaddr_in, | |
2444 | - sizeof(*server_sockaddr_in)) < 0) | |
2445 | + if(connect(*server_connect_fd, (struct sockaddr * )server_sockaddr_in6, | |
2446 | + sizeof(*server_sockaddr_in6)) < 0) | |
2447 | { | |
2448 | #ifdef DEBUG | |
2449 | fprintf(stderr, | |
a6284aab | 2450 | @@ -3122,13 +3145,13 @@ |
047d95d5 AF |
2451 | |
2452 | config_lineP->permit_deny = NULL; | |
2453 | config_lineP->source_hostname = NULL; | |
2454 | - config_lineP->source_host = 0; | |
2455 | - config_lineP->source_netmask = NULL; | |
2456 | - config_lineP->source_net = 0; | |
2457 | + bzero((char *)&config_lineP->source_host, sizeof(struct in6_addr)); | |
2458 | + config_lineP->source_preflen = NULL; | |
2459 | + bzero((char *)&config_lineP->source_net, sizeof(struct in6_addr)); | |
2460 | config_lineP->dest_hostname = NULL; | |
2461 | - config_lineP->dest_host = 0; | |
2462 | - config_lineP->dest_netmask = NULL; | |
2463 | - config_lineP->dest_net = 0; | |
2464 | + bzero((char *)&config_lineP->dest_host, sizeof(struct in6_addr)); | |
2465 | + config_lineP->dest_preflen = NULL; | |
2466 | + bzero((char *)&config_lineP->dest_net, sizeof(struct in6_addr)); | |
2467 | config_lineP->operator = NULL; | |
2468 | config_lineP->service = NULL; | |
2469 | ||
a6284aab | 2470 | @@ -3200,7 +3223,7 @@ |
047d95d5 AF |
2471 | { |
2472 | char token[64]; | |
2473 | strcpy(token, result); | |
2474 | - if (doVerifyHostMaskToken(token)) | |
2475 | + if (doVerifyHostToken(token)) | |
2476 | { | |
2477 | if ((config_file_data[line_number]->source_hostname = | |
2478 | (char *) malloc (strlen(result) + 1)) == NULL) | |
a6284aab | 2479 | @@ -3219,22 +3242,24 @@ |
047d95d5 AF |
2480 | /* |
2481 | // generate network address format | |
2482 | */ | |
2483 | - config_file_data[line_number]->source_host = | |
2484 | - inet_addr(config_file_data[line_number]->source_hostname); | |
2485 | + inet_pton(AF_INET6, | |
2486 | + config_file_data[line_number]->source_hostname, | |
2487 | + &config_file_data[line_number]->source_host); | |
2488 | } else | |
2489 | bad_token = 1; | |
2490 | } | |
2491 | ||
2492 | /* | |
2493 | - // now the source netmask field | |
2494 | + // now the source prefix length field | |
2495 | */ | |
2496 | if ((result = strtok(NULL, SEPARATOR1)) != NULL) | |
2497 | { | |
2498 | char token[64]; | |
2499 | + int plen, j; | |
2500 | strcpy(token, result); | |
2501 | - if (doVerifyHostMaskToken(token)) | |
2502 | + if (doVerifyMaskToken(token)) | |
2503 | { | |
2504 | - if ((config_file_data[line_number]->source_netmask = | |
2505 | + if ((config_file_data[line_number]->source_preflen = | |
2506 | (char *) malloc (strlen(result) + 1)) == NULL) | |
2507 | { | |
2508 | #ifdef DEBUG | |
a6284aab | 2509 | @@ -3242,14 +3267,18 @@ |
047d95d5 AF |
2510 | #endif |
2511 | return 0; | |
2512 | } | |
2513 | - strcpy(config_file_data[line_number]->source_netmask, result); | |
2514 | + strcpy(config_file_data[line_number]->source_preflen, result); | |
2515 | #ifdef DEBUG | |
2516 | fprintf(stderr, | |
2517 | "third token = %s\n", | |
2518 | - config_file_data[line_number]->source_netmask); | |
2519 | + config_file_data[line_number]->source_preflen); | |
2520 | #endif | |
2521 | - config_file_data[line_number]->source_net = | |
2522 | - inet_addr(config_file_data[line_number]->source_netmask); | |
2523 | + plen = atoi(config_file_data[line_number]->source_preflen); | |
2524 | + for (j = 0; plen >= 8; plen -= 8, j++) | |
2525 | + config_file_data[line_number]->source_net.s6_addr[j] = 0xff; | |
2526 | + if (plen != 0) | |
2527 | + config_file_data[line_number]->source_net.s6_addr[j] = | |
2528 | + 0xff << (8 - plen); | |
2529 | } else | |
2530 | bad_token = 1; | |
2531 | } | |
a6284aab | 2532 | @@ -3260,7 +3289,7 @@ |
047d95d5 AF |
2533 | { |
2534 | char token[64]; | |
2535 | strcpy(token, result); | |
2536 | - if (doVerifyHostMaskToken(token)) | |
2537 | + if (doVerifyHostToken(token)) | |
2538 | { | |
2539 | if ((config_file_data[line_number]->dest_hostname = | |
2540 | (char *) malloc (strlen(result) + 1)) == NULL) | |
a6284aab | 2541 | @@ -3276,21 +3305,23 @@ |
047d95d5 AF |
2542 | "fourth token = %s\n", |
2543 | config_file_data[line_number]->dest_hostname); | |
2544 | #endif | |
2545 | - config_file_data[line_number]->dest_host = | |
2546 | - inet_addr(config_file_data[line_number]->dest_hostname); | |
2547 | + inet_pton(AF_INET6, | |
2548 | + config_file_data[line_number]->dest_hostname, | |
2549 | + &config_file_data[line_number]->dest_host); | |
2550 | } else | |
2551 | bad_token = 1; | |
2552 | } | |
2553 | /* | |
2554 | - // now the destination netmask field | |
2555 | + // now the destination prefix length field | |
2556 | */ | |
2557 | if ((result = strtok(NULL, SEPARATOR1)) != NULL) | |
2558 | { | |
2559 | char token[64]; | |
2560 | + int plen, j; | |
2561 | strcpy(token, result); | |
2562 | - if (doVerifyHostMaskToken(token)) | |
2563 | + if (doVerifyMaskToken(token)) | |
2564 | { | |
2565 | - if ((config_file_data[line_number]->dest_netmask = | |
2566 | + if ((config_file_data[line_number]->dest_preflen = | |
2567 | (char *) malloc (strlen(result) + 1)) == NULL) | |
2568 | { | |
2569 | #ifdef DEBUG | |
a6284aab | 2570 | @@ -3298,14 +3329,18 @@ |
047d95d5 AF |
2571 | #endif |
2572 | return 0; | |
2573 | } | |
2574 | - strcpy(config_file_data[line_number]->dest_netmask, result); | |
2575 | + strcpy(config_file_data[line_number]->dest_preflen, result); | |
2576 | #ifdef DEBUG | |
2577 | fprintf(stderr, | |
2578 | "fifth token = %s\n", | |
2579 | - config_file_data[line_number]->dest_netmask); | |
2580 | + config_file_data[line_number]->dest_preflen); | |
2581 | #endif | |
2582 | - config_file_data[line_number]->dest_net = | |
2583 | - inet_addr(config_file_data[line_number]->dest_netmask); | |
2584 | + plen = atoi(config_file_data[line_number]->dest_preflen); | |
2585 | + for (j = 0; plen >= 8; plen -= 8, j++) | |
2586 | + config_file_data[line_number]->dest_net.s6_addr[j] = 0xff; | |
2587 | + if (plen != 0) | |
2588 | + config_file_data[line_number]->dest_net.s6_addr[j] = | |
2589 | + 0xff << (8 - plen); | |
2590 | } else | |
2591 | bad_token = 1; | |
2592 | } | |
a6284aab | 2593 | @@ -3377,9 +3412,9 @@ |
047d95d5 AF |
2594 | ((config_file_data[line_number]->permit_deny != NULL) && |
2595 | (config_file_data[line_number]->source_hostname == NULL)) || | |
2596 | ((config_file_data[line_number]->source_hostname != NULL) && | |
2597 | - (config_file_data[line_number]->source_netmask == NULL)) || | |
2598 | + (config_file_data[line_number]->source_preflen == NULL)) || | |
2599 | ((config_file_data[line_number]->dest_hostname != NULL) && | |
2600 | - (config_file_data[line_number]->dest_netmask == NULL)) || | |
2601 | + (config_file_data[line_number]->dest_preflen == NULL)) || | |
2602 | ((config_file_data[line_number]->operator != NULL) && | |
2603 | (config_file_data[line_number]->service == NULL))) | |
2604 | return 1; | |
a6284aab | 2605 | @@ -3388,27 +3423,23 @@ |
047d95d5 AF |
2606 | return 0; |
2607 | } | |
2608 | ||
2609 | -int doVerifyHostMaskToken(char token[]) | |
2610 | +int doVerifyHostToken(char token[]) | |
2611 | { | |
2612 | - char * result; | |
2613 | - int delimiter_count = 0; | |
2614 | + struct in6_addr addr; | |
2615 | /* | |
2616 | - // verify there are 3 "." delimiters in the token | |
2617 | + // verify it is a real IPv6 address | |
2618 | */ | |
2619 | - while (token) | |
2620 | - { | |
2621 | - if ((result = strchr(token, SEPARATOR2)) != NULL) | |
2622 | - { | |
2623 | - token = result; | |
2624 | - delimiter_count++; | |
2625 | - token ++; | |
2626 | - } else | |
2627 | - token = result; | |
2628 | - } | |
2629 | - if ((delimiter_count < 3) || (delimiter_count > 3)) | |
2630 | - return 0; | |
2631 | - else | |
2632 | - return 1; | |
2633 | + return (inet_pton(AF_INET6, token, &addr) > 0); | |
2634 | +} | |
2635 | + | |
2636 | +int doVerifyMaskToken(char token[]) | |
2637 | +{ | |
2638 | + int plen; | |
2639 | + /* | |
2640 | + // verify it is a legal prefix length | |
2641 | + */ | |
2642 | + plen = atoi(token); | |
2643 | + return ((plen >= 0) && (plen <= 128)); | |
2644 | } | |
2645 | ||
2646 | void BadSyntax(char *msg, int line) | |
a6284aab | 2647 | @@ -3483,8 +3514,8 @@ |
047d95d5 AF |
2648 | struct config_line *ruleP = config_info->config_file_data[line_counter]; |
2649 | fprintf(stderr,"matched: %s %s %s %s %s %s %s\n", | |
2650 | ruleP->permit_deny, | |
2651 | - ruleP->source_hostname, ruleP->source_netmask, | |
2652 | - ruleP->dest_hostname, ruleP->dest_netmask, | |
2653 | + ruleP->source_hostname, ruleP->source_preflen, | |
2654 | + ruleP->dest_hostname, ruleP->dest_preflen, | |
2655 | ruleP->operator, | |
2656 | ruleP->service); | |
2657 | } | |
a6284aab AF |
2658 | --- XFree86-3.3.3.1/xc/programs/xfwp/xfwp.h.ipv6 Wed Jun 11 14:09:00 1997 |
2659 | +++ XFree86-3.3.3.1/xc/programs/xfwp/xfwp.h Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
2660 | @@ -61,7 +61,7 @@ |
2661 | /* allocate ADD_LINES entries at a time when loading the configuration */ | |
2662 | #define ADD_LINES 20 | |
2663 | #define SEPARATOR1 " \t\n" | |
2664 | -#define SEPARATOR2 '.' | |
2665 | +#define SEPARATOR2 ':' | |
2666 | ||
2667 | #define min(a,b) ((a) < (b) ? (a) : (b)) | |
2668 | #define max(a,b) ((a) > (b) ? (a) : (b)) | |
2669 | @@ -194,13 +194,13 @@ | |
2670 | { | |
2671 | char * permit_deny; | |
2672 | char * source_hostname; | |
2673 | - unsigned int source_host; | |
2674 | - char * source_netmask; | |
2675 | - unsigned int source_net; | |
2676 | + struct in6_addr source_host; | |
2677 | + char * source_preflen; | |
2678 | + struct in6_addr source_net; | |
2679 | char * dest_hostname; | |
2680 | - unsigned int dest_host; | |
2681 | - char * dest_netmask; | |
2682 | - unsigned int dest_net; | |
2683 | + struct in6_addr dest_host; | |
2684 | + char * dest_preflen; | |
2685 | + struct in6_addr dest_net; | |
2686 | char * operator; | |
2687 | char * service; | |
2688 | int service_id; | |
2689 | @@ -303,8 +303,8 @@ | |
2690 | struct client_conn_buf * client_conn_array[], | |
2691 | struct ice_data * ice_data); | |
2692 | ||
2693 | -int doConfigCheck(struct sockaddr_in * temp_sockaddr_in, | |
2694 | - struct sockaddr_in * server_sockaddr_in, | |
2695 | +int doConfigCheck(struct sockaddr_in6 * temp_sockaddr_in6, | |
2696 | + struct sockaddr_in6 * server_sockaddr_in6, | |
2697 | struct config * config_info, | |
2698 | int context, | |
2699 | struct log_struct * log_data); | |
2700 | @@ -337,10 +337,10 @@ | |
2701 | ||
2702 | int doServerConnectSetup(char * x_server_hostport, | |
2703 | int * server_connect_fd, | |
2704 | - struct sockaddr_in * server_addr_in); | |
2705 | + struct sockaddr_in6 * server_addr_in6); | |
2706 | ||
2707 | int doServerConnect(int * server_connect_fd, | |
2708 | - struct sockaddr_in * server_addr_in); | |
2709 | + struct sockaddr_in6 * server_addr_in6); | |
2710 | ||
2711 | int doProcessLine(char *line, | |
2712 | struct config * config_info, | |
2713 | @@ -352,7 +352,9 @@ | |
2714 | ||
2715 | Bool doConfigRequireDisallow(int, char*); | |
2716 | ||
2717 | -int doVerifyHostMaskToken(char token[]); | |
2718 | +int doVerifyHostToken(char token[]); | |
2719 | + | |
2720 | +int doVerifyMaskToken(char token[]); | |
2721 | ||
2722 | void doInstallIOErrorHandler(); | |
2723 | ||
a6284aab AF |
2724 | --- XFree86-3.3.3.1/xc/programs/xfwp/xfwp.man.ipv6 Tue Dec 24 11:04:47 1996 |
2725 | +++ XFree86-3.3.3.1/xc/programs/xfwp/xfwp.man Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
2726 | @@ -206,7 +206,7 @@ |
2727 | packet-filtering routers. It contains zero or more source-destination | |
2728 | rules of the following form: | |
2729 | .PP | |
2730 | -[#]{permit | deny} <src> <src mask> [<dest> <dest mask> [<operator> <service>]] | |
2731 | +[#]{permit | deny} <src> <src len> [<dest> <dest len> [<operator> <service>]] | |
2732 | .sp | |
2733 | .IP # 12 | |
2734 | comment delimiter; evaluator will skip these lines | |
2735 | @@ -214,21 +214,21 @@ | |
2736 | the keywords ``permit'' or ``deny'' indicate whether the | |
2737 | rule will enable or disable access, respectively | |
2738 | .IP src 12 | |
2739 | -the IP address against the host who originated the | |
2740 | -connection request will be matched, expressed in IP | |
2741 | -format (x.x.x.x) | |
2742 | -.IP "src mask" 12 | |
2743 | -a subnet mask, also in IP format, for further qualifying | |
2744 | -the source mask. Bits set in the mask indicate bits of the | |
2745 | +the IPv6 address against the host who originated the | |
2746 | +connection request will be matched, expressed in IPv6 | |
2747 | +format (x:x:x:x:x:x:x:x) | |
2748 | +.IP "src len" 12 | |
2749 | +a prefix length, a number between 0 and 128, for further qualifying | |
2750 | +the source prefix. Bits after the prefix indicate bits of the | |
2751 | incoming address to be \fIignored\fP when comparing to the specified src | |
2752 | .IP dest 12 | |
2753 | -the IP address against which the destination of the | |
2754 | -incoming connection request (i.e. the host IP of the | |
2755 | +the IPv6 address against which the destination of the | |
2756 | +incoming connection request (i.e. the host IPv6 of the | |
2757 | X server to which the incoming client is attempting to | |
2758 | connect) will be matched | |
2759 | -.IP "dest mask" 12 | |
2760 | -a subnet mask, also in IP format, for further qualifying | |
2761 | -the destination mask. Bits set in the mask indicate bits of the | |
2762 | +.IP "dest len" 12 | |
2763 | +a prefix length, a number between 0 and 128, for further qualifying | |
2764 | +the destination prefix. Bits after the prefix indicate bits of the | |
2765 | destination address to be \fIignored\fP when comparing to the specified dest | |
2766 | .IP operator 12 | |
2767 | always ``eq'' (if the service field is not NULL) | |
2768 | @@ -267,8 +267,8 @@ | |
2769 | .RS 3 | |
2770 | while (more entries to check) | |
2771 | { | |
2772 | - if ((<originator IP> AND (NOT <src mask>)) == src) | |
2773 | - [if ((<dest X server IP> AND (NOT <dest mask>)) == dest)] | |
2774 | + if ((<originator IPv6> AND (<src prefix>)) == src) | |
2775 | + [if ((<dest X server IPv6> AND (<dest prefix>)) == dest)] | |
2776 | [if (service fields present and matching)] | |
2777 | do either permit or deny connection depending on keyword | |
2778 | else | |
2779 | @@ -312,22 +312,22 @@ | |
2780 | require policy1 | |
2781 | require policy2 | |
2782 | # | |
2783 | -# deny pm connections originating on 8.7.6.5 [NOTE: If pm service | |
2784 | +# deny pm connections originating on 8:7:6:5:4:3:2:1 [NOTE: If pm service | |
2785 | # is explicitly qualified, line must include destination fields as | |
2786 | # shown.] | |
2787 | # | |
2788 | -deny 8.7.6.5 0.0.0.0 0.0.0.0 255.255.255.255 eq pm | |
2789 | +deny 8:7:6:5:4:3:2:1 128 :: 0 eq pm | |
2790 | # | |
2791 | # permit xfindproxy X server connects to anywhere [NOTE: If | |
2792 | # fp service is explicitly qualified, line must include source fields | |
2793 | # as shown.] | |
2794 | # | |
2795 | -permit 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 eq fp | |
2796 | +permit :: 0 :: 0 eq fp | |
2797 | # | |
2798 | -# permit all connection types originating from the 192.0.0.0 | |
2799 | -# IP domain only | |
2800 | +# permit all connection types originating from the fec0::/10 | |
2801 | +# IPv6 domain only | |
2802 | # | |
2803 | -permit 192.0.0.0 0.255.255.255 | |
2804 | +permit fec0:: 10 | |
2805 | .fi | |
2806 | \fP | |
2807 | .PP | |
a6284aab AF |
2808 | --- XFree86-3.3.3.1/xc/programs/xhost/xhost.c.ipv6 Sun Sep 13 15:15:59 1998 |
2809 | +++ XFree86-3.3.3.1/xc/programs/xhost/xhost.c Thu Jun 24 12:39:47 1999 | |
047d95d5 AF |
2810 | @@ -75,6 +75,7 @@ |
2811 | #endif | |
2812 | #include <netdb.h> | |
2813 | #include <netinet/in.h> | |
2814 | +#include <resolv.h> | |
2815 | #else | |
2816 | #include <server/ip/gen/socket.h> | |
2817 | #include <server/ip/types.h> | |
2818 | @@ -153,6 +154,9 @@ | |
2819 | #ifdef AF_INET | |
2820 | { AF_INET, FamilyInternet }, | |
2821 | #endif | |
2822 | +#ifdef AF_INET6 | |
2823 | + { AF_INET6, FamilyInternet }, | |
2824 | +#endif | |
2825 | }; | |
2826 | ||
2827 | #define FAMILIES ((sizeof familyMap)/(sizeof familyMap[0])) | |
2828 | @@ -184,6 +188,12 @@ | |
2829 | ||
2830 | ProgramName = argv[0]; | |
2831 | ||
2832 | +#ifdef NEEDSOCKETS | |
2833 | + if ((_res.options & RES_INIT) == 0) | |
2834 | + (void)res_init(); | |
2835 | + _res.options |= RES_USE_INET6; | |
2836 | +#endif | |
2837 | + | |
2838 | if ((dpy = XOpenDisplay(NULL)) == NULL) { | |
2839 | fprintf(stderr, "%s: unable to open display \"%s\"\n", | |
2840 | ProgramName, XDisplayName (NULL)); | |
2841 | @@ -308,7 +318,7 @@ | |
2842 | #endif | |
2843 | #ifdef NEEDSOCKETS | |
2844 | #ifndef AMTCPCONN | |
2845 | - static struct in_addr addr; /* so we can point at it */ | |
2846 | + static struct in6_addr addr; /* so we can point at it */ | |
2847 | #else | |
2848 | static ipaddr_t addr; | |
2849 | #endif | |
2850 | @@ -484,41 +494,30 @@ | |
2851 | } | |
2852 | #ifdef NEEDSOCKETS | |
2853 | /* | |
2854 | - * First see if inet_addr() can grok the name; if so, then use it. | |
2855 | - */ | |
2856 | -#ifndef AMTCPCONN | |
2857 | - if ((addr.s_addr = inet_addr(name)) != -1) { | |
2858 | -#else | |
2859 | - if ((addr = inet_addr(name)) != -1) { | |
2860 | -#endif | |
2861 | - ha.family = FamilyInternet; | |
2862 | - ha.length = 4; /* but for Cray would be sizeof(addr.s_addr) */ | |
2863 | - ha.address = (char *)&addr; /* but for Cray would be &addr.s_addr */ | |
2864 | - if (add) { | |
2865 | - XAddHost (dpy, &ha); | |
2866 | - printf ("%s %s\n", name, add_msg); | |
2867 | - } else { | |
2868 | - XRemoveHost (dpy, &ha); | |
2869 | - printf ("%s %s\n", name, remove_msg); | |
2870 | - } | |
2871 | - return 1; | |
2872 | - } | |
2873 | - /* | |
2874 | + * (gethostbyname knows how to handle litterals...) | |
2875 | * Is it in the namespace? | |
2876 | */ | |
2877 | - else if (((hp = gethostbyname(name)) == (struct hostent *)NULL) | |
2878 | - || hp->h_addrtype != AF_INET) { | |
2879 | + if (((hp = gethostbyname(name)) == (struct hostent *)NULL) | |
2880 | + || hp->h_addrtype != AF_INET6) { | |
2881 | return 0; | |
2882 | } else { | |
2883 | ha.family = XFamily(hp->h_addrtype); | |
2884 | - ha.length = hp->h_length; | |
2885 | #ifdef h_addr /* new 4.3bsd version of gethostent */ | |
2886 | { | |
2887 | char **list; | |
2888 | ||
2889 | /* iterate over the hosts */ | |
2890 | for (list = hp->h_addr_list; *list; list++) { | |
2891 | + ha.length = hp->h_length; | |
2892 | ha.address = *list; | |
2893 | +#ifdef UNMAPPED_IPV4 | |
2894 | + if ((ha.family == FamilyInternet) && | |
2895 | + (ha.length == sizeof(struct in6_addr)) && | |
2896 | + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ha.address)) { | |
2897 | + ha.length = sizeof(struct in_addr); | |
2898 | + ha.address += sizeof(struct in6_addr) - sizeof(struct in_addr); | |
2899 | + } | |
2900 | +#endif | |
2901 | if (add) { | |
2902 | XAddHost (dpy, &ha); | |
2903 | } else { | |
2904 | @@ -527,7 +526,16 @@ | |
2905 | } | |
2906 | } | |
2907 | #else | |
2908 | + ha.length = hp->h_length; | |
2909 | ha.address = hp->h_addr; | |
2910 | +#ifdef UNMAPPED_IPV4 | |
2911 | + if ((ha.family == FamilyInternet) && | |
2912 | + (ha.length == sizeof(struct in6_addr)) && | |
2913 | + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ha.address)) { | |
2914 | + ha.length = sizeof(struct in_addr); | |
2915 | + ha.address += sizeof(struct in6_addr) - sizeof(struct in_addr); | |
2916 | + } | |
2917 | +#endif | |
2918 | if (add) { | |
2919 | XAddHost (dpy, &ha); | |
2920 | } else { | |
2921 | @@ -545,7 +553,7 @@ | |
2922 | ||
2923 | /* | |
2924 | * get_hostname - Given an internet address, return a name (CHARON.MIT.EDU) | |
2925 | - * or a string representing the address (18.58.0.13) if the name cannot | |
2926 | + * or a string representing the address (::ffff:18.58.0.13) if the name cannot | |
2927 | * be found. | |
2928 | */ | |
2929 | ||
2930 | @@ -556,7 +564,7 @@ | |
2931 | { | |
2932 | #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) | |
2933 | struct hostent *hp = NULL; | |
2934 | - char *inet_ntoa(); | |
2935 | + static char v[64]; | |
2936 | #endif | |
2937 | #ifdef DNETCONN | |
2938 | struct nodeent *np; | |
2939 | @@ -571,12 +579,6 @@ | |
2940 | ||
2941 | #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) | |
2942 | if (ha->family == FamilyInternet) { | |
2943 | -#ifdef CRAY | |
2944 | - struct in_addr t_addr; | |
2945 | - bzero((char *)&t_addr, sizeof(t_addr)); | |
2946 | - bcopy(ha->address, (char *)&t_addr, 4); | |
2947 | - ha->address = (char *)&t_addr; | |
2948 | -#endif | |
2949 | /* gethostbyaddr can take a LONG time if the host does not exist. | |
2950 | Assume that if it does not respond in NAMESERVER_TIMEOUT seconds | |
2951 | that something is wrong and do not make the user wait. | |
2952 | @@ -586,16 +588,17 @@ | |
2953 | signal(SIGALRM, nameserver_lost); | |
2954 | alarm(4); | |
2955 | if (setjmp(env) == 0) { | |
2956 | - hp = gethostbyaddr (ha->address, ha->length, AF_INET); | |
2957 | + hp = gethostbyaddr (ha->address, ha->length, | |
2958 | + ha->length == 4 ? AF_INET : AF_INET6); | |
2959 | } | |
2960 | alarm(0); | |
2961 | if (hp) | |
2962 | return (hp->h_name); | |
2963 | -#ifndef AMTCPCONN | |
2964 | - else return (inet_ntoa(*((struct in_addr *)(ha->address)))); | |
2965 | -#else | |
2966 | - else return (inet_ntoa(*((ipaddr_t *)(ha->address)))); | |
2967 | -#endif | |
2968 | + else { | |
2969 | + inet_ntop(ha->length == 4 ? AF_INET : AF_INET6, | |
2970 | + ha->address, v, sizeof(v)); | |
2971 | + return (v); | |
2972 | + } | |
2973 | } | |
2974 | #endif | |
2975 | if (ha->family == FamilyNetname) { |