summaryrefslogtreecommitdiff
path: root/lib/yang.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-01-26 23:29:59 +0200
committerGitHub <noreply@github.com>2024-01-26 23:29:59 +0200
commit1254d5fc4e7d6b3717177fd353974a55b1777d4a (patch)
tree527cd29e0d69f3eaad25ee6b3a38e2a13572b77b /lib/yang.c
parent5db3bb0de95c6828bc8eda807f679ca2a7a68f8d (diff)
parent83abe9c3cb9acd610dcdf8341374428df5ea9093 (diff)
Merge pull request #15220 from LabNConsulting/chopps/ripd-convert
ripd to mgmtd
Diffstat (limited to 'lib/yang.c')
-rw-r--r--lib/yang.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/yang.c b/lib/yang.c
index 7d35fb0d3d..ed855c8498 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -508,6 +508,30 @@ void yang_dnode_iterate(yang_dnode_iter_cb cb, void *arg,
ly_set_free(set, NULL);
}
+uint32_t yang_dnode_count(const struct lyd_node *dnode, const char *xpath_fmt,
+ ...)
+{
+ va_list ap;
+ char xpath[XPATH_MAXLEN];
+ struct ly_set *set;
+ uint32_t count;
+
+ va_start(ap, xpath_fmt);
+ vsnprintf(xpath, sizeof(xpath), xpath_fmt, ap);
+ va_end(ap);
+
+ if (lyd_find_xpath(dnode, xpath, &set)) {
+ assert(0);
+ return 0;
+ }
+
+ count = set->count;
+
+ ly_set_free(set, NULL);
+
+ return count;
+}
+
bool yang_dnode_is_default(const struct lyd_node *dnode, const char *xpath)
{
const struct lysc_node *snode;