summaryrefslogtreecommitdiffstats
path: root/lib/yang.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-01-04 22:08:10 +0100
committerRenato Westphal <renato@opensourcerouting.org>2019-01-18 19:15:41 +0100
commitfcb7bffdda0b122c34978e3f7390b6f26689848a (patch)
tree882984513c5a7f469f9a3e1fd8c4af398279dd41 /lib/yang.c
parentlib: constify a few parameters in the VRF code (diff)
downloadfrr-fcb7bffdda0b122c34978e3f7390b6f26689848a.tar.xz
frr-fcb7bffdda0b122c34978e3f7390b6f26689848a.zip
lib: introduce new YANG helper function
One use case for the new yang_data_list_find() function is to find input parameters in RPC northbound callbacks easily, without the need to iterate over the input parameters manually. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/yang.c')
-rw-r--r--lib/yang.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/yang.c b/lib/yang.c
index 71b41c35d..4077b2974 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -608,6 +608,25 @@ struct list *yang_data_list_new(void)
return list;
}
+struct yang_data *yang_data_list_find(const struct list *list,
+ const char *xpath_fmt, ...)
+{
+ char xpath[XPATH_MAXLEN];
+ struct yang_data *data;
+ struct listnode *node;
+ va_list ap;
+
+ va_start(ap, xpath_fmt);
+ vsnprintf(xpath, sizeof(xpath), xpath_fmt, ap);
+ va_end(ap);
+
+ for (ALL_LIST_ELEMENTS_RO(list, node, data))
+ if (strmatch(data->xpath, xpath))
+ return data;
+
+ return NULL;
+}
+
static void *ly_dup_cb(const void *priv)
{
/* Make a shallow copy of the priv pointer. */