From: Alan T. DeKok Date: Thu, 13 Jul 2023 17:26:12 +0000 (-0400) Subject: add decode flags for nested structs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=768db6143ae4e43e4534fcf98294a0269c4b6a69;p=thirdparty%2Ffreeradius-server.git add decode flags for nested structs nothing uses them right now, but it's a good way to track what needs to be changed. --- diff --git a/src/protocols/dhcpv6/decode.c b/src/protocols/dhcpv6/decode.c index 847d27a4cb8..4ad26ab3ee7 100644 --- a/src/protocols/dhcpv6/decode.c +++ b/src/protocols/dhcpv6/decode.c @@ -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; diff --git a/src/protocols/dhcpv6/dhcpv6.h b/src/protocols/dhcpv6/dhcpv6.h index 2b880655f07..cce442f2b82 100644 --- a/src/protocols/dhcpv6/dhcpv6.h +++ b/src/protocols/dhcpv6/dhcpv6.h @@ -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; /* diff --git a/src/protocols/radius/decode.c b/src/protocols/radius/decode.c index 69256ac1354..b6840f5996c 100644 --- a/src/protocols/radius/decode.c +++ b/src/protocols/radius/decode.c @@ -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; diff --git a/src/protocols/radius/radius.h b/src/protocols/radius/radius.h index 02227fc31eb..6701d8650d5 100644 --- a/src/protocols/radius/radius.h +++ b/src/protocols/radius/radius.h @@ -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