summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_message_get_mx.c
blob: 5b9f0d61b1322b26b1ad97a6f2cf42a5734535f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* ISC license. */

#include <errno.h>

#include <skalibs/posixishard.h>
#include <skalibs/uint16.h>

#include <s6-dns/s6dns-message.h>

int s6dns_message_get_mx (s6dns_message_rr_mx_t *mx, char const *packet, unsigned int packetlen, unsigned int *pos)
{
  if (*pos + 3 > packetlen) return (errno = EPROTO, 0) ;
  uint16_unpack_big(packet + *pos, &mx->preference) ; *pos += 2 ;
  return s6dns_message_get_domain(&mx->exchange, packet, packetlen, pos) ;
}