diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-21 19:47:31 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-21 19:47:31 +0000 |
commit | 1fb7cdff0722039f6b103e9782ca8a25b8545b1b (patch) | |
tree | 374d5b281c361a12e717c17f8e79e4f8ed84db7e /src/libs6dns | |
parent | 9e82df990cc70cdc123c531061204d9f1442c42b (diff) | |
download | s6-dns-1fb7cdff0722039f6b103e9782ca8a25b8545b1b.tar.xz |
Add s6dns_message_parse_question
Diffstat (limited to 'src/libs6dns')
-rw-r--r-- | src/libs6dns/deps-lib/s6dns | 1 | ||||
-rw-r--r-- | src/libs6dns/s6dns_message_parse_question.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/libs6dns/deps-lib/s6dns b/src/libs6dns/deps-lib/s6dns index 95c2bf5..e9646fa 100644 --- a/src/libs6dns/deps-lib/s6dns +++ b/src/libs6dns/deps-lib/s6dns @@ -54,6 +54,7 @@ s6dns_message_parse.o s6dns_message_parse_getrr.o s6dns_message_parse_init.o s6dns_message_parse_next.o +s6dns_message_parse_question.o s6dns_message_parse_skipqd.o s6dns_rci_free.o s6dns_rci_here.o diff --git a/src/libs6dns/s6dns_message_parse_question.c b/src/libs6dns/s6dns_message_parse_question.c new file mode 100644 index 0000000..e2b639f --- /dev/null +++ b/src/libs6dns/s6dns_message_parse_question.c @@ -0,0 +1,20 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/posixishard.h> +#include <skalibs/uint16.h> + +#include <s6-dns/s6dns-constants.h> +#include <s6-dns/s6dns-message.h> + +int s6dns_message_parse_question (s6dns_domain_t *name, uint16_t *qtype, char const *packet, unsigned int packetlen, unsigned int *pos) +{ + uint16_t qclass ; + if (!s6dns_message_get_domain(name, packet, packetlen, pos)) return 0 ; + if (*pos + 4 > packetlen) return (errno = EPROTO, 0) ; + uint16_unpack_big(packet + *pos, qtype) ; *pos += 2 ; + uint16_unpack_big(packet + *pos, &qclass) ; *pos += 2 ; + if (qclass != S6DNS_C_IN) return (errno = ENOTSUP, 0) ; + return 1 ; +} |