fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
dns_nd.c
Go to the documentation of this file.
1#include "byte.h"
2#include "fmt.h"
3#include "ip.h"
4#include "dnsresolv.h"
5
13int dns_name4_domain(char name[DNS_NAME4_DOMAIN],const char ip[4])
14{
15 unsigned int namelen;
16 unsigned int i;
17
18 namelen = 0;
19 i = fmt_ulong(name + namelen + 1,(unsigned long) (unsigned char) ip[3]);
20 name[namelen++] = i;
21 namelen += i;
22 i = fmt_ulong(name + namelen + 1,(unsigned long) (unsigned char) ip[2]);
23 name[namelen++] = i;
24 namelen += i;
25 i = fmt_ulong(name + namelen + 1,(unsigned long) (unsigned char) ip[1]);
26 name[namelen++] = i;
27 namelen += i;
28 i = fmt_ulong(name + namelen + 1,(unsigned long) (unsigned char) ip[0]);
29 name[namelen++] = i;
30 namelen += i;
31 byte_copy(name + namelen,14,"\7in-addr\4arpa\0");
32 return namelen+14;
33}
34
35int dns_name6_domain(char name[DNS_NAME6_DOMAIN],const char ip[16])
36{
37 unsigned int j;
38
39 for (j = 0; j < 16; j++) {
40 name[j * 4] = 1;
41 name[j * 4 + 1] = tohex(ip[15 - j] & 15);
42 name[j * 4 + 2] = 1;
43 name[j * 4 + 3] = tohex((unsigned char)ip[15 - j] >> 4);
44 }
45 byte_copy(name + 4 * 16,10,"\3ip6\4arpa\0");
46 return 4 * 16 + 10;
47}
48
int dns_name4_domain(char name[DNS_NAME4_DOMAIN], const char ip[4])
Definition: dns_nd.c:13
int dns_name6_domain(char name[DNS_NAME6_DOMAIN], const char ip[16])
Definition: dns_nd.c:35
conversion function declarations
unsigned int fmt_ulong(char *, unsigned long)
Definition: fmt.c:44
char tohex(char)
Definition: fmt.c:70
void byte_copy(void *, unsigned int, const void *)
Definition: byte.c:20
#define DNS_NAME4_DOMAIN
Definition: dnsresolv.h:165
#define DNS_NAME6_DOMAIN
Definition: dnsresolv.h:179