ucspi-ssl  0.99e
TLS encryption for IPv6 communication
dns_nd6.c
Go to the documentation of this file.
1 #include "byte.h"
2 #include "fmt.h"
3 #include "dns.h"
4 
5 /* RFC1886:
6  * 4321:0:1:2:3:4:567:89ab
7  * ->
8  * 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.
9  */
10 
11 static inline char tohex(char c) {
12  return c>=10?c-10+'a':c+'0';
13 }
14 
15 int dns_name6_domain(char name[DNS_NAME6_DOMAIN],char ip[16])
16 {
17  unsigned int j;
18 
19  for (j=0; j<16; j++) {
20  name[j*4]=1;
21  name[j*4+1]=tohex(ip[15-j] & 15);
22  name[j*4+2]=1;
23  name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4);
24  }
25  byte_copy(name + 4*16,10,"\3ip6\4arpa\0");
26  return 4*16+10;
27 }
28 
void byte_copy(void *, unsigned int, const void *)
#define DNS_NAME6_DOMAIN
Definition: dns.h:92
int dns_name6_domain(char name[DNS_NAME6_DOMAIN], char ip[16])
Definition: dns_nd6.c:15