diff options
Diffstat (limited to 'tinydns-data.c')
-rw-r--r-- | tinydns-data.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/tinydns-data.c b/tinydns-data.c index ba82f84..4d66865 100644 --- a/tinydns-data.c +++ b/tinydns-data.c @@ -8,6 +8,7 @@ #include "byte.h" #include "fmt.h" #include "ip4.h" +#include "ip6.h" #include "exit.h" #include "case.h" #include "scan.h" @@ -65,16 +66,23 @@ void ipprefix_cat(stralloc *out,char *s) char ch; unsigned int j; - for (;;) - if (*s == '.') - ++s; - else { - j = scan_ulong(s,&u); - if (!j) return; - s += j; - ch = u; - if (!stralloc_catb(out,&ch,1)) nomem(); - } + if (*s=='s') { + ++s; + if (!stralloc_catb(out,"s",1) || !stralloc_cats(out,s)) nomem(); + } else { + if (*s=='f') ++s; + if (!stralloc_catb(out,"f",1)) nomem(); + for (;;) + if (*s == '.') + ++s; + else { + j = scan_ulong(s,&u); + if (!j) return; + s += j; + ch = u; + if (!stralloc_catb(out,&ch,1)) nomem(); + } + } } void txtparse(stralloc *sa) @@ -172,6 +180,7 @@ static stralloc f[NUMFIELDS]; static char *d1; static char *d2; char dptr[DNS_NAME4_DOMAIN]; +char d6ptr[DNS_NAME6_DOMAIN]; char strnum[FMT_ULONG]; @@ -193,6 +202,7 @@ int main() char loc[2]; unsigned long u; char ip[4]; + char ip6[16]; char type[2]; char soa[20]; char buf[4]; @@ -339,6 +349,33 @@ int main() } break; + case '6': case '3': + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); + if (!stralloc_0(&f[2])) nomem(); + if (!scan_ulong(f[2].s,&ttl)) ttl = TTL_POSITIVE; + ttdparse(&f[3],ttd); + locparse(&f[4],loc); + + if (!stralloc_0(&f[1])) nomem(); + if (ip6_scan_flat(f[1].s,ip6)) { + rr_start(DNS_T_AAAA,ttl,ttd,loc); + rr_add(ip6,16); + rr_finish(d1); + + if (line.s[0] == '6') { /* emit both .ip6.arpa and .ip6.int */ + dns_name6_domain(d6ptr,ip6,DNS_IP6_ARPA); + rr_start(DNS_T_PTR,ttl,ttd,loc); + rr_addname(d1); + rr_finish(d6ptr); + + dns_name6_domain(d6ptr,ip6,DNS_IP6_INT); + rr_start(DNS_T_PTR,ttl,ttd,loc); + rr_addname(d1); + rr_finish(d6ptr); + } + } + break; + case '@': if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); if (!stralloc_0(&f[4])) nomem(); |