]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow for encoding of other protocols inside of the internal dict
authorAlan T. DeKok <aland@freeradius.org>
Wed, 6 Jul 2022 16:46:17 +0000 (12:46 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 6 Jul 2022 16:46:17 +0000 (12:46 -0400)
we can't just drop the other protocols into a packet along side
internal attributes, because we can't distinguish the internal
attribute "1" from the protocol number "1".

We therefore need an encapsulation layer.

The internal encoder / decoder still needs to be updated to handle
Protocol-Encapsulation as a special-case, ala Message-Authenticator

src/lib/util/dict_util.c

index b43aa1e9cfecd6f1767c261be3df8eba38865a9a..fa65492925aaaada2f95259b1a20fca921b87a54 100644 (file)
@@ -859,6 +859,28 @@ int dict_protocol_add(fr_dict_t *dict)
 
        dict_dependent_add(dict, "global");
 
+       /*
+        *      Create and add sub-attributes which allow other
+        *      protocols to be encapsulated in the internal
+        *      namespace.
+        */
+       if (dict_gctx->internal && (dict != dict_gctx->internal)) {
+               static fr_dict_attr_t const *encap;
+               fr_dict_attr_t const *da;
+               fr_dict_attr_flags_t flags = { 0 };
+
+               if (!encap) encap = fr_dict_attr_by_name(NULL, dict_gctx->internal->root, "Protocol-Encapsulation");
+               fr_assert(encap != NULL);
+
+               if (fr_dict_attr_add(dict_gctx->internal, encap, dict->root->name, dict->root->attr, FR_TYPE_GROUP, &flags) < 0) {
+                       return -1;
+               }
+
+               da = fr_dict_attr_child_by_num(encap, dict->root->attr);
+               fr_assert(da != NULL);
+               dict_attr_ref_set(da, dict->root);
+       }
+
        return 0;
 }