return c;
}
-/** Find the pair with the matching DAs
+/** Find a pair with a matching da
*
* @param[in] list to search in.
* @param[in] da to look for in the list.
*/
fr_pair_t *fr_pair_find_by_da(fr_pair_list_t const *list, fr_dict_attr_t const *da)
{
- fr_pair_t *vp;
+ fr_pair_t *vp = NULL;
if (fr_dlist_empty(&list->head)) return NULL;
if (!da) return NULL;
- for (vp = fr_pair_list_head(list); vp != NULL; vp = fr_pair_list_next(list, vp)) if (da == vp->da) return vp;
+ while ((vp = fr_pair_list_next(list, vp))) if (da == vp->da) return vp;
return NULL;
}
+/** Find a pair which has the specified ancestor
+ *
+ * @param[in] list to search in.
+ * @param[in] ancestor to look for in the list.
+ * @return
+ * - first matching fr_pair_t.
+ * - NULL if no fr_pair_ts match.
+ *
+ * @hidecallergraph
+ */
+fr_pair_t *fr_pair_find_by_ancestor(fr_pair_list_t const *list, fr_dict_attr_t const *ancestor)
+{
+ fr_pair_t *vp = NULL;
+
+ while ((vp = fr_pair_list_next(list, vp))) {
+ if (!fr_dict_attr_common_parent(ancestor, vp->da, true)) continue;
+
+ return vp;
+ }
+
+ return NULL;
+}
/** Find the pair with the matching attribute by vendor id and attribute number.
*
/** @hidecallergraph */
fr_pair_t *fr_pair_find_by_da(fr_pair_list_t const *list, fr_dict_attr_t const *da);
+fr_pair_t *fr_pair_find_by_ancestor(fr_pair_list_t const *list, fr_dict_attr_t const *ancestor);
+
fr_pair_t *fr_pair_find_by_num(fr_pair_list_t *list, unsigned int vendor, unsigned int attr);
fr_pair_t *fr_pair_find_by_child_num(fr_pair_list_t *list, fr_dict_attr_t const *parent, unsigned int attr);