From: Alan T. DeKok Date: Mon, 30 Jan 2017 17:03:53 +0000 (-0500) Subject: return "known" unknown attribute if it exists X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fedd7738ea032af71a9797b123e5e3d87a1048c8;p=thirdparty%2Ffreeradius-server.git return "known" unknown attribute if it exists after creating unknown attribute, look it up by name. If it exists, return that one. This lets us use unknown attributes in the config files, and then have the decoder automatically reference then when they're seen in the packets. --- diff --git a/src/lib/dict.c b/src/lib/dict.c index 5b6b76eca41..6b6f3715d80 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -3127,6 +3127,21 @@ fr_dict_attr_t const *fr_dict_unknown_afrom_fields(TALLOC_CTX *ctx, fr_dict_attr return NULL; } + /* + * The config files may reference the unknown by name. + * If so, use the pre-defined name instead of an unknown + * one. + * + * @fixme: pass the root into this function! + */ + da = fr_dict_attr_by_name(NULL, n->name); + if (da) { + fr_dict_unknown_free(&parent); + parent = n; + fr_dict_unknown_free(&parent); + return da; + } + /* * Ensure the parent is freed at the same time as the * unknown DA. This should be OK as we never parent