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

#include <string.h>
#include <skalibs/types.h>
#include <s6-dns/s6dns-domain.h>

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