summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/northbound.c6
-rw-r--r--lib/northbound_confd.c4
-rw-r--r--lib/northbound_sysrepo.c8
-rw-r--r--lib/yang.c23
-rw-r--r--lib/yang.h28
-rw-r--r--lib/yang_translator.c22
6 files changed, 27 insertions, 64 deletions
diff --git a/lib/northbound.c b/lib/northbound.c
index e79ccc7dd0..a978c7fe78 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -162,12 +162,12 @@ static int nb_node_del_cb(const struct lys_node *snode, void *arg)
void nb_nodes_create(void)
{
- yang_snodes_iterate_all(nb_node_new_cb, 0, NULL);
+ yang_snodes_iterate(NULL, nb_node_new_cb, 0, NULL);
}
void nb_nodes_delete(void)
{
- yang_snodes_iterate_all(nb_node_del_cb, 0, NULL);
+ yang_snodes_iterate(NULL, nb_node_del_cb, 0, NULL);
}
struct nb_node *nb_node_find(const char *xpath)
@@ -2254,7 +2254,7 @@ void nb_init(struct thread_master *tm,
nb_load_callbacks(modules[i]);
/* Validate northbound callbacks. */
- yang_snodes_iterate_all(nb_node_validate, 0, &errors);
+ yang_snodes_iterate(NULL, nb_node_validate, 0, &errors);
if (errors > 0) {
flog_err(
EC_LIB_NB_CBS_VALIDATION,
diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c
index a53e90d558..8acba9fd2b 100644
--- a/lib/northbound_confd.c
+++ b/lib/northbound_confd.c
@@ -1279,7 +1279,7 @@ static int frr_confd_init_dp(const char *program_name)
* Iterate over all loaded YANG modules and subscribe to the paths
* referent to state data.
*/
- yang_snodes_iterate_all(frr_confd_subscribe_state, 0, &data_cbs);
+ yang_snodes_iterate(NULL, frr_confd_subscribe_state, 0, &data_cbs);
/* Register notification stream. */
memset(&ncbs, 0, sizeof(ncbs));
@@ -1430,7 +1430,7 @@ static int frr_confd_init(const char *program_name)
goto error;
}
- yang_snodes_iterate_all(frr_confd_calculate_snode_hash, 0, NULL);
+ yang_snodes_iterate(NULL, frr_confd_calculate_snode_hash, 0, NULL);
hook_register(nb_notification_send, frr_confd_notification_send);
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c
index e9aac3ef14..c027f4de72 100644
--- a/lib/northbound_sysrepo.c
+++ b/lib/northbound_sysrepo.c
@@ -690,10 +690,10 @@ static int frr_sr_init(void)
int event_pipe;
frr_sr_subscribe_config(module);
- yang_snodes_iterate_module(module->info, frr_sr_subscribe_state,
- 0, module);
- yang_snodes_iterate_module(module->info, frr_sr_subscribe_rpc,
- 0, module);
+ yang_snodes_iterate(module->info, frr_sr_subscribe_state, 0,
+ module);
+ yang_snodes_iterate(module->info, frr_sr_subscribe_rpc, 0,
+ module);
/* Watch subscriptions. */
ret = sr_get_event_pipe(module->sr_subscription, &event_pipe);
diff --git a/lib/yang.c b/lib/yang.c
index 46012acf51..c59cb642f0 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -227,8 +227,8 @@ next:
return ret;
}
-int yang_snodes_iterate_module(const struct lys_module *module,
- yang_iterate_cb cb, uint16_t flags, void *arg)
+int yang_snodes_iterate(const struct lys_module *module, yang_iterate_cb cb,
+ uint16_t flags, void *arg)
{
const struct lys_module *module_iter;
uint32_t idx = 0;
@@ -252,25 +252,6 @@ int yang_snodes_iterate_module(const struct lys_module *module,
return ret;
}
-int yang_snodes_iterate_all(yang_iterate_cb cb, uint16_t flags, void *arg)
-{
- struct yang_module *module;
- int ret = YANG_ITER_CONTINUE;
-
- RB_FOREACH (module, yang_modules, &yang_modules) {
- struct lys_node *snode;
-
- LY_TREE_FOR (module->info->data, snode) {
- ret = yang_snodes_iterate_subtree(snode, NULL, cb,
- flags, arg);
- if (ret == YANG_ITER_STOP)
- return ret;
- }
- }
-
- return ret;
-}
-
void yang_snode_get_path(const struct lys_node *snode, enum yang_path_type type,
char *xpath, size_t xpath_len)
{
diff --git a/lib/yang.h b/lib/yang.h
index 867ade9676..0cd6a4a6f2 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -186,29 +186,11 @@ extern int yang_snodes_iterate_subtree(const struct lys_node *snode,
void *arg);
/*
- * Iterate over all libyang schema nodes from the given YANG module.
+ * Iterate over all libyang schema nodes from all loeaded modules of from the
+ * given YANG module.
*
* module
- * YANG module to operate on.
- *
- * cb
- * Function to call with each schema node.
- *
- * flags
- * YANG_ITER_* flags to control how the iteration is performed.
- *
- * arg
- * Arbitrary argument passed as the second parameter in each call to 'cb'.
- *
- * Returns:
- * The return value of the last called callback.
- */
-extern int yang_snodes_iterate_module(const struct lys_module *module,
- yang_iterate_cb cb, uint16_t flags,
- void *arg);
-
-/*
- * Iterate over all libyang schema nodes from all loaded YANG modules.
+ * When set, iterate over all nodes of the specified module only.
*
* cb
* Function to call with each schema node.
@@ -222,8 +204,8 @@ extern int yang_snodes_iterate_module(const struct lys_module *module,
* Returns:
* The return value of the last called callback.
*/
-extern int yang_snodes_iterate_all(yang_iterate_cb cb, uint16_t flags,
- void *arg);
+extern int yang_snodes_iterate(const struct lys_module *module,
+ yang_iterate_cb cb, uint16_t flags, void *arg);
/*
* Build schema path or data path of the schema node.
diff --git a/lib/yang_translator.c b/lib/yang_translator.c
index 7dbb1f3f1a..1f64675d6a 100644
--- a/lib/yang_translator.c
+++ b/lib/yang_translator.c
@@ -469,12 +469,12 @@ static unsigned int yang_translator_validate(struct yang_translator *translator)
args.errors = 0;
for (ALL_LIST_ELEMENTS_RO(translator->modules, ln, tmodule)) {
- yang_snodes_iterate_module(
- tmodule->module, yang_translator_validate_cb,
- YANG_ITER_FILTER_NPCONTAINERS
- | YANG_ITER_FILTER_LIST_KEYS
- | YANG_ITER_FILTER_INPUT_OUTPUT,
- &args);
+ yang_snodes_iterate(tmodule->module,
+ yang_translator_validate_cb,
+ YANG_ITER_FILTER_NPCONTAINERS
+ | YANG_ITER_FILTER_LIST_KEYS
+ | YANG_ITER_FILTER_INPUT_OUTPUT,
+ &args);
}
if (args.errors)
@@ -500,11 +500,11 @@ static unsigned int yang_module_nodes_count(const struct lys_module *module)
{
unsigned int total = 0;
- yang_snodes_iterate_module(module, yang_module_nodes_count_cb,
- YANG_ITER_FILTER_NPCONTAINERS
- | YANG_ITER_FILTER_LIST_KEYS
- | YANG_ITER_FILTER_INPUT_OUTPUT,
- &total);
+ yang_snodes_iterate(module, yang_module_nodes_count_cb,
+ YANG_ITER_FILTER_NPCONTAINERS
+ | YANG_ITER_FILTER_LIST_KEYS
+ | YANG_ITER_FILTER_INPUT_OUTPUT,
+ &total);
return total;
}