]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add decode flags for nested structs
authorAlan T. DeKok <aland@freeradius.org>
Thu, 13 Jul 2023 17:26:12 +0000 (13:26 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 13 Jul 2023 17:30:32 +0000 (13:30 -0400)
nothing uses them right now, but it's a good way to track what
needs to be changed.

src/protocols/dhcpv6/decode.c
src/protocols/dhcpv6/dhcpv6.h
src/protocols/radius/decode.c
src/protocols/radius/radius.h

index 847d27a4cb8bb073b246457ee13c868c02b88529..4ad26ab3ee76910c7f464f14d28d405256a31c47 100644 (file)
@@ -73,6 +73,7 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
        ssize_t                 slen;
        fr_pair_t               *vp = NULL;
        uint8_t                 prefix_len;
+       fr_dhcpv6_decode_ctx_t  *packet_ctx = decode_ctx;
 
        FR_PROTO_HEX_DUMP(data, data_len, "decode_value");
 
@@ -175,7 +176,7 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
                break;
 
        case FR_TYPE_STRUCT:
-               slen = fr_struct_from_network(ctx, out, parent, data, data_len, false,
+               slen = fr_struct_from_network(ctx, out, parent, data, data_len, packet_ctx->struct_nested,
                                              decode_ctx, decode_value_trampoline, decode_tlv_trampoline);
                if (slen < 0) goto raw;
 
index 2b880655f07d7f8a7c3d8ca79b2be17c1f177c46..cce442f2b821dca855a6a92055ad80b7d920826a 100644 (file)
@@ -142,6 +142,7 @@ typedef struct {
        uint32_t                transaction_id;         //!< previous transaction ID
        uint8_t                 *duid;                  //!< the expected DUID, in wire format
        size_t                  duid_len;               //!< length of the expected DUID
+       bool                    struct_nested;          //!< decode structs as nested
 } fr_dhcpv6_decode_ctx_t;
 
 /*
index 69256ac1354c52d381b73d9f9c444068a610e8eb..b6840f5996ccca62e005c1ba8fc7517cd3825a9f 100644 (file)
@@ -1750,7 +1750,7 @@ ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
                 *      attribute, OR it's already been grouped
                 *      into a contiguous memory buffer.
                 */
-               ret = fr_struct_from_network(ctx, out, parent, p, attr_len, false,
+               ret = fr_struct_from_network(ctx, out, parent, p, attr_len, packet_ctx->struct_nested,
                                             packet_ctx, decode_value_trampoline, decode_tlv_trampoline);
                if (ret < 0) goto raw;
                return attr_len;
index 02227fc31eb6efc61070731f39723c26b9c9316f..6701d8650d57b308fa1a71e6017adbc6726cad39 100644 (file)
@@ -172,6 +172,7 @@ typedef struct {
        int                     salt_offset;            //!< for tunnel passwords
        bool                    tunnel_password_zeros;  //!< check for trailing zeros on decode
        bool                    disallow_tunnel_passwords; //!< not all packets can have tunnel passwords
+       bool                    struct_nested;          //!< decode structs as nested
 
        uint8_t                 tag;                    //!< current tag for encoding
        fr_radius_tag_ctx_t     **tags;                 //!< for decoding tagged attributes