]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
no need to pass dict_dhcpv4 to all of the dhcpv4 functions
authorAlan T. DeKok <aland@freeradius.org>
Sat, 18 Dec 2021 15:58:10 +0000 (10:58 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Dec 2021 17:22:11 +0000 (12:22 -0500)
src/protocols/dhcpv4/decode.c
src/protocols/dhcpv4/dhcpv4.h
src/protocols/dhcpv4/packet.c

index 5be183265d601fbe59aff1f1c21be2fb9f771824..69a19427737ea0bbcea80ecd12bc4b613de96a36 100644 (file)
@@ -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;
index 42bbf58da3bdaf99b51e9c7fa426aa3a14c7d1e4..23e2ef51be34bc02c9863c974e1920974a23b541 100644 (file)
@@ -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);
 
 /*
index 55b740d49cf9010133b0da7afe55b6e575c33c9b..150b0d7ed8b8aadead303b4dd398f331072806a5 100644 (file)
@@ -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);