]> git.pld-linux.org Git - packages/djbdns.git/blame - djbdns-1.05-ipv6.diff
- fixed dnscache's random seed generation
[packages/djbdns.git] / djbdns-1.05-ipv6.diff
CommitLineData
73e5e52e 1diff -uNr djbdns-1.05/FILES djbdns-1.05-fefe/FILES
2--- djbdns-1.05/FILES Sun Feb 11 22:11:45 2001
3+++ djbdns-1.05-fefe/FILES Tue Feb 13 15:16:12 2001
4@@ -135,6 +135,7 @@
5 exit.h
6 fmt.h
7 fmt_ulong.c
8+fmt_xlong.c
9 gen_alloc.h
10 gen_allocdefs.h
11 getln.c
12@@ -151,6 +152,9 @@
13 ip4.h
14 ip4_fmt.c
15 ip4_scan.c
16+ip6.h
17+ip6_fmt.c
18+ip6_scan.c
19 ndelay.h
20 ndelay_off.c
21 ndelay_on.c
22@@ -164,6 +168,7 @@
23 readclose.c
24 readclose.h
25 scan.h
26+scan_0x.c
27 scan_ulong.c
28 seek.h
29 seek_set.c
30@@ -241,3 +246,4 @@
31 warn-shsgr
32 buffer_read.c
33 buffer_write.c
34+dns_nd6.c
35diff -uNr djbdns-1.05/Makefile djbdns-1.05-fefe/Makefile
36--- djbdns-1.05/Makefile Sun Feb 11 22:11:45 2001
37+++ djbdns-1.05-fefe/Makefile Tue Feb 13 15:16:12 2001
38@@ -120,12 +120,13 @@
39 case_diffb.o case_diffs.o case_lowerb.o fmt_ulong.o ip4_fmt.o \
40 ip4_scan.o scan_ulong.o str_chr.o str_diff.o str_len.o str_rchr.o \
41 str_start.o uint16_pack.o uint16_unpack.o uint32_pack.o \
42-uint32_unpack.o
43+uint32_unpack.o ip6_fmt.o ip6_scan.o scan_0x.o fmt_xlong.o
44 ./makelib byte.a byte_chr.o byte_copy.o byte_cr.o \
45 byte_diff.o byte_zero.o case_diffb.o case_diffs.o \
46 case_lowerb.o fmt_ulong.o ip4_fmt.o ip4_scan.o scan_ulong.o \
47 str_chr.o str_diff.o str_len.o str_rchr.o str_start.o \
48- uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o
49+ uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o \
50+ ip6_fmt.o ip6_scan.o scan_0x.o fmt_xlong.o
51
52 byte_chr.o: \
53 compile byte_chr.c byte.h
54@@ -228,11 +229,13 @@
55 dns.a: \
56 makelib dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o dns_ipq.o dns_mx.o \
57 dns_name.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \
58-dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o
59+dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o dns_ip6.o \
60+dns_sortip6.o dns_nd6.o
61 ./makelib dns.a dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o \
62 dns_ipq.o dns_mx.o dns_name.o dns_nd.o dns_packet.o \
63 dns_random.o dns_rcip.o dns_rcrw.o dns_resolve.o \
64- dns_sortip.o dns_transmit.o dns_txt.o
65+ dns_sortip.o dns_transmit.o dns_txt.o dns_ip6.o dns_sortip6.o \
66+ dns_nd6.o
67
68 dns_dfd.o: \
69 compile dns_dfd.c error.h alloc.h byte.h dns.h stralloc.h gen_alloc.h \
70@@ -254,6 +257,11 @@
71 stralloc.h iopause.h taia.h tai.h uint64.h taia.h
72 ./compile dns_ip.c
73
74+dns_ip6.o: \
75+compile dns_ip6.c stralloc.h gen_alloc.h uint16.h byte.h dns.h \
76+stralloc.h iopause.h taia.h tai.h uint64.h taia.h
77+ ./compile dns_ip6.c
78+
79 dns_ipq.o: \
80 compile dns_ipq.c stralloc.h gen_alloc.h case.h byte.h str.h dns.h \
81 stralloc.h iopause.h taia.h tai.h uint64.h taia.h
82@@ -274,6 +282,11 @@
83 taia.h tai.h uint64.h taia.h
84 ./compile dns_nd.c
85
86+dns_nd6.o: \
87+compile dns_nd6.c byte.h fmt.h dns.h stralloc.h gen_alloc.h iopause.h \
88+taia.h tai.h uint64.h taia.h
89+ ./compile dns_nd6.c
90+
91 dns_packet.o: \
92 compile dns_packet.c error.h dns.h stralloc.h gen_alloc.h iopause.h \
93 taia.h tai.h uint64.h taia.h
94@@ -306,6 +319,11 @@
95 taia.h tai.h uint64.h taia.h
96 ./compile dns_sortip.c
97
98+dns_sortip6.o: \
99+compile dns_sortip6.c byte.h dns.h stralloc.h gen_alloc.h iopause.h \
100+taia.h tai.h uint64.h taia.h
101+ ./compile dns_sortip6.c
102+
103 dns_transmit.o: \
104 compile dns_transmit.c socket.h uint16.h alloc.h error.h byte.h \
105 uint16.h dns.h stralloc.h gen_alloc.h iopause.h taia.h tai.h uint64.h \
106@@ -369,6 +387,17 @@
107 gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h
108 ./compile dnsip.c
109
110+dnsip6: \
111+load dnsip6.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \
112+byte.a socket.lib
113+ ./load dnsip6 iopause.o dns.a env.a libtai.a alloc.a \
114+ buffer.a unix.a byte.a `cat socket.lib`
115+
116+dnsip6.o: \
117+compile dnsip6.c buffer.h exit.h strerr.h ip6.h dns.h stralloc.h \
118+gen_alloc.h iopause.h taia.h tai.h uint64.h
119+ ./compile dnsip6.c
120+
121 dnsipq: \
122 load dnsipq.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \
123 byte.a socket.lib
124@@ -399,7 +428,7 @@
125
126 dnsname.o: \
127 compile dnsname.c buffer.h exit.h strerr.h ip4.h dns.h stralloc.h \
128-gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h
129+gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h ip6.h
130 ./compile dnsname.c
131
132 dnsq: \
133@@ -484,6 +513,10 @@
134 compile fmt_ulong.c fmt.h
135 ./compile fmt_ulong.c
136
137+fmt_xlong.o: \
138+compile fmt_xlong.c scan.h
139+ ./compile fmt_xlong.c
140+
141 generic-conf.o: \
142 compile generic-conf.c strerr.h buffer.h open.h generic-conf.h \
143 buffer.h
144@@ -546,10 +579,18 @@
145 compile ip4_fmt.c fmt.h ip4.h
146 ./compile ip4_fmt.c
147
148+ip6_fmt.o: \
149+compile ip6_fmt.c fmt.h ip6.h
150+ ./compile ip6_fmt.c
151+
152 ip4_scan.o: \
153 compile ip4_scan.c scan.h ip4.h
154 ./compile ip4_scan.c
155
156+ip6_scan.o: \
157+compile ip6_scan.c scan.h ip6.h
158+ ./compile ip6_scan.c
159+
160 it: \
161 prog install instcheck
162
163@@ -677,7 +718,7 @@
164 rbldns-data pickdns-conf pickdns pickdns-data tinydns-conf tinydns \
165 tinydns-data tinydns-get tinydns-edit axfr-get axfrdns-conf axfrdns \
166 dnsip dnsipq dnsname dnstxt dnsmx dnsfilter random-ip dnsqr dnsq \
167-dnstrace dnstracesort cachetest utime rts
168+dnstrace dnstracesort cachetest utime rts dnsip6
169
170 prot.o: \
171 compile prot.c hasshsgr.h prot.h
172@@ -762,6 +803,10 @@
173 compile scan_ulong.c scan.h
174 ./compile scan_ulong.c
175
176+scan_0x.o: \
177+compile scan_0x.c scan.h
178+ ./compile scan_0x.c
179+
180 seek_set.o: \
181 compile seek_set.c seek.h
182 ./compile seek_set.c
183@@ -1005,7 +1050,7 @@
184 compile tinydns-data.c uint16.h uint32.h str.h byte.h fmt.h ip4.h \
185 exit.h case.h scan.h buffer.h strerr.h getln.h buffer.h stralloc.h \
186 gen_alloc.h cdb_make.h buffer.h uint32.h stralloc.h open.h dns.h \
187-stralloc.h iopause.h taia.h tai.h uint64.h taia.h
188+stralloc.h iopause.h taia.h tai.h uint64.h taia.h ip6.h
189 ./compile tinydns-data.c
190
191 tinydns-edit: \
192@@ -1104,3 +1149,6 @@
193 compile walldns.c byte.h dns.h stralloc.h gen_alloc.h iopause.h \
194 taia.h tai.h uint64.h taia.h dd.h response.h uint32.h
195 ./compile walldns.c
196+
197+clean:
198+ rm -f `cat TARGETS`
199diff -uNr djbdns-1.05/TARGETS djbdns-1.05-fefe/TARGETS
200--- djbdns-1.05/TARGETS Sun Feb 11 22:11:45 2001
201+++ djbdns-1.05-fefe/TARGETS Tue Feb 13 15:16:12 2001
202@@ -214,3 +214,12 @@
203 it
204 setup
205 check
206+scan_0x.o
207+fmt_xlong.o
208+ip6_scan.o
209+ip6_fmt.o
210+dnsip6.o
211+dns_ip6.o
212+dns_sortip6.o
213+dnsip6
214+dns_nd6.o
215diff -uNr djbdns-1.05/axfr-get.c djbdns-1.05-fefe/axfr-get.c
216--- djbdns-1.05/axfr-get.c Sun Feb 11 22:11:45 2001
217+++ djbdns-1.05-fefe/axfr-get.c Tue Feb 13 15:16:12 2001
218@@ -13,6 +13,7 @@
219 #include "byte.h"
220 #include "str.h"
221 #include "ip4.h"
222+#include "ip6.h"
223 #include "timeoutread.h"
224 #include "timeoutwrite.h"
225 #include "dns.h"
226@@ -217,6 +218,14 @@
227 x_copy(buf,len,pos,data,4);
228 if (!stralloc_catb(&line,ipstr,ip4_fmt(ipstr,data))) return 0;
229 }
230+ else if (byte_equal(data,2,DNS_T_AAAA)) {
231+ char ipstr[IP6_FMT];
232+ if (!stralloc_copys(&line,"6")) return 0;
233+ if (!dns_domain_todot_cat(&line,d1)) return 0;
234+ if (!stralloc_cats(&line,":")) return 0;
235+ x_copy(buf,len,pos,data,16);
236+ if (!stralloc_catb(&line,ipstr,ip6_fmt_flat(ipstr,data))) return 0;
237+ }
238 else {
239 unsigned char ch;
240 unsigned char ch2;
241diff -uNr djbdns-1.05/dns.h djbdns-1.05-fefe/dns.h
242--- djbdns-1.05/dns.h Sun Feb 11 22:11:45 2001
243+++ djbdns-1.05-fefe/dns.h Tue Feb 13 15:16:12 2001
244@@ -68,6 +68,8 @@
245
246 extern int dns_ip4_packet(stralloc *,const char *,unsigned int);
247 extern int dns_ip4(stralloc *,const stralloc *);
248+extern int dns_ip6_packet(stralloc *,char *,unsigned int);
249+extern int dns_ip6(stralloc *,stralloc *);
250 extern int dns_name_packet(stralloc *,const char *,unsigned int);
251 extern void dns_name4_domain(char *,const char *);
252 #define DNS_NAME4_DOMAIN 31
253@@ -80,5 +82,10 @@
254 extern int dns_resolvconfrewrite(stralloc *);
255 extern int dns_ip4_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *);
256 extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *);
257+extern int dns_ip6_qualify_rules(stralloc *,stralloc *,stralloc *,stralloc *);
258+extern int dns_ip6_qualify(stralloc *,stralloc *,stralloc *);
259+
260+extern int dns_name6_domain(char *,char *);
261+#define DNS_NAME6_DOMAIN (4*16+15)
262
263 #endif
264diff -uNr djbdns-1.05/dns_ip6.c djbdns-1.05-fefe/dns_ip6.c
265--- djbdns-1.05/dns_ip6.c Thu Jan 1 01:00:00 1970
266+++ djbdns-1.05-fefe/dns_ip6.c Tue Feb 13 15:16:12 2001
267@@ -0,0 +1,91 @@
268+#include "stralloc.h"
269+#include "uint16.h"
270+#include "byte.h"
271+#include "dns.h"
272+#include "ip6.h"
273+
274+int dns_ip6_packet(stralloc *out,char *buf,unsigned int len)
275+{
276+ unsigned int pos;
277+ char header[16];
278+ uint16 numanswers;
279+ uint16 datalen;
280+
281+ if (!stralloc_copys(out,"")) return -1;
282+
283+ pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1;
284+ uint16_unpack_big(header + 6,&numanswers);
285+ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1;
286+ pos += 4;
287+
288+ while (numanswers--) {
289+ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1;
290+ pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1;
291+ uint16_unpack_big(header + 8,&datalen);
292+ if (byte_equal(header,2,DNS_T_AAAA))
293+ if (byte_equal(header + 2,2,DNS_C_IN))
294+ if (datalen == 16) {
295+ if (!dns_packet_copy(buf,len,pos,header,16)) return -1;
296+ if (!stralloc_catb(out,header,16)) return -1;
297+ }
298+ pos += datalen;
299+ }
300+
301+ dns_sortip6(out->s,out->len);
302+ return 0;
303+}
304+
305+static char *q = 0;
306+
307+int dns_ip6(stralloc *out,stralloc *fqdn)
308+{
309+ unsigned int i;
310+ char code;
311+ char ch;
312+ char ip[16];
313+
314+ if (!stralloc_copys(out,"")) return -1;
315+ if (!stralloc_readyplus(fqdn,1)) return -1;
316+ fqdn->s[fqdn->len]=0;
317+ if ((i=ip6_scan(fqdn->s,ip))) {
318+ if (fqdn->s[i]) return -1;
319+ stralloc_copyb(out,ip,16);
320+ return 0;
321+ }
322+ if ((i=ip4_scan(fqdn->s,ip+12))) {
323+ if (fqdn->s[i]) return -1;
324+ byte_zero(ip,10);
325+ ip[10]=ip[11]=0xff;
326+ stralloc_copyb(out,ip,16);
327+ return 0;
328+ }
329+ code = 0;
330+ for (i = 0;i <= fqdn->len;++i) {
331+ if (i < fqdn->len)
332+ ch = fqdn->s[i];
333+ else
334+ ch = '.';
335+
336+ if ((ch == '[') || (ch == ']')) continue;
337+ if (ch == '.') {
338+ if (!stralloc_append(out,&code)) return -1;
339+ code = 0;
340+ continue;
341+ }
342+ if ((ch >= '0') && (ch <= '9')) {
343+ code *= 10;
344+ code += ch - '0';
345+ continue;
346+ }
347+
348+ if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1;
349+ if (dns_resolve(q,DNS_T_AAAA) == -1) return -1;
350+ if (dns_ip6_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1;
351+ dns_transmit_free(&dns_resolve_tx);
352+ dns_domain_free(&q);
353+ return 0;
354+ }
355+
356+ out->len &= ~3;
357+ return 0;
358+}
359diff -uNr djbdns-1.05/dns_name.c djbdns-1.05-fefe/dns_name.c
360--- djbdns-1.05/dns_name.c Sun Feb 11 22:11:45 2001
361+++ djbdns-1.05-fefe/dns_name.c Tue Feb 13 15:16:12 2001
362@@ -2,6 +2,7 @@
363 #include "uint16.h"
364 #include "byte.h"
365 #include "dns.h"
366+#include "ip6.h"
367
368 static char *q = 0;
369
370@@ -43,6 +44,20 @@
371 if (dns_resolve(name,DNS_T_PTR) == -1) return -1;
372 if (dns_name_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1;
373 dns_transmit_free(&dns_resolve_tx);
374+ dns_domain_free(&q);
375+ return 0;
376+}
377+
378+int dns_name6(stralloc *out,char ip[16])
379+{
380+ char name[DNS_NAME6_DOMAIN];
381+
382+ if (ip6_isv4mapped(ip))
383+ return dns_name4(out,ip+12);
384+ dns_name6_domain(name,ip);
385+ if (dns_resolve(name,DNS_T_PTR) == -1) return -1;
386+ if (dns_name_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1;
387+ dns_transmit_free(&dns_resolve_tx);
388 dns_domain_free(&q);
389 return 0;
390 }
391diff -uNr djbdns-1.05/dns_nd6.c djbdns-1.05-fefe/dns_nd6.c
392--- djbdns-1.05/dns_nd6.c Thu Jan 1 01:00:00 1970
393+++ djbdns-1.05-fefe/dns_nd6.c Tue Feb 13 15:16:12 2001
394@@ -0,0 +1,28 @@
395+#include "byte.h"
396+#include "fmt.h"
397+#include "dns.h"
398+
399+/* RFC1886:
400+ * 4321:0:1:2:3:4:567:89ab
401+ * ->
402+ * b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.INT.
403+ */
404+
405+unsigned int mkint(unsigned char a,unsigned char b) {
406+ return ((unsigned int)a << 8) + (unsigned int)b;
407+}
408+
409+int dns_name6_domain(char name[DNS_NAME6_DOMAIN],char ip[16])
410+{
411+ unsigned int j;
412+
413+ for (j=0; j<16; j++) {
414+ name[j*4]=1;
415+ name[j*4+1]=tohex(ip[15-j] & 15);
416+ name[j*4+2]=1;
417+ name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4);
418+ }
419+ byte_copy(name + 4*16,14,"\3ip6\3int\0");
420+ return 4*16+14;
421+}
422+
423diff -uNr djbdns-1.05/dns_sortip6.c djbdns-1.05-fefe/dns_sortip6.c
424--- djbdns-1.05/dns_sortip6.c Thu Jan 1 01:00:00 1970
425+++ djbdns-1.05-fefe/dns_sortip6.c Tue Feb 13 15:16:12 2001
426@@ -0,0 +1,20 @@
427+#include "byte.h"
428+#include "dns.h"
429+
430+/* XXX: sort servers by configurable notion of closeness? */
431+/* XXX: pay attention to competence of each server? */
432+
433+void dns_sortip6(char *s,unsigned int n)
434+{
435+ unsigned int i;
436+ char tmp[16];
437+
438+ n >>= 4;
439+ while (n > 1) {
440+ i = dns_random(n);
441+ --n;
442+ byte_copy(tmp,14,s + (i << 4));
443+ byte_copy(s + (i << 4),16,s + (n << 4));
444+ byte_copy(s + (n << 4),16,tmp);
445+ }
446+}
447diff -uNr djbdns-1.05/dnsip6.c djbdns-1.05-fefe/dnsip6.c
448--- djbdns-1.05/dnsip6.c Thu Jan 1 01:00:00 1970
449+++ djbdns-1.05-fefe/dnsip6.c Tue Feb 13 15:16:12 2001
450@@ -0,0 +1,40 @@
451+#include "buffer.h"
452+#include "exit.h"
453+#include "strerr.h"
454+#include "ip6.h"
455+#include "dns.h"
456+
457+#define FATAL "dnsip: fatal: "
458+
459+static char seed[128];
460+
461+static stralloc fqdn;
462+static stralloc out;
463+char str[IP6_FMT];
464+
465+main(int argc,char **argv)
466+{
467+ int i;
468+
469+ dns_random_init(seed);
470+
471+ if (*argv) ++argv;
472+
473+ while (*argv) {
474+ if (!stralloc_copys(&fqdn,*argv))
475+ strerr_die2x(111,FATAL,"out of memory");
476+ if (dns_ip6(&out,&fqdn) == -1)
477+ strerr_die4sys(111,FATAL,"unable to find IPv6 address for ",*argv,": ");
478+
479+ for (i = 0;i + 16 <= out.len;i += 16) {
480+ buffer_put(buffer_1,str,ip6_fmt(str,out.s + i));
481+ buffer_puts(buffer_1," ");
482+ }
483+ buffer_puts(buffer_1,"\n");
484+
485+ ++argv;
486+ }
487+
488+ buffer_flush(buffer_1);
489+ _exit(0);
490+}
491diff -uNr djbdns-1.05/dnsname.c djbdns-1.05-fefe/dnsname.c
492--- djbdns-1.05/dnsname.c Sun Feb 11 22:11:45 2001
493+++ djbdns-1.05-fefe/dnsname.c Tue Feb 13 15:16:12 2001
494@@ -9,6 +9,7 @@
495 static char seed[128];
496
497 char ip[4];
498+char ip6[16];
499 static stralloc out;
500
501 int main(int argc,char **argv)
502@@ -18,10 +19,15 @@
503 if (*argv) ++argv;
504
505 while (*argv) {
506- if (!ip4_scan(*argv,ip))
507- strerr_die3x(111,FATAL,"unable to parse IP address ",*argv);
508- if (dns_name4(&out,ip) == -1)
509- strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": ");
510+ if (ip6_scan(*argv,ip6)) {
511+ if (dns_name6(&out,ip6) == -1)
512+ strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": ");
513+ } else {
514+ if (!ip4_scan(*argv,ip))
515+ strerr_die3x(111,FATAL,"unable to parse IP address ",*argv);
516+ if (dns_name4(&out,ip) == -1)
517+ strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": ");
518+ }
519
520 buffer_put(buffer_1,out.s,out.len);
521 buffer_puts(buffer_1,"\n");
522diff -uNr djbdns-1.05/fmt_xlong.c djbdns-1.05-fefe/fmt_xlong.c
523--- djbdns-1.05/fmt_xlong.c Thu Jan 1 01:00:00 1970
524+++ djbdns-1.05-fefe/fmt_xlong.c Tue Feb 13 15:16:12 2001
525@@ -0,0 +1,22 @@
526+#include "fmt.h"
527+
528+char tohex(char num) {
529+ if (num<10)
530+ return num+'0';
531+ else if (num<16)
532+ return num-10+'a';
533+ else
534+ return -1;
535+}
536+
537+unsigned int fmt_xlong(register char *s,register unsigned long u)
538+{
539+ register unsigned int len; register unsigned long q;
540+ len = 1; q = u;
541+ while (q > 15) { ++len; q /= 16; }
542+ if (s) {
543+ s += len;
544+ do { *--s = tohex(u % 16); u /= 16; } while(u); /* handles u == 0 */
545+ }
546+ return len;
547+}
548diff -uNr djbdns-1.05/hier.c djbdns-1.05-fefe/hier.c
549--- djbdns-1.05/hier.c Sun Feb 11 22:11:45 2001
550+++ djbdns-1.05-fefe/hier.c Tue Feb 13 15:16:12 2001
551@@ -29,6 +29,7 @@
552 c(auto_home,"bin","axfr-get",-1,-1,0755);
553
554 c(auto_home,"bin","dnsip",-1,-1,0755);
555+ c(auto_home,"bin","dnsip6",-1,-1,0755);
556 c(auto_home,"bin","dnsipq",-1,-1,0755);
557 c(auto_home,"bin","dnsname",-1,-1,0755);
558 c(auto_home,"bin","dnstxt",-1,-1,0755);
559diff -uNr djbdns-1.05/ip6.h djbdns-1.05-fefe/ip6.h
560--- djbdns-1.05/ip6.h Thu Jan 1 01:00:00 1970
561+++ djbdns-1.05-fefe/ip6.h Tue Feb 13 15:16:12 2001
562@@ -0,0 +1,28 @@
563+#ifndef IP6_H
564+#define IP6_H
565+
566+extern unsigned int ip6_scan(char *,char *);
567+extern unsigned int ip6_fmt(char *,char *);
568+
569+extern unsigned int ip6_scan_flat(char *,char *);
570+extern unsigned int ip6_fmt_flat(char *,char *);
571+
572+/*
573+ ip6 address syntax: (h = hex digit), no leading '0' required
574+ 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
575+ 2. any number of 0000 may be abbreviated as "::", but only once
576+ flat ip6 address syntax:
577+ hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
578+ */
579+
580+#define IP6_FMT 40
581+
582+const static unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff};
583+const static unsigned char V6loopback[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
584+const static unsigned char V6any[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
585+
586+#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix))
587+
588+const static char ip4loopback[4] = {127,0,0,1};
589+
590+#endif
591diff -uNr djbdns-1.05/ip6_fmt.c djbdns-1.05-fefe/ip6_fmt.c
592--- djbdns-1.05/ip6_fmt.c Thu Jan 1 01:00:00 1970
593+++ djbdns-1.05-fefe/ip6_fmt.c Tue Feb 13 15:16:12 2001
594@@ -0,0 +1,55 @@
595+#include "fmt.h"
596+#include "ip6.h"
597+#include <stdio.h>
598+
599+unsigned int ip6_fmt(char *s,char ip[16])
600+{
601+ unsigned int len;
602+ unsigned int i;
603+
604+ len = 0;
605+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[0] << 8) +
606+ (unsigned long) (unsigned char) ip[1]); len += i; if (s) s += i;
607+ if (s) *s++ = ':'; ++len;
608+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[2] << 8) +
609+ (unsigned long) (unsigned char) ip[3]); len += i; if (s) s += i;
610+ if (s) *s++ = ':'; ++len;
611+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[4] << 8) +
612+ (unsigned long) (unsigned char) ip[5]); len += i; if (s) s += i;
613+ if (s) *s++ = ':'; ++len;
614+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[6] << 8) +
615+ (unsigned long) (unsigned char) ip[7]); len += i; if (s) s += i;
616+ if (s) *s++ = ':'; ++len;
617+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[8] << 8) +
618+ (unsigned long) (unsigned char) ip[9]); len += i; if (s) s += i;
619+ if (s) *s++ = ':'; ++len;
620+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[10] << 8) +
621+ (unsigned long) (unsigned char) ip[11]); len += i; if (s) s += i;
622+ if (s) *s++ = ':'; ++len;
623+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[12] << 8) +
624+ (unsigned long) (unsigned char) ip[13]); len += i; if (s) s += i;
625+ if (s) *s++ = ':'; ++len;
626+ i = fmt_xlong(s,((unsigned long) (unsigned char) ip[14] << 8) +
627+ (unsigned long) (unsigned char) ip[15]); len += i; if (s) s += i;
628+ if (s) *s=0;
629+ return len;
630+}
631+
632+static char tohex(char num) {
633+ if (num<10)
634+ return num+'0';
635+ else if (num<16)
636+ return num-10+'a';
637+ else
638+ return -1;
639+}
640+
641+unsigned int ip6_fmt_flat(char *s,char ip[16])
642+{
643+ int i;
644+ for (i=0; i<16; i++) {
645+ *s++=tohex((unsigned char)ip[i] >> 4);
646+ *s++=tohex((unsigned char)ip[i] & 15);
647+ }
648+ return 32;
649+}
650diff -uNr djbdns-1.05/ip6_scan.c djbdns-1.05-fefe/ip6_scan.c
651--- djbdns-1.05/ip6_scan.c Thu Jan 1 01:00:00 1970
652+++ djbdns-1.05-fefe/ip6_scan.c Tue Feb 13 15:16:12 2001
653@@ -0,0 +1,110 @@
654+#include "scan.h"
655+#include "ip4.h"
656+#include "ip6.h"
657+
658+/*
659+ * IPv6 addresses are really ugly to parse.
660+ * Syntax: (h = hex digit)
661+ * 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
662+ * 2. any number of 0000 may be abbreviated as "::", but only once
663+ * 3. The last two words may be written as IPv4 address
664+ */
665+
666+unsigned int ip6_scan(char *s,char ip[16])
667+{
668+ unsigned int i;
669+ unsigned int len=0;
670+ unsigned int u;
671+
672+ char suffix[16];
673+ int prefixlen=0;
674+ int suffixlen=0;
675+
676+ for (i=0; i<16; i++) ip[i]=0;
677+
678+ for (;;) {
679+ if (*s == ':') {
680+ len++;
681+ if (s[1] == ':') { /* Found "::", skip to part 2 */
682+ s+=2;
683+ len++;
684+ break;
685+ }
686+ s++;
687+ }
688+ i = scan_0x(s,&u);
689+ if (!i) return 0;
690+ if (prefixlen==12 && s[i]=='.') {
691+ /* the last 4 bytes may be written as IPv4 address */
692+ i=ip4_scan(s,ip+12);
693+ if (i)
694+ return i+len;
695+ else
696+ return 0;
697+ }
698+ ip[prefixlen++] = (u >> 8);
699+ ip[prefixlen++] = (u & 255);
700+ s += i; len += i;
701+ if (prefixlen==16)
702+ return len;
703+ }
704+
705+/* part 2, after "::" */
706+ for (;;) {
707+ if (*s == ':') {
708+ if (suffixlen==0)
709+ break;
710+ s++;
711+ len++;
712+ } else if (suffixlen!=0)
713+ break;
714+ i = scan_0x(s,&u);
715+ if (!i) {
716+ len--;
717+ break;
718+ }
719+ if (suffixlen+prefixlen<=12 && s[i]=='.') {
720+ int j=ip4_scan(s,suffix+suffixlen);
721+ if (j) {
722+ suffixlen+=4;
723+ len+=j;
724+ break;
725+ } else
726+ prefixlen=12-suffixlen; /* make end-of-loop test true */
727+ }
728+ suffix[suffixlen++] = (u >> 8);
729+ suffix[suffixlen++] = (u & 255);
730+ s += i; len += i;
731+ if (prefixlen+suffixlen==16)
732+ break;
733+ }
734+ for (i=0; i<suffixlen; i++)
735+ ip[16-suffixlen+i] = suffix[i];
736+ return len;
737+}
738+
739+static long int fromhex(unsigned char c) {
740+ if (c>='0' && c<='9')
741+ return c-'0';
742+ else if (c>='A' && c<='F')
743+ return c-'A'+10;
744+ else if (c>='a' && c<='f')
745+ return c-'a'+10;
746+ return -1;
747+}
748+
749+unsigned int ip6_scan_flat(char *s,char ip[16])
750+{
751+ int i;
752+ char *old=s;
753+ for (i=0; i<16; i++) {
754+ int tmp;
755+ tmp=fromhex(*s++);
756+ if (tmp<0) return 0;
757+ ip[i]=tmp << 4;
758+ tmp=fromhex(*s++);
759+ if (tmp<0) return 0;
760+ ip[i]+=tmp;
761+ }
762+ return 32;
763+}
764diff -uNr djbdns-1.05/printrecord.c djbdns-1.05-fefe/printrecord.c
765--- djbdns-1.05/printrecord.c Sun Feb 11 22:11:45 2001
766+++ djbdns-1.05-fefe/printrecord.c Tue Feb 13 15:16:12 2001
767@@ -4,6 +4,7 @@
768 #include "byte.h"
769 #include "dns.h"
770 #include "printrecord.h"
771+#include "ip6.h"
772
773 static char *d;
774
775@@ -82,6 +83,15 @@
776 if (!stralloc_catulong0(out,ch,0)) return 0;
777 }
778 }
779+ else if (byte_equal(misc,2,DNS_T_AAAA)) {
780+ char ip6str[IP6_FMT];
781+ int stringlen;
782+ if (datalen != 16) { errno = error_proto; return 0; }
783+ if (!stralloc_cats(out," AAAA ")) return 0;
784+ pos = dns_packet_copy(buf,len,pos,misc,16); if (!pos) return 0;
785+ stringlen=ip6_fmt(ip6str,misc);
786+ if (!stralloc_cats(out,ip6str)) return 0;
787+ }
788 else {
789 if (!stralloc_cats(out," ")) return 0;
790 uint16_unpack_big(misc,&u16);
791diff -uNr djbdns-1.05/query.c djbdns-1.05-fefe/query.c
792--- djbdns-1.05/query.c Sun Feb 11 22:11:45 2001
793+++ djbdns-1.05-fefe/query.c Tue Feb 13 15:16:12 2001
794@@ -227,6 +227,158 @@
795 return 1;
796 }
797
798+ if (dns_domain_equal(d,"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\003ip6\003int\0")) {
799+ if (z->level) goto LOWERLEVEL;
800+ if (!rqa(z)) goto DIE;
801+ if (typematch(DNS_T_PTR,dtype)) {
802+ if (!response_rstart(d,DNS_T_PTR,"\0\0\0\0")) goto DIE;
803+ if (!response_addname("\016ipv6-localhost\0")) goto DIE;
804+ if (!response_addname("\015ipv6-loopback\0")) goto DIE;
805+ response_rfinish(RESPONSE_ANSWER);
806+ }
807+ cleanup(z);
808+ return 1;
809+ }
810+
811+ if (dns_domain_equal(d,"\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\001e\001f\003ip6\003int\0")) {
812+ if (z->level) goto LOWERLEVEL;
813+ if (!rqa(z)) goto DIE;
814+ if (typematch(DNS_T_PTR,dtype)) {
815+ if (!response_rstart(d,DNS_T_PTR,"\0\0\0\0")) goto DIE;
816+ if (!response_addname("\015ipv6-localnet\0")) goto DIE;
817+ response_rfinish(RESPONSE_ANSWER);
818+ }
819+ cleanup(z);
820+ return 1;
821+ }
822+
823+ if (dns_domain_equal(d,"\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\001f\001f\003ip6\003int\0")) {
824+ if (z->level) goto LOWERLEVEL;
825+ if (!rqa(z)) goto DIE;
826+ if (typematch(DNS_T_PTR,dtype)) {
827+ if (!response_rstart(d,DNS_T_PTR,"\0\0\0\0")) goto DIE;
828+ if (!response_addname("\020ipv6-mcastprefix\0")) goto DIE;
829+ response_rfinish(RESPONSE_ANSWER);
830+ }
831+ cleanup(z);
832+ return 1;
833+ }
834+
835+ if (dns_domain_equal(d,"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\003int\0")) {
836+ if (z->level) goto LOWERLEVEL;
837+ if (!rqa(z)) goto DIE;
838+ if (typematch(DNS_T_PTR,dtype)) {
839+ if (!response_rstart(d,DNS_T_PTR,"\0\0\0\0")) goto DIE;
840+ if (!response_addname("\015ipv6-allnodes\0")) goto DIE;
841+ response_rfinish(RESPONSE_ANSWER);
842+ }
843+ cleanup(z);
844+ return 1;
845+ }
846+
847+ if (dns_domain_equal(d,"\0012\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\003int\0")) {
848+ if (z->level) goto LOWERLEVEL;
849+ if (!rqa(z)) goto DIE;
850+ if (typematch(DNS_T_PTR,dtype)) {
851+ if (!response_rstart(d,DNS_T_PTR,"\0\0\0\0")) goto DIE;
852+ if (!response_addname("\017ipv6-allrouters\0")) goto DIE;
853+ response_rfinish(RESPONSE_ANSWER);
854+ }
855+ cleanup(z);
856+ return 1;
857+ }
858+
859+ if (dns_domain_equal(d,"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\003int\0")) {
860+ if (z->level) goto LOWERLEVEL;
861+ if (!rqa(z)) goto DIE;
862+ if (typematch(DNS_T_PTR,dtype)) {
863+ if (!response_rstart(d,DNS_T_PTR,"\0\0\0\0")) goto DIE;
864+ if (!response_addname("\015ipv6-allhosts\0")) goto DIE;
865+ response_rfinish(RESPONSE_ANSWER);
866+ }
867+ cleanup(z);
868+ return 1;
869+ }
870+
871+ if (dns_domain_equal(d,"\016ipv6-localhost\0") ||
872+ dns_domain_equal(d,"\015ipv6-loopback\0"))
873+ {
874+ if (z->level) goto LOWERLEVEL;
875+ if (!rqa(z)) goto DIE;
876+ if (typematch(DNS_T_AAAA,dtype)) {
877+ if (!response_rstart(d,DNS_T_AAAA,"\0\0\0\0")) goto DIE;
878+ if (!response_addbytes("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001",16)) goto DIE;
879+ response_rfinish(RESPONSE_ANSWER);
880+ }
881+ cleanup(z);
882+ return 1;
883+ }
884+
885+ if (dns_domain_equal(d,"\015ipv6-localnet\0"))
886+ {
887+ if (z->level) goto LOWERLEVEL;
888+ if (!rqa(z)) goto DIE;
889+ if (typematch(DNS_T_AAAA,dtype)) {
890+ if (!response_rstart(d,DNS_T_AAAA,"\0\0\0\0")) goto DIE;
891+ if (!response_addbytes("\376\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",16)) goto DIE;
892+ response_rfinish(RESPONSE_ANSWER);
893+ }
894+ cleanup(z);
895+ return 1;
896+ }
897+
898+ if (dns_domain_equal(d,"\020ipv6-mcastprefix\0"))
899+ {
900+ if (z->level) goto LOWERLEVEL;
901+ if (!rqa(z)) goto DIE;
902+ if (typematch(DNS_T_AAAA,dtype)) {
903+ if (!response_rstart(d,DNS_T_AAAA,"\0\0\0\0")) goto DIE;
904+ if (!response_addbytes("\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",16)) goto DIE;
905+ response_rfinish(RESPONSE_ANSWER);
906+ }
907+ cleanup(z);
908+ return 1;
909+ }
910+
911+ if (dns_domain_equal(d,"\15ipv6-allnodes\0"))
912+ {
913+ if (z->level) goto LOWERLEVEL;
914+ if (!rqa(z)) goto DIE;
915+ if (typematch(DNS_T_AAAA,dtype)) {
916+ if (!response_rstart(d,DNS_T_AAAA,"\0\0\0\0")) goto DIE;
917+ if (!response_addbytes("\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\001",16)) goto DIE;
918+ response_rfinish(RESPONSE_ANSWER);
919+ }
920+ cleanup(z);
921+ return 1;
922+ }
923+
924+ if (dns_domain_equal(d,"\17ipv6-allrouters\0"))
925+ {
926+ if (z->level) goto LOWERLEVEL;
927+ if (!rqa(z)) goto DIE;
928+ if (typematch(DNS_T_AAAA,dtype)) {
929+ if (!response_rstart(d,DNS_T_AAAA,"\0\0\0\0")) goto DIE;
930+ if (!response_addbytes("\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\002",16)) goto DIE;
931+ response_rfinish(RESPONSE_ANSWER);
932+ }
933+ cleanup(z);
934+ return 1;
935+ }
936+
937+ if (dns_domain_equal(d,"\15ipv6-allhosts\0"))
938+ {
939+ if (z->level) goto LOWERLEVEL;
940+ if (!rqa(z)) goto DIE;
941+ if (typematch(DNS_T_AAAA,dtype)) {
942+ if (!response_rstart(d,DNS_T_AAAA,"\0\0\0\0")) goto DIE;
943+ if (!response_addbytes("\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\003",16)) goto DIE;
944+ response_rfinish(RESPONSE_ANSWER);
945+ }
946+ cleanup(z);
947+ return 1;
948+ }
949+
950 if (dns_domain_equal(d,"\0011\0010\0010\003127\7in-addr\4arpa\0")) {
951 if (z->level) goto LOWERLEVEL;
952 if (!rqa(z)) goto DIE;
953diff -uNr djbdns-1.05/scan_0x.c djbdns-1.05-fefe/scan_0x.c
954--- djbdns-1.05/scan_0x.c Thu Jan 1 01:00:00 1970
955+++ djbdns-1.05-fefe/scan_0x.c Tue Feb 13 15:16:12 2001
956@@ -0,0 +1,24 @@
957+#include "scan.h"
958+
959+long int fromhex(unsigned char c) {
960+ if (c>='0' && c<='9')
961+ return c-'0';
962+ else if (c>='A' && c<='F')
963+ return c-'A'+10;
964+ else if (c>='a' && c<='f')
965+ return c-'a'+10;
966+ return -1;
967+}
968+
969+unsigned int scan_0x(register const char *s,register unsigned int *u)
970+{
971+ register unsigned int pos = 0;
972+ register unsigned long result = 0;
973+ register long int c;
974+ while ((c = fromhex((unsigned char) (s[pos]))) >= 0) {
975+ result = (result << 4) + c;
976+ ++pos;
977+ }
978+ *u = result;
979+ return pos;
980+}
981diff -uNr djbdns-1.05/socket.h djbdns-1.05-fefe/socket.h
982--- djbdns-1.05/socket.h Sun Feb 11 22:11:45 2001
983+++ djbdns-1.05-fefe/socket.h Tue Feb 13 15:16:12 2001
984@@ -5,17 +5,27 @@
985
986 extern int socket_tcp(void);
987 extern int socket_udp(void);
988+extern int socket_tcp6(void);
989+extern int socket_udp6(void);
990
991 extern int socket_connect4(int,const char *,uint16);
992+extern int socket_connect6(int,char *,uint16);
993 extern int socket_connected(int);
994 extern int socket_bind4(int,char *,uint16);
995 extern int socket_bind4_reuse(int,char *,uint16);
996+extern int socket_bind6(int,char *,uint16);
997+extern int socket_bind6_reuse(int,char *,uint16);
998 extern int socket_listen(int,int);
999 extern int socket_accept4(int,char *,uint16 *);
1000+extern int socket_accept6(int,char *,uint16 *);
1001 extern int socket_recv4(int,char *,int,char *,uint16 *);
1002 extern int socket_send4(int,const char *,int,const char *,uint16);
1003+extern int socket_recv6(int,char *,int,char *,uint16 *);
1004+extern int socket_send6(int,char *,int,char *,uint16);
1005 extern int socket_local4(int,char *,uint16 *);
1006 extern int socket_remote4(int,char *,uint16 *);
1007+extern int socket_local6(int,char *,uint16 *);
1008+extern int socket_remote6(int,char *,uint16 *);
1009
1010 extern void socket_tryreservein(int,int);
1011
1012diff -uNr djbdns-1.05/tinydns-conf.c djbdns-1.05-fefe/tinydns-conf.c
1013--- djbdns-1.05/tinydns-conf.c Sun Feb 11 22:11:45 2001
1014+++ djbdns-1.05-fefe/tinydns-conf.c Tue Feb 13 15:16:12 2001
1015@@ -82,6 +82,18 @@
1016 finish();
1017 perm(0755);
1018
1019+ start("root/add-host6");
1020+ outs("#!/bin/sh\nexec ");
1021+ outs(auto_home); outs("/bin/tinydns-edit data data.new add host6 ${1+\"$@\"}\n");
1022+ finish();
1023+ perm(0755);
1024+
1025+ start("root/add-alias6");
1026+ outs("#!/bin/sh\nexec ");
1027+ outs(auto_home); outs("/bin/tinydns-edit data data.new add alias6 ${1+\"$@\"}\n");
1028+ finish();
1029+ perm(0755);
1030+
1031 start("root/add-mx");
1032 outs("#!/bin/sh\nexec ");
1033 outs(auto_home); outs("/bin/tinydns-edit data data.new add mx ${1+\"$@\"}\n");
1034diff -uNr djbdns-1.05/tinydns-data.c djbdns-1.05-fefe/tinydns-data.c
1035--- djbdns-1.05/tinydns-data.c Sun Feb 11 22:11:45 2001
1036+++ djbdns-1.05-fefe/tinydns-data.c Tue Feb 13 15:16:12 2001
1037@@ -8,6 +8,7 @@
1038 #include "byte.h"
1039 #include "fmt.h"
1040 #include "ip4.h"
1041+#include "ip6.h"
1042 #include "exit.h"
1043 #include "case.h"
1044 #include "scan.h"
1045@@ -172,6 +173,7 @@
1046 static char *d1;
1047 static char *d2;
1048 char dptr[DNS_NAME4_DOMAIN];
1049+char d6ptr[DNS_NAME6_DOMAIN];
1050
1051 char strnum[FMT_ULONG];
1052
1053@@ -193,6 +195,7 @@
1054 char loc[2];
1055 unsigned long u;
1056 char ip[4];
1057+ char ip6[16];
1058 char type[2];
1059 char soa[20];
1060 char buf[4];
1061@@ -338,6 +341,28 @@
1062 }
1063 }
1064 break;
1065+
1066+ case '6': case '3':
1067+ if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
1068+ if (!stralloc_0(&f[2])) nomem();
1069+ if (!scan_ulong(f[2].s,&ttl)) ttl = TTL_POSITIVE;
1070+ ttdparse(&f[3],ttd);
1071+ locparse(&f[4],loc);
1072+
1073+ if (!stralloc_0(&f[1])) nomem();
1074+ if (ip6_scan_flat(f[1].s,ip6)) {
1075+ rr_start(DNS_T_AAAA,ttl,ttd,loc);
1076+ rr_add(ip6,16);
1077+ rr_finish(d1);
1078+
1079+ if (line.s[0] == '6') {
1080+ dns_name6_domain(d6ptr,ip6);
1081+ rr_start(DNS_T_PTR,ttl,ttd,loc);
1082+ rr_addname(d1);
1083+ rr_finish(d6ptr);
1084+ }
1085+ }
1086+ break;
1087
1088 case '@':
1089 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
1090diff -uNr djbdns-1.05/tinydns-edit.c djbdns-1.05-fefe/tinydns-edit.c
1091--- djbdns-1.05/tinydns-edit.c Sun Feb 11 22:11:45 2001
1092+++ djbdns-1.05-fefe/tinydns-edit.c Tue Feb 13 15:16:12 2001
1093@@ -13,6 +13,7 @@
1094 #include "str.h"
1095 #include "fmt.h"
1096 #include "ip4.h"
1097+#include "ip6.h"
1098 #include "dns.h"
1099
1100 #define FATAL "tinydns-edit: fatal: "
1101@@ -25,7 +26,8 @@
1102
1103 void die_usage()
1104 {
1105- strerr_die1x(100,"tinydns-edit: usage: tinydns-edit data data.new add [ns|childns|host|alias|mx] domain a.b.c.d");
1106+ strerr_die1x(100,"tinydns-edit: usage: tinydns-edit data data.new add [ns|childns|host|alias|mx] domain a.b.c.d\n"
1107+ "tinydns-edit: usage: tinydns-edit data data.new add [host6|alias6] domain a:b:c:d:e:f:g:h");
1108 }
1109 void nomem()
1110 {
1111@@ -43,6 +45,7 @@
1112 char mode;
1113 static char *target;
1114 char targetip[4];
1115+char targetip6[16];
1116
1117 int fd;
1118 buffer b;
1119@@ -61,7 +64,9 @@
1120 static char *d1;
1121 static char *d2;
1122 char ip[4];
1123+char ip6[16];
1124 char ipstr[IP4_FMT];
1125+char ip6str[IP6_FMT];
1126 char strnum[FMT_ULONG];
1127
1128 static char *names[26];
1129@@ -96,7 +101,9 @@
1130 if (str_equal(*argv,"ns")) mode = '.';
1131 else if (str_equal(*argv,"childns")) mode = '&';
1132 else if (str_equal(*argv,"host")) mode = '=';
1133+ else if (str_equal(*argv,"host6")) mode = '6';
1134 else if (str_equal(*argv,"alias")) mode = '+';
1135+ else if (str_equal(*argv,"alias6")) mode = '3';
1136 else if (str_equal(*argv,"mx")) mode = '@';
1137 else die_usage();
1138
1139@@ -104,7 +111,11 @@
1140 if (!dns_domain_fromdot(&target,*argv,str_len(*argv))) nomem();
1141
1142 if (!*++argv) die_usage();
1143- if (!ip4_scan(*argv,targetip)) die_usage();
1144+ if (mode == '6' || mode == '3') {
1145+ if (!ip6_scan(*argv,targetip6)) die_usage();
1146+ } else {
1147+ if (!ip4_scan(*argv,targetip)) die_usage();
1148+ }
1149
1150 umask(077);
1151
1152@@ -129,7 +140,7 @@
1153 if (!dns_domain_fromdot(&names[i],f[0].s,f[0].len)) nomem();
1154 }
1155 break;
1156- case '+': case '=':
1157+ case '+': case '=': case '6': case '3':
1158 ttl = TTL_POSITIVE;
1159 break;
1160 case '@':
1161@@ -203,6 +214,18 @@
1162 }
1163 break;
1164
1165+ case '6':
1166+ if (line.s[0] == '6') {
1167+ if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
1168+ if (dns_domain_equal(d1,target))
1169+ strerr_die2x(100,FATAL,"host name already used");
1170+ if (!stralloc_0(&f[1])) nomem();
1171+ if (ip6_scan(f[1].s,ip6))
1172+ if (byte_equal(ip,16,targetip6))
1173+ strerr_die2x(100,FATAL,"IPv6 address already used");
1174+ }
1175+ break;
1176+
1177 case '@':
1178 if (line.s[0] == '@') {
1179 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
1180@@ -228,7 +251,11 @@
1181 if (!stralloc_copyb(&f[0],&mode,1)) nomem();
1182 if (!dns_domain_todot_cat(&f[0],target)) nomem();
1183 if (!stralloc_cats(&f[0],":")) nomem();
1184- if (!stralloc_catb(&f[0],ipstr,ip4_fmt(ipstr,targetip))) nomem();
1185+ if (mode == '6' || mode == '3') {
1186+ if (!stralloc_catb(&f[0],ip6str,ip6_fmt_flat(ip6str,targetip6))) nomem();
1187+ } else {
1188+ if (!stralloc_catb(&f[0],ipstr,ip4_fmt(ipstr,targetip))) nomem();
1189+ }
1190 switch(mode) {
1191 case '.': case '&': case '@':
1192 for (i = 0;i < 26;++i)
This page took 0.336158 seconds and 4 git commands to generate.