From acdc8eed89399a9fa5e7478ee40b928c65e3ab4e Mon Sep 17 00:00:00 2001 From: Martin Lewis Date: Tue, 23 Jun 2020 15:25:08 -0500 Subject: udhcp: add option scanner Added an option scanner to udhcp to enable iteration over packet options. Signed-off-by: Martin Lewis Signed-off-by: Denys Vlasenko --- networking/udhcp/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'networking/udhcp/common.h') diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 6214db06a..81c1dcbdc 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -107,6 +107,12 @@ enum { OPTION_LIST = 0x20, }; +struct dhcp_scan_state { + int overload; + int rem; + uint8_t *optionptr; +}; + /* DHCP option codes (partial list). See RFC 2132 and * http://www.iana.org/assignments/bootp-dhcp-parameters/ * Commented out options are handled by common option machinery, @@ -206,6 +212,8 @@ extern const uint8_t dhcp_option_lengths[] ALIGN1; unsigned FAST_FUNC udhcp_option_idx(const char *name, const char *option_strings); +void init_scan_state(struct dhcp_packet *packet, struct dhcp_scan_state *scan_state) FAST_FUNC; +uint8_t *udhcp_scan_options(struct dhcp_packet *packet, struct dhcp_scan_state *scan_state) FAST_FUNC; uint8_t *udhcp_get_option(struct dhcp_packet *packet, int code) FAST_FUNC; /* Same as above + ensures that option length is 4 bytes * (returns NULL if size is different) -- cgit v1.2.3