fr_dict_attr_t const *da;
fr_sbuff_marker_t m_s;
tmpl_attr_filter_t filter;
+ fr_dict_attr_err_t dict_err;
fr_sbuff_marker(&m_s, name);
* No parent means we need to go hunting through all the dictionaries
*/
if (!parent) {
- slen = fr_dict_attr_by_qualified_name_substr(NULL, &da,
+ slen = fr_dict_attr_by_qualified_name_substr(&dict_err, &da,
rules->dict_def, name, !rules->disallow_internal);
/*
* Otherwise we're resolving in the context of the last component,
* or its reference in the case of group attributes.
*/
} else {
- slen = fr_dict_attr_child_by_name_substr(NULL, &da, parent, name, false);
+ slen = fr_dict_attr_child_by_name_substr(&dict_err, &da, parent, name, false);
+ }
+
+ /*
+ * Fatal errors related to nesting...
+ */
+ switch (dict_err) {
+ case FR_DICT_ATTR_NO_CHILDREN:
+ case FR_DICT_ATTR_NOT_DESCENDENT:
+ goto error;
+
+ default:
+ break;
}
/*
DA_VERIFY(parent);
+ /*
+ * Check the parent can is a grouping attribute
+ */
+ switch (parent->type) {
+ case FR_TYPE_STRUCTURAL:
+ break;
+
+ default:
+ fr_strerror_printf("Parent (%s) is a %s, it cannot contain nested attributes",
+ parent->name,
+ fr_table_str_by_value(fr_value_box_type_table,
+ parent->type, "?Unknown?"));
+ if (err) *err = FR_DICT_ATTR_NO_CHILDREN;
+ return 0;
+ }
+
/*
* We return the child of the referenced attribute, and
* not of the "group" attribute.
if (parent->type == FR_TYPE_GROUP) parent = parent->ref;
if (!parent->children) {
- fr_strerror_printf("%s has no children", parent->name);
+ fr_strerror_printf("Parent (%s) has no children", parent->name);
if (err) *err = FR_DICT_ATTR_NO_CHILDREN;
return 0;
}
if (is_direct_decendent) {
if ((*out)->parent != parent) {
not_decendent:
- fr_strerror_printf("%s is not a descendent of %s", parent->name, (*out)->name);
+ fr_strerror_printf("%s is not a descendent of parent (%s)", parent->name, (*out)->name);
if (err) *err = FR_DICT_ATTR_NOT_DESCENDENT;
*out = NULL;
return 0;