Skip to content

Commit

Permalink
return "known" unknown attribute if it exists
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alandekok committed Jan 30, 2017
1 parent c9a2790 commit fedd773
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/dict.c
Expand Up @@ -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
Expand Down

1 comment on commit fedd773

@arr2036
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly the same pattern of behaviour you were saying was incorrect for the OID variant of this function.

Please sign in to comment.