From c44d8b51ffb5a413f8bbdbd9991bbc573853e397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henryk=20Pl=C3=B6tz?= Date: Fri, 3 Oct 2014 20:04:14 +0200 Subject: Apply patch djbdns-1.05-test27.diff.bz2 Source was http://www.fefe.de/dns/djbdns-1.05-test27.diff.bz2, SHA1 f0380ec1866f49c0bcf6369a923ac0a4a5095da8 --- dns_nd6.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 dns_nd6.c (limited to 'dns_nd6.c') diff --git a/dns_nd6.c b/dns_nd6.c new file mode 100644 index 0000000..6dbeb89 --- /dev/null +++ b/dns_nd6.c @@ -0,0 +1,35 @@ +#include "byte.h" +#include "fmt.h" +#include "dns.h" + +/* RFC1886: + * 4321:0:1:2:3:4:567:89ab + * -> + * 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. + * 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.ARPA. + */ + +extern char tohex(char num); + +unsigned int mkint(unsigned char a,unsigned char b) { + return ((unsigned int)a << 8) + (unsigned int)b; +} + +int dns_name6_domain(char name[DNS_NAME6_DOMAIN],const char ip[16],int t) +{ + unsigned int j; + + for (j=0; j<16; j++) { + name[j*4]=1; + name[j*4+1]=tohex(ip[15-j] & 15); + name[j*4+2]=1; + name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4); + } + if (t==DNS_IP6_INT) + byte_copy(name + 4*16,9,"\3ip6\3int\0"); + else if (t==DNS_IP6_ARPA) + byte_copy(name + 4*16,10,"\3ip6\4arpa\0"); + else return 0; + return 4*16+9+t; +} + -- cgit v1.2.3