summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_domain_arpafromip4.c
blob: d77938f3ccdd6b10d876d090977dabf39420cac8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <skalibs/bytestr.h>
#include <skalibs/uint.h>
#include <s6-dns/s6dns-domain.h>

void s6dns_domain_arpafromip4 (s6dns_domain_t *d, char const *ip)
{
  register unsigned int i = 0 ;
  d->len = 0 ;
  d->s[d->len++] = '.' ;  
  for (; i < 4 ; i++)
  {
    register unsigned int u = ((unsigned char *)ip)[3-i] ;
    d->len += uint_fmt(d->s + d->len, u) ;
    d->s[d->len++] = '.' ;
  }
  byte_copy(d->s + d->len, 13, "in-addr.arpa.") ; d->len += 13 ;
}