1 diff -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
35 diff -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
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 \
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
53 compile byte_chr.c byte.h
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 \
69 compile dns_dfd.c error.h alloc.h byte.h dns.h stralloc.h gen_alloc.h \
71 stralloc.h iopause.h taia.h tai.h uint64.h taia.h
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
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
83 taia.h tai.h uint64.h taia.h
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
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
95 taia.h tai.h uint64.h taia.h
96 ./compile dns_sortip.c
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
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 \
107 gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h
111 +load dnsip6.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \
113 + ./load dnsip6 iopause.o dns.a env.a libtai.a alloc.a \
114 + buffer.a unix.a byte.a `cat socket.lib`
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
122 load dnsipq.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \
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
134 compile fmt_ulong.c fmt.h
135 ./compile fmt_ulong.c
138 +compile fmt_xlong.c scan.h
139 + ./compile fmt_xlong.c
142 compile generic-conf.c strerr.h buffer.h open.h generic-conf.h \
144 @@ -546,10 +579,18 @@
145 compile ip4_fmt.c fmt.h ip4.h
149 +compile ip6_fmt.c fmt.h ip6.h
150 + ./compile ip6_fmt.c
153 compile ip4_scan.c scan.h ip4.h
157 +compile ip6_scan.c scan.h ip6.h
158 + ./compile ip6_scan.c
161 prog install instcheck
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
171 compile prot.c hasshsgr.h prot.h
173 compile scan_ulong.c scan.h
174 ./compile scan_ulong.c
177 +compile scan_0x.c scan.h
178 + ./compile scan_0x.c
181 compile seek_set.c seek.h
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
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
198 + rm -f `cat TARGETS`
199 diff -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
215 diff -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
223 #include "timeoutread.h"
224 #include "timeoutwrite.h"
227 x_copy(buf,len,pos,data,4);
228 if (!stralloc_catb(&line,ipstr,ip4_fmt(ipstr,data))) return 0;
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;
241 diff -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
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
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 *);
260 +extern int dns_name6_domain(char *,char *);
261 +#define DNS_NAME6_DOMAIN (4*16+15)
264 diff -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
268 +#include "stralloc.h"
274 +int dns_ip6_packet(stralloc *out,char *buf,unsigned int len)
281 + if (!stralloc_copys(out,"")) return -1;
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;
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;
301 + dns_sortip6(out->s,out->len);
307 +int dns_ip6(stralloc *out,stralloc *fqdn)
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);
322 + if ((i=ip4_scan(fqdn->s,ip+12))) {
323 + if (fqdn->s[i]) return -1;
325 + ip[10]=ip[11]=0xff;
326 + stralloc_copyb(out,ip,16);
330 + for (i = 0;i <= fqdn->len;++i) {
336 + if ((ch == '[') || (ch == ']')) continue;
338 + if (!stralloc_append(out,&code)) return -1;
342 + if ((ch >= '0') && (ch <= '9')) {
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);
359 diff -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
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);
378 +int dns_name6(stralloc *out,char ip[16])
380 + char name[DNS_NAME6_DOMAIN];
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);
391 diff -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
400 + * 4321:0:1:2:3:4:567:89ab
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.
405 +unsigned int mkint(unsigned char a,unsigned char b) {
406 + return ((unsigned int)a << 8) + (unsigned int)b;
409 +int dns_name6_domain(char name[DNS_NAME6_DOMAIN],char ip[16])
413 + for (j=0; j<16; j++) {
415 + name[j*4+1]=tohex(ip[15-j] & 15);
417 + name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4);
419 + byte_copy(name + 4*16,14,"\3ip6\3int\0");
423 diff -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
430 +/* XXX: sort servers by configurable notion of closeness? */
431 +/* XXX: pay attention to competence of each server? */
433 +void dns_sortip6(char *s,unsigned int 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);
447 diff -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
457 +#define FATAL "dnsip: fatal: "
459 +static char seed[128];
461 +static stralloc fqdn;
462 +static stralloc out;
465 +main(int argc,char **argv)
469 + dns_random_init(seed);
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,": ");
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," ");
483 + buffer_puts(buffer_1,"\n");
488 + buffer_flush(buffer_1);
491 diff -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
495 static char seed[128];
501 int main(int argc,char **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,": ");
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,": ");
520 buffer_put(buffer_1,out.s,out.len);
521 buffer_puts(buffer_1,"\n");
522 diff -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
528 +char tohex(char num) {
537 +unsigned int fmt_xlong(register char *s,register unsigned long u)
539 + register unsigned int len; register unsigned long q;
541 + while (q > 15) { ++len; q /= 16; }
544 + do { *--s = tohex(u % 16); u /= 16; } while(u); /* handles u == 0 */
548 diff -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
552 c(auto_home,"bin","axfr-get",-1,-1,0755);
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);
559 diff -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
566 +extern unsigned int ip6_scan(char *,char *);
567 +extern unsigned int ip6_fmt(char *,char *);
569 +extern unsigned int ip6_scan_flat(char *,char *);
570 +extern unsigned int ip6_fmt_flat(char *,char *);
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
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};
586 +#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix))
588 +const static char ip4loopback[4] = {127,0,0,1};
591 diff -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
599 +unsigned int ip6_fmt(char *s,char ip[16])
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;
632 +static char tohex(char num) {
641 +unsigned int ip6_fmt_flat(char *s,char ip[16])
644 + for (i=0; i<16; i++) {
645 + *s++=tohex((unsigned char)ip[i] >> 4);
646 + *s++=tohex((unsigned char)ip[i] & 15);
650 diff -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
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
666 +unsigned int ip6_scan(char *s,char ip[16])
669 + unsigned int len=0;
676 + for (i=0; i<16; i++) ip[i]=0;
681 + if (s[1] == ':') { /* Found "::", skip to part 2 */
690 + if (prefixlen==12 && s[i]=='.') {
691 + /* the last 4 bytes may be written as IPv4 address */
692 + i=ip4_scan(s,ip+12);
698 + ip[prefixlen++] = (u >> 8);
699 + ip[prefixlen++] = (u & 255);
705 +/* part 2, after "::" */
712 + } else if (suffixlen!=0)
719 + if (suffixlen+prefixlen<=12 && s[i]=='.') {
720 + int j=ip4_scan(s,suffix+suffixlen);
726 + prefixlen=12-suffixlen; /* make end-of-loop test true */
728 + suffix[suffixlen++] = (u >> 8);
729 + suffix[suffixlen++] = (u & 255);
731 + if (prefixlen+suffixlen==16)
734 + for (i=0; i<suffixlen; i++)
735 + ip[16-suffixlen+i] = suffix[i];
739 +static long int fromhex(unsigned char c) {
740 + if (c>='0' && c<='9')
742 + else if (c>='A' && c<='F')
744 + else if (c>='a' && c<='f')
749 +unsigned int ip6_scan_flat(char *s,char ip[16])
753 + for (i=0; i<16; i++) {
756 + if (tmp<0) return 0;
759 + if (tmp<0) return 0;
764 diff -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
770 #include "printrecord.h"
776 if (!stralloc_catulong0(out,ch,0)) return 0;
779 + else if (byte_equal(misc,2,DNS_T_AAAA)) {
780 + char ip6str[IP6_FMT];
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;
789 if (!stralloc_cats(out," ")) return 0;
790 uint16_unpack_big(misc,&u16);
791 diff -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 @@
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);
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);
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);
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);
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);
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);
871 + if (dns_domain_equal(d,"\016ipv6-localhost\0") ||
872 + dns_domain_equal(d,"\015ipv6-loopback\0"))
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);
885 + if (dns_domain_equal(d,"\015ipv6-localnet\0"))
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);
898 + if (dns_domain_equal(d,"\020ipv6-mcastprefix\0"))
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);
911 + if (dns_domain_equal(d,"\15ipv6-allnodes\0"))
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);
924 + if (dns_domain_equal(d,"\17ipv6-allrouters\0"))
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);
937 + if (dns_domain_equal(d,"\15ipv6-allhosts\0"))
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);
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;
953 diff -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
959 +long int fromhex(unsigned char c) {
960 + if (c>='0' && c<='9')
962 + else if (c>='A' && c<='F')
964 + else if (c>='a' && c<='f')
969 +unsigned int scan_0x(register const char *s,register unsigned int *u)
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;
981 diff -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
986 extern int socket_tcp(void);
987 extern int socket_udp(void);
988 +extern int socket_tcp6(void);
989 +extern int socket_udp6(void);
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 *);
1010 extern void socket_tryreservein(int,int);
1012 diff -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
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");
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");
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");
1034 diff -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
1048 char dptr[DNS_NAME4_DOMAIN];
1049 +char d6ptr[DNS_NAME6_DOMAIN];
1051 char strnum[FMT_ULONG];
1061 @@ -338,6 +341,28 @@
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);
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);
1079 + if (line.s[0] == '6') {
1080 + dns_name6_domain(d6ptr,ip6);
1081 + rr_start(DNS_T_PTR,ttl,ttd,loc);
1089 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
1090 diff -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
1100 #define FATAL "tinydns-edit: fatal: "
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");
1113 static char *target;
1115 +char targetip6[16];
1124 char ipstr[IP4_FMT];
1125 +char ip6str[IP6_FMT];
1126 char strnum[FMT_ULONG];
1128 static char *names[26];
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 = '@';
1139 @@ -104,7 +111,11 @@
1140 if (!dns_domain_fromdot(&target,*argv,str_len(*argv))) nomem();
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();
1147 + if (!ip4_scan(*argv,targetip)) die_usage();
1153 if (!dns_domain_fromdot(&names[i],f[0].s,f[0].len)) nomem();
1156 - case '+': case '=':
1157 + case '+': case '=': case '6': case '3':
1161 @@ -203,6 +214,18 @@
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");
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();
1188 + if (!stralloc_catb(&f[0],ipstr,ip4_fmt(ipstr,targetip))) nomem();
1191 case '.': case '&': case '@':
1192 for (i = 0;i < 26;++i)