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

#include <errno.h>
#include <skalibs/error.h>
#include <skalibs/uint32.h>
#include <s6-dns/s6dns-message.h>

int s6dns_message_get_soa (s6dns_message_rr_soa_t *soa, char const *packet, unsigned int packetlen, unsigned int *pos)
{
  if (!s6dns_message_get_domain(&soa->mname, packet, packetlen, pos)) return 0 ;
  if (!s6dns_message_get_domain(&soa->rname, packet, packetlen, pos)) return 0 ;
  if (*pos + 20 > packetlen) return (errno = EPROTO, 0) ;
  uint32_unpack_big(packet + *pos, &soa->serial) ; *pos += 4 ;
  uint32_unpack_big(packet + *pos, &soa->refresh) ; *pos += 4 ;
  uint32_unpack_big(packet + *pos, &soa->retry) ; *pos += 4 ;
  uint32_unpack_big(packet + *pos, &soa->expire) ; *pos += 4 ;
  uint32_unpack_big(packet + *pos, &soa->minimum) ; *pos += 4 ;
  return 1 ;
}