blob: 3b581273cb0349e7ca3a664e4a64c859296d1aea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/* ISC license. */
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
#include <s6-dns/s6dns-domain.h>
void s6dns_domain_arpafromip6 (s6dns_domain_t *d, char const *ip6, unsigned int mask)
{
register unsigned int i ;
if (mask > 128) mask = 128 ;
mask = mask ? 1 + ((mask-1) >> 2) : 0 ;
d->len = 0 ;
d->s[d->len++] = '.' ;
for (i = 32 - mask ; i < 32 ; i++)
{
unsigned char c = ip6[15-(i>>1)] ;
d->s[d->len++] = fmtscan_asc((i & 1) ? (c >> 4) : (c & 15)) ;
d->s[d->len++] = '.' ;
}
byte_copy(d->s + d->len, 9, "ip6.arpa.") ; d->len += 9 ;
}
|