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

#include <errno.h>

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

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

int s6dns_message_get_srv (s6dns_message_rr_srv_t *srv, char const *packet, unsigned int packetlen, unsigned int *pos)
{
  if (*pos + 7 > packetlen) return (errno = EPROTO, 0) ;
  uint16_unpack_big(packet + *pos, &srv->priority) ; *pos += 2 ;
  uint16_unpack_big(packet + *pos, &srv->weight) ; *pos += 2 ;
  uint16_unpack_big(packet + *pos, &srv->port) ; *pos += 2 ;
  return s6dns_message_get_domain(&srv->target, packet, packetlen, pos) ;
}