From: Alan T. DeKok Date: Sat, 18 Dec 2021 15:58:10 +0000 (-0500) Subject: no need to pass dict_dhcpv4 to all of the dhcpv4 functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f15273262edadca6683cb70cf55c5ea9132e666;p=thirdparty%2Ffreeradius-server.git no need to pass dict_dhcpv4 to all of the dhcpv4 functions --- diff --git a/src/protocols/dhcpv4/decode.c b/src/protocols/dhcpv4/decode.c index 5be183265d..69a1942773 100644 --- a/src/protocols/dhcpv4/decode.c +++ b/src/protocols/dhcpv4/decode.c @@ -499,13 +499,12 @@ next: * * @param[in] ctx context to alloc new attributes in. * @param[out] out Where to write the decoded options. - * @param[in] dict to lookup attributes in. * @param[in] data to parse. * @param[in] data_len of data to parse. * @param[in] decode_ctx Unused. */ ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, - fr_dict_t const *dict, uint8_t const *data, size_t data_len, UNUSED void *decode_ctx) + uint8_t const *data, size_t data_len, UNUSED void *decode_ctx) { ssize_t ret; uint8_t const *p = data; @@ -518,7 +517,7 @@ ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, FR_PROTO_HEX_DUMP(data, data_len, NULL); - parent = fr_dict_root(dict); + parent = fr_dict_root(dict_dhcpv4); /* * Padding / End of options @@ -593,13 +592,21 @@ static ssize_t fr_dhcpv4_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, return data_len; } +static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_t const *dict, + uint8_t const *data, size_t data_len, void *decode_ctx) +{ + fr_assert(dict == dict_dhcpv4); + + return fr_dhcpv4_decode_option(ctx, out, data, data_len, decode_ctx); +} + /* * Test points */ extern fr_test_point_pair_decode_t dhcpv4_tp_decode_pair; fr_test_point_pair_decode_t dhcpv4_tp_decode_pair = { .test_ctx = decode_test_ctx, - .func = fr_dhcpv4_decode_option + .func = decode_option }; extern fr_test_point_proto_decode_t dhcpv4_tp_decode_proto; diff --git a/src/protocols/dhcpv4/dhcpv4.h b/src/protocols/dhcpv4/dhcpv4.h index 42bbf58da3..23e2ef51be 100644 --- a/src/protocols/dhcpv4/dhcpv4.h +++ b/src/protocols/dhcpv4/dhcpv4.h @@ -161,7 +161,7 @@ void fr_dhcpv4_print_hex(FILE *fp, uint8_t const *packet, size_t packet_len); /* * decode.c */ -ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict, +ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t len, void *decode_ctx); /* diff --git a/src/protocols/dhcpv4/packet.c b/src/protocols/dhcpv4/packet.c index 55b740d49c..150b0d7ed8 100644 --- a/src/protocols/dhcpv4/packet.c +++ b/src/protocols/dhcpv4/packet.c @@ -205,7 +205,7 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, while (p < end) { if (p[0] == 0) break; /* padding */ - len = fr_dhcpv4_decode_option(ctx, &tmp, dict_dhcpv4, p, (end - p), NULL); + len = fr_dhcpv4_decode_option(ctx, &tmp, p, (end - p), NULL); if (len <= 0) { fr_pair_list_free(&tmp); return len; @@ -236,7 +236,7 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, while (p < end) { if (p[0] == 0) break; /* padding */ - len = fr_dhcpv4_decode_option(ctx, &tmp, dict_dhcpv4, + len = fr_dhcpv4_decode_option(ctx, &tmp, p, end - p, NULL); if (len <= 0) { fr_pair_list_free(&tmp); @@ -255,7 +255,7 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, while (p < end) { if (p[0] == 0) break; /* padding */ - len = fr_dhcpv4_decode_option(ctx, &tmp, dict_dhcpv4, + len = fr_dhcpv4_decode_option(ctx, &tmp, p, end - p, NULL); if (len <= 0) { fr_pair_list_free(&tmp);