1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# http://hasiru.net/djbdns-ipv6-ooyama.patch
diff -puNr dns_transmit.c dns_transmit.c
--- dns_transmit.c 2008-07-12 14:10:52.000000000 +0900
+++ dns_transmit.c 2008-07-11 15:35:23.000000000 +0900
@@ -104,6 +104,14 @@ static int thisudp(struct dns_transmit *
while (d->udploop < 4) {
for (;d->curserver < 16;++d->curserver) {
ip = d->servers + 16 * d->curserver;
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+ if (!fromserver) {
+ if (ip6_isv4mapped(ip))
+ noipv6 = 1;
+ else
+ noipv6 = 0;
+ }
+#endif
if (byte_diff(ip,16,V6any)) {
d->query[2] = dns_random(256);
d->query[3] = dns_random(256);
@@ -155,6 +163,14 @@ static int thistcp(struct dns_transmit *
for (;d->curserver < 16;++d->curserver) {
ip = d->servers + 16 * d->curserver;
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+ if (!fromserver) {
+ if (ip6_isv4mapped(ip))
+ noipv6 = 1;
+ else
+ noipv6 = 0;
+ }
+#endif
if (byte_diff(ip,16,V6any)) {
d->query[2] = dns_random(256);
d->query[3] = dns_random(256);
diff -puNr dnscache.c dnscache.c
--- dnscache.c 2008-07-12 14:10:52.000000000 +0900
+++ dnscache.c 2008-07-11 15:32:00.000000000 +0900
@@ -59,6 +59,7 @@ uint64 numqueries = 0;
static int udp53;
+
#define MAXUDP 200
static struct udpclient {
struct query q;
@@ -408,11 +409,12 @@ int main()
if (!ip6_scan(x,myipincoming))
strerr_die3x(111,FATAL,"unable to parse IP address ",x);
-#if 0
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
/* if if IP is a mapped-IPv4 address, disable IPv6 functionality */
/* this is actually a bad idea */
if (ip6_isv4mapped(myipincoming))
noipv6 = 1;
+ fromserver = 1;
#endif
udp53 = socket_udp6();
diff -puNr server.c server.c
--- server.c 2008-07-12 14:10:52.000000000 +0900
+++ server.c 2008-07-11 15:33:18.000000000 +0900
@@ -92,6 +92,9 @@ int main()
{
char *x;
int *udp53;
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+ int *noipv6s;
+#endif
unsigned int off;
unsigned int cnt;
iopause_fd *iop;
@@ -116,6 +119,11 @@ int main()
}
udp53=(int *) alloc(sizeof(int) *cnt);
if (!udp53) nomem();
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+ noipv6s=(int *) alloc(sizeof(int) *cnt);
+ if (!noipv6s) nomem();
+ fromserver = 1;
+#endif
iop=(iopause_fd *) alloc(sizeof(*iop) * cnt);
if (!iop) nomem();
@@ -124,6 +132,12 @@ int main()
unsigned int l;
uint32 ifid=0;
l=ip6_scan(x+off,ip);
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+ if (ip6_isv4mapped(ip))
+ noipv6 = noipv6s[cnt] = 1;
+ else
+ noipv6 = noipv6s[cnt] = 0;
+#endif
udp53[cnt] = socket_udp6();
if (udp53[cnt] == -1)
strerr_die2sys(111,fatal,"unable to create UDP socket: ");
@@ -165,6 +179,9 @@ int main()
iopause(iop,cnt,&deadline,&stamp);
for (i=0;i<cnt;i++)
if (iop[i].revents) {
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+ noipv6 = noipv6s[i];
+#endif
len = socket_recv6(udp53[i],buf,sizeof buf,ip,&port,&ifid);
if (len < 0) continue;
if (!doit()) continue;
diff -puNr socket.h socket.h
--- socket.h 2008-07-12 14:10:52.000000000 +0900
+++ socket.h 2008-07-11 15:44:14.000000000 +0900
@@ -34,5 +34,6 @@ extern const char* socket_getifname(uint
extern uint32 socket_getifidx(const char *ifname);
extern int noipv6;
+extern int fromserver;
#endif
diff -puNr socket_noipv6.c socket_noipv6.c
--- socket_noipv6.c 2008-07-12 14:10:52.000000000 +0900
+++ socket_noipv6.c 2008-07-11 15:30:12.000000000 +0900
@@ -1,5 +1,6 @@
#include "haveip6.h"
+int fromserver=0;
#ifdef LIBC_HAS_IP6
int noipv6=0;
#else
|