diff options
-rw-r--r-- | src/include/s6-dns/s6dns-message.h | 1 | ||||
-rw-r--r-- | src/libs6dns/deps-lib/s6dns | 1 | ||||
-rw-r--r-- | src/libs6dns/s6dns_message_get_domain_nodecode.c | 2 | ||||
-rw-r--r-- | src/libs6dns/s6dns_message_parse_question.c | 21 | ||||
-rw-r--r-- | src/libs6dns/s6dns_message_parse_question_nodecode.c | 28 |
5 files changed, 34 insertions, 19 deletions
diff --git a/src/include/s6-dns/s6dns-message.h b/src/include/s6-dns/s6dns-message.h index eb9c378..04d0f79 100644 --- a/src/include/s6-dns/s6dns-message.h +++ b/src/include/s6-dns/s6dns-message.h @@ -188,6 +188,7 @@ extern unsigned int s6dns_message_parse_next (s6dns_message_counts_t *, s6dns_me /* For when you want to write a cache */ +extern int s6dns_message_parse_question_nodecode (s6dns_message_counts_t *, s6dns_domain_t *, uint16_t *, char const *, unsigned int, unsigned int *) ; extern int s6dns_message_parse_question (s6dns_message_counts_t *, s6dns_domain_t *, uint16_t *, char const *, unsigned int, unsigned int *) ; #endif diff --git a/src/libs6dns/deps-lib/s6dns b/src/libs6dns/deps-lib/s6dns index 266b574..818e913 100644 --- a/src/libs6dns/deps-lib/s6dns +++ b/src/libs6dns/deps-lib/s6dns @@ -84,6 +84,7 @@ s6dns_message_parse_getrr.o s6dns_message_parse_init.o s6dns_message_parse_next.o s6dns_message_parse_question.o +s6dns_message_parse_question_nodecode.o s6dns_message_parse_skipqd.o s6dns_rci_free.o s6dns_rci_here.o diff --git a/src/libs6dns/s6dns_message_get_domain_nodecode.c b/src/libs6dns/s6dns_message_get_domain_nodecode.c index 9774527..d3678db 100644 --- a/src/libs6dns/s6dns_message_get_domain_nodecode.c +++ b/src/libs6dns/s6dns_message_get_domain_nodecode.c @@ -4,6 +4,7 @@ #include <errno.h> #include <skalibs/posixishard.h> +#include <skalibs/bytestr.h> #include <s6-dns/s6dns-message.h> @@ -45,5 +46,6 @@ size_t s6dns_message_get_domain_nodecode (char *out, size_t outmax, char const * } else return (errno = EPROTONOSUPPORT, 0) ; /* unsupported extension */ } + case_lowerb(out, w) ; return w ; } diff --git a/src/libs6dns/s6dns_message_parse_question.c b/src/libs6dns/s6dns_message_parse_question.c index 780ec22..484774c 100644 --- a/src/libs6dns/s6dns_message_parse_question.c +++ b/src/libs6dns/s6dns_message_parse_question.c @@ -1,26 +1,9 @@ /* ISC license. */ -#include <errno.h> - -#include <skalibs/posixishard.h> -#include <skalibs/uint16.h> - -#include <s6-dns/s6dns-constants.h> +#include <s6-dns/s6dns-domain.h> #include <s6-dns/s6dns-message.h> int s6dns_message_parse_question (s6dns_message_counts_t *counts, s6dns_domain_t *name, uint16_t *qtypep, char const *packet, unsigned int packetlen, unsigned int *pos) { - s6dns_domain_t d ; - uint16_t qtype ; - uint16_t qclass ; - if (!counts->qd) return (errno = EINVAL, 0) ; - if (!s6dns_message_get_domain(&d, 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) ; - counts->qd-- ; - *name = d ; - *qtypep = qtype ; - return 1 ; + return s6dns_message_parse_question_nodecode(counts, name, qtypep, packet, packetlen, pos) && s6dns_domain_decode(name) ; } diff --git a/src/libs6dns/s6dns_message_parse_question_nodecode.c b/src/libs6dns/s6dns_message_parse_question_nodecode.c new file mode 100644 index 0000000..f6cc4a7 --- /dev/null +++ b/src/libs6dns/s6dns_message_parse_question_nodecode.c @@ -0,0 +1,28 @@ +/* ISC license. */ + +#include <stdint.h> +#include <errno.h> + +#include <skalibs/posixishard.h> +#include <skalibs/uint16.h> + +#include <s6-dns/s6dns-constants.h> +#include <s6-dns/s6dns-domain.h> +#include <s6-dns/s6dns-message.h> + +int s6dns_message_parse_question_nodecode (s6dns_message_counts_t *counts, s6dns_domain_t *name, uint16_t *qtypep, char const *packet, unsigned int packetlen, unsigned int *pos) +{ + s6dns_domain_t d ; + uint16_t qtype ; + uint16_t qclass ; + if (!counts->qd) return (errno = EINVAL, 0) ; + if (!s6dns_message_get_domain_nodecode(&d, 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) ; + counts->qd-- ; + *name = d ; + *qtypep = qtype ; + return 1 ; +} |