From: Alan T. DeKok Date: Wed, 6 Jul 2022 16:46:17 +0000 (-0400) Subject: allow for encoding of other protocols inside of the internal dict X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5876ebe408d045bcc5e5195ac80c3b3c663e3fea;p=thirdparty%2Ffreeradius-server.git allow for encoding of other protocols inside of the internal dict 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 --- diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index b43aa1e9cfe..fa65492925a 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -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; }