]> git.ipfire.org Git - thirdparty/glibc.git/commit
resolv: Add DNS packet parsing helpers geared towards wire format
authorFlorian Weimer <fweimer@redhat.com>
Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)
commit857c890d9b42c50c8a94b76d47d4a61ab6d2f49c
tree1b87343a1b57fb9cf28d19c3884066e9f57e6b90
parent78b1a4f0e49064e5dfb686c7cd87bd4df2640b29
resolv: Add DNS packet parsing helpers geared towards wire format

The public parser functions around the ns_rr record type produce
textual domain names, but usually, this is not what we need while
parsing DNS packets within glibc.  This commit adds two new helper
functions, __ns_rr_cursor_init and __ns_rr_cursor_next, for writing
packet parsers, and struct ns_rr_cursor, struct ns_rr_wire as
supporting types.

In theory, it is possible to avoid copying the owner name
into the rname field in __ns_rr_cursor_next, but this would need
more functions that work on compressed names.

Eventually, __res_context_send could be enhanced to preserve the
result of the packet parsing that is necessary for matching the
incoming UDP packets, so that this works does not have to be done
twice.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
include/arpa/nameser.h
resolv/Makefile
resolv/ns_rr_cursor_init.c [new file with mode: 0644]
resolv/ns_rr_cursor_next.c [new file with mode: 0644]
resolv/tst-ns_rr_cursor.c [new file with mode: 0644]