]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
prepare for decoding TLVs inside of struct_from_network()
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Nov 2020 19:54:24 +0000 (14:54 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Nov 2020 20:16:15 +0000 (15:16 -0500)
rearrange arguments to match struct_to_network
add (currently unused) decode_tlv function

src/lib/util/struct.c
src/lib/util/struct.h
src/protocols/arp/base.c
src/protocols/dhcpv6/decode.c
src/protocols/radius/decode.c
src/protocols/tacacs/decode.c

index 0cbef332de57718fb982260a7ea64fc66fe68e1a..d4ad7ee123d6251ca9bacec9701059cd4d158415 100644 (file)
@@ -64,8 +64,8 @@ fr_pair_t *fr_raw_from_network(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, ui
  */
 ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_cursor_t *cursor,
                               fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len,
-                              fr_dict_attr_t const **child_p,
-                              fr_decode_value_t decode_value, void *decoder_ctx)
+                              fr_dict_attr_t const **child_p, void *decoder_ctx,
+                              fr_decode_value_t decode_value, fr_decode_value_t decode_tlv)
 {
        unsigned int            child_num;
        uint8_t const           *p = data, *end = data + data_len;
@@ -323,7 +323,7 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_cursor_t *cursor,
                        fr_assert(child->type == FR_TYPE_STRUCT);
 
                        slen = fr_struct_from_network(ctx, &child_cursor, child, p, end - p, child_p,
-                                                     decode_value, decoder_ctx);
+                                                     decoder_ctx, decode_value, decode_tlv);
                        if (slen <= 0) goto unknown_child;
                        p += slen;
                }
index cdd96ccdf5682a412f939974324d63026977c077..dcb7c4c697000c46b07a6ca50ac8bf0413b38198 100644 (file)
@@ -38,8 +38,8 @@ typedef ssize_t (*fr_decode_value_t)(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_di
 
 ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_cursor_t *cursor,
                               fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len,
-                              fr_dict_attr_t const **child,
-                              fr_decode_value_t decode_value, void *decoder_ctx) CC_HINT(nonnull(2,3,4));
+                              fr_dict_attr_t const **child, void *decoder_ctx,
+                              fr_decode_value_t decode_value, fr_decode_value_t decode_tlv) CC_HINT(nonnull(2,3,4));
 
 typedef ssize_t (*fr_encode_dbuff_t)(fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth,
                                     fr_cursor_t *cursor, void *encoder_ctx);
index bc3369e83c26b1560f50a9fc96bb8326172dfdcc..c51351f82105f34f4e9811e1a5ef257a7d707cba 100644 (file)
@@ -260,7 +260,8 @@ ssize_t fr_arp_decode(TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len,
         */
        fr_pair_list_init(list);
        fr_cursor_init(&cursor, list);
-       return fr_struct_from_network(ctx, &cursor, attr_arp_packet, packet, FR_ARP_PACKET_SIZE, &child, NULL, NULL);
+       return fr_struct_from_network(ctx, &cursor, attr_arp_packet, packet, FR_ARP_PACKET_SIZE, &child,
+                                     NULL, NULL, NULL);
 }
 
 int fr_arp_init(void)
index 61cbed1e645e9183b49f67dccf046d59e44a39eb..ba3f92b56b0aaab0aca875dbf3949dabcb164339 100644 (file)
@@ -224,7 +224,7 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_t cons
 
        case FR_TYPE_STRUCT:
                slen = fr_struct_from_network(ctx, cursor, parent, data, data_len, &tlv,
-                                              decode_value_trampoline, decoder_ctx);
+                                             decoder_ctx, decode_value_trampoline, NULL);
                if (slen < 0) return slen;
 
                if (tlv) {
index 12b957216d1be82eae7c82765289abfada4ea235..c462671c40b7990be26249e8133b203685b79d02 100644 (file)
@@ -1447,7 +1447,7 @@ ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dic
                 *      into a contiguous memory buffer.
                 */
                ret = fr_struct_from_network(ctx, cursor, parent, p, attr_len, &child,
-                                            decode_value, decoder_ctx);
+                                            decoder_ctx, decode_value, NULL);
                if (ret < 0) goto raw;
 
                /*
index d1735bf1ef806aee80572985b746c7db1a203d6f..b633a78ab6318d02c0efe257b54390dd502c476b 100644 (file)
@@ -232,7 +232,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l
        /*
         *      Call the struct encoder to do the actual work.
         */
-       if (fr_struct_from_network(ctx, cursor, attr_tacacs_packet, buffer, buffer_len, &tlv, NULL, NULL) < 0) {
+       if (fr_struct_from_network(ctx, cursor, attr_tacacs_packet, buffer, buffer_len, &tlv, NULL, NULL, NULL) < 0) {
                fr_strerror_printf("Problems to decode %s using fr_struct_from_network()", attr_tacacs_packet->name);
                return -1;
        }