diff -uNr djbdns-1.05.old/axfr-get.c djbdns-1.05/axfr-get.c --- djbdns-1.05.old/axfr-get.c Sun Feb 11 19:11:45 2001 +++ djbdns-1.05/axfr-get.c Sat Apr 5 18:26:54 2003 @@ -209,6 +209,57 @@ if (!stralloc_cats(&line,".:")) return 0; if (!stralloc_catulong0(&line,dist,0)) return 0; } + else if (byte_equal(data,2,DNS_T_SRV)) { + uint16 dist, weight, port; + if (!stralloc_copys(&line,"S")) return 0; + if (!dns_domain_todot_cat(&line,d1)) return 0; + if (!stralloc_cats(&line,"::")) return 0; + pos = x_copy(buf,len,pos,data,2); + uint16_unpack_big(data,&dist); + pos = x_copy(buf,len,pos,data,2); + uint16_unpack_big(data,&weight); + pos = x_copy(buf,len,pos,data,2); + uint16_unpack_big(data,&port); + x_getname(buf,len,pos,&d1); + if (!dns_domain_todot_cat(&line,d1)) return 0; + if (!stralloc_cats(&line,".:")) return 0; + if (!stralloc_catulong0(&line,dist,0)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!stralloc_catulong0(&line,weight,0)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!stralloc_catulong0(&line,port,0)) return 0; + } + else if (byte_equal(data,2,DNS_T_NAPTR)) { + uint16 order, preference; + char flags[255], service[255], regexp[255]; + char fs, ss, rs; + if (!stralloc_copys(&line,"N")) return 0; + if (!dns_domain_todot_cat(&line,d1)) return 0; + if (!stralloc_cats(&line,":")) return 0; + pos = x_copy(buf,len,pos,data,2); + uint16_unpack_big(data,&order); + pos = x_copy(buf,len,pos,data,2); + uint16_unpack_big(data,&preference); + pos = x_copy(buf,len,pos,&fs,1); + pos = x_copy(buf,len,pos,flags,fs); + pos = x_copy(buf,len,pos,&ss,1); + pos = x_copy(buf,len,pos,service,ss); + pos = x_copy(buf,len,pos,&rs,1); + pos = x_copy(buf,len,pos,regexp,rs); + x_getname(buf,len,pos,&d1); + if (!stralloc_catulong0(&line,order,0)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!stralloc_catulong0(&line,preference,0)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!stralloc_catb(&line,flags,fs)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!stralloc_catb(&line,service,ss)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!stralloc_catb(&line,regexp,rs)) return 0; + if (!stralloc_cats(&line,":")) return 0; + if (!dns_domain_todot_cat(&line,d1)) return 0; + if (!stralloc_cats(&line,".")) return 0; + } else if (byte_equal(data,2,DNS_T_A) && (dlen == 4)) { char ipstr[IP4_FMT]; if (!stralloc_copys(&line,"+")) return 0; @@ -216,6 +267,14 @@ if (!stralloc_cats(&line,":")) return 0; x_copy(buf,len,pos,data,4); if (!stralloc_catb(&line,ipstr,ip4_fmt(ipstr,data))) return 0; + } + else if (byte_equal(data,2,DNS_T_PTR)) { + if (!stralloc_copys(&line,"^")) return 0; + if (!dns_domain_todot_cat(&line,d1)) return 0; + if (!stralloc_cats(&line,":")) return 0; + x_getname(buf,len,pos,&d1); + if (!dns_domain_todot_cat(&line,d1)) return 0; + if (!stralloc_cats(&line,".")) return 0; } else { unsigned char ch; diff -uNr djbdns-1.05.old/dns.h djbdns-1.05/dns.h --- djbdns-1.05.old/dns.h Sun Feb 11 19:11:45 2001 +++ djbdns-1.05/dns.h Sat Apr 5 18:25:42 2003 @@ -20,6 +20,8 @@ #define DNS_T_SIG "\0\30" #define DNS_T_KEY "\0\31" #define DNS_T_AAAA "\0\34" +#define DNS_T_SRV "\0\041" +#define DNS_T_NAPTR "\0\43" #define DNS_T_AXFR "\0\374" #define DNS_T_ANY "\0\377" diff -uNr djbdns-1.05.old/parsetype.c djbdns-1.05/parsetype.c --- djbdns-1.05.old/parsetype.c Sun Feb 11 19:11:45 2001 +++ djbdns-1.05/parsetype.c Sun Apr 6 21:33:42 2003 @@ -24,6 +24,8 @@ else if (case_equals(s,"key")) byte_copy(type,2,DNS_T_KEY); else if (case_equals(s,"aaaa")) byte_copy(type,2,DNS_T_AAAA); else if (case_equals(s,"axfr")) byte_copy(type,2,DNS_T_AXFR); + else if (case_equals(s,"srv")) byte_copy(type,2,DNS_T_SRV); + else if (case_equals(s,"naptr")) byte_copy(type,2,DNS_T_NAPTR); else return 0; diff -uNr djbdns-1.05.old/printrecord.c djbdns-1.05/printrecord.c --- djbdns-1.05.old/printrecord.c Sun Feb 11 19:11:45 2001 +++ djbdns-1.05/printrecord.c Sun Apr 6 21:33:54 2003 @@ -82,6 +82,58 @@ if (!stralloc_catulong0(out,ch,0)) return 0; } } + else if (byte_equal(misc,2,DNS_T_SRV)) { + uint16 u16tmp; + if (!stralloc_cats(out," SRV ")) return 0; + pos = dns_packet_copy(buf,len,pos,misc,2); if (!pos) return 0; + uint16_unpack_big(misc,&u16tmp); + pos = dns_packet_copy(buf,len,pos,misc,2); if (!pos) return 0; + uint16_unpack_big(misc,&u16); + if (!stralloc_catulong0(out,u16,0)) return 0; + if (!stralloc_cats(out," ")) return 0; + if (!stralloc_catulong0(out,u16tmp,0)) return 0; + if (!stralloc_cats(out," ")) return 0; + pos = dns_packet_copy(buf,len,pos,misc,2); if (!pos) return 0; + uint16_unpack_big(misc,&u16); + if (!stralloc_catulong0(out,u16,0)) return 0; + if (!stralloc_cats(out," ")) return 0; + pos = dns_packet_getname(buf,len,pos,&d); if (!pos) return 0; + if (!dns_domain_todot_cat(out,d)) return 0; + } + else if (byte_equal(misc,2,DNS_T_NAPTR)) { + char str[255]; + unsigned int oldpos; + if (!stralloc_cats(out," NAPTR ")) return 0; + pos = dns_packet_copy(buf,len,pos,misc,2); if (!pos) return 0; + uint16_unpack_big(misc,&u16); + if (!stralloc_catulong0(out,u16,0)) return 0; + if (!stralloc_cats(out," ")) return 0; + pos = dns_packet_copy(buf,len,pos,misc,2); if (!pos) return 0; + uint16_unpack_big(misc,&u16); + if (!stralloc_catulong0(out,u16,0)) return 0; + if (!stralloc_cats(out," ")) return 0; + pos = dns_packet_copy(buf,len,pos,&ch,1); if (!pos) return 0; + pos = dns_packet_copy(buf,len,pos,str,ch); if (!pos) return 0; + if (!stralloc_cats(out,"\"")) return 0; + if (!stralloc_catb(out,str,ch)) return 0; + if (!stralloc_cats(out,"\" ")) return 0; + pos = dns_packet_copy(buf,len,pos,&ch,1); if (!pos) return 0; + pos = dns_packet_copy(buf,len,pos,str,ch); if (!pos) return 0; + if (!stralloc_cats(out,"\"")) return 0; + if (!stralloc_catb(out,str,ch)) return 0; + if (!stralloc_cats(out,"\" ")) return 0; + pos = dns_packet_copy(buf,len,pos,&ch,1); if (!pos) return 0; + pos = dns_packet_copy(buf,len,pos,str,ch); if (!pos) return 0; + if (!stralloc_cats(out,"\"")) return 0; + if (!stralloc_catb(out,str,ch)) return 0; + if (!stralloc_cats(out,"\" ")) return 0; + pos = dns_packet_getname(buf,len,pos,&d); if (!pos) return 0; + oldpos = out->len; + if (!dns_domain_todot_cat(out,d)) return 0; + if (out->len == oldpos) + if (!stralloc_cats(out,".")) return 0; + } + else { if (!stralloc_cats(out," ")) return 0; uint16_unpack_big(misc,&u16); diff -uNr djbdns-1.05.old/tinydns-data.c djbdns-1.05/tinydns-data.c --- djbdns-1.05.old/tinydns-data.c Sun Feb 11 19:11:45 2001 +++ djbdns-1.05/tinydns-data.c Sat Apr 5 18:27:50 2003 @@ -196,6 +196,8 @@ char type[2]; char soa[20]; char buf[4]; + char naptr[4]; + char srv[6]; umask(022); @@ -439,6 +441,73 @@ rr_start(type,ttl,ttd,loc); rr_add(f[2].s,f[2].len); rr_finish(d1); + break; + + case 'N': + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); + if (!dns_domain_fromdot(&d2,f[6].s,f[6].len)) nomem(); + if (!stralloc_0(&f[7])) nomem(); + if (!scan_ulong(f[7].s,&ttl)) ttl = TTL_POSITIVE; + ttdparse(&f[8],ttd); + locparse(&f[9],loc); + + if (!stralloc_0(&f[1])) nomem(); + if (!scan_ulong(f[1].s,&u)) u = 0; + uint16_pack_big(naptr,u); + if (!stralloc_0(&f[2])) nomem(); + if (!scan_ulong(f[2].s,&u)) u = 0; + uint16_pack_big(naptr + 2,u); + + txtparse(&f[3]); if (f[3].len > 255) + syntaxerror(": it is not allowed more than 255 chars in a label"); + txtparse(&f[4]); if (f[4].len > 255) + syntaxerror(": it is not allowed more than 255 chars in a label"); + txtparse(&f[5]); if (f[5].len > 255) + syntaxerror(": it is not allowed more than 255 chars in a label"); + + rr_start(DNS_T_NAPTR,ttl,ttd,loc); + rr_add(naptr,4); + + ch = f[3].len; rr_add(&ch,1); + rr_add(f[3].s, f[3].len); + ch = f[4].len; rr_add(&ch,1); + rr_add(f[4].s, f[4].len); + ch = f[5].len; rr_add(&ch,1); + rr_add(f[5].s, f[5].len); + + rr_addname(d2); + rr_finish(d1); + break; + + case 'S': + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); + if (!stralloc_0(&f[6])) nomem(); + if (!scan_ulong(f[6].s,&ttl)) ttl = TTL_POSITIVE; + ttdparse(&f[7],ttd); + locparse(&f[8],loc); + + if (!stralloc_0(&f[1])) nomem(); + + if (byte_chr(f[2].s,f[2].len,'.') >= f[2].len) { + if (!stralloc_cats(&f[2],".srv.")) nomem(); + if (!stralloc_catb(&f[2],f[0].s,f[0].len)) nomem(); + } + if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem(); + + if (!stralloc_0(&f[4])) nomem(); + if (!scan_ulong(f[4].s,&u)) u = 0; + uint16_pack_big(srv,u); + if (!stralloc_0(&f[5])) nomem(); + if (!scan_ulong(f[5].s,&u)) u = 0; + uint16_pack_big(srv + 2,u); + if (!stralloc_0(&f[3])) nomem(); + if (!scan_ulong(f[3].s,&u)) nomem(); + uint16_pack_big(srv + 4,u); + + rr_start(DNS_T_SRV,ttl,ttd,loc); + rr_add(srv,6); + rr_addname(d2); + rr_finish(d1); break; default: