summaryrefslogtreecommitdiff
path: root/lib/northbound_sysrepo.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-11-02 21:56:26 -0200
committerRenato Westphal <renato@opensourcerouting.org>2018-11-26 17:38:08 -0200
commite0ccfad220d80c1d02b327fd0ee24faf6a8d2bd4 (patch)
treefcfd051fb691b38b615c3c77631dcf4e876060f5 /lib/northbound_sysrepo.c
parenta1b5f469e70333042c2a0bd7e98bc4e69f4a0237 (diff)
lib: rework the yang schema node iteration functions
* Rename yang_snodes_iterate() to yang_snodes_iterate_subtree() and expose it in the public API. * Rename yang_module_snodes_iterate() to yang_snodes_iterate_module(). * Rename yang_all_snodes_iterate() to yang_snodes_iterate_all(). * Make it possible to stop the iteration at any time by returning YANG_ITER_STOP in the iteration callbacks. * Make the iteration callbacks accept only one user argument and not two. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound_sysrepo.c')
-rw-r--r--lib/northbound_sysrepo.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c
index f109f78133..9c07db8560 100644
--- a/lib/northbound_sysrepo.c
+++ b/lib/northbound_sysrepo.c
@@ -732,18 +732,17 @@ static void frr_sr_subscribe_config(struct yang_module *module)
sr_strerror(ret));
}
-static void frr_sr_subscribe_state(const struct lys_node *snode, void *arg1,
- void *arg2)
+static int frr_sr_subscribe_state(const struct lys_node *snode, void *arg)
{
- struct yang_module *module = arg1;
+ struct yang_module *module = arg;
struct nb_node *nb_node;
int ret;
if (!CHECK_FLAG(snode->flags, LYS_CONFIG_R))
- return;
+ return YANG_ITER_CONTINUE;
/* We only need to subscribe to the root of the state subtrees. */
if (snode->parent && CHECK_FLAG(snode->parent->flags, LYS_CONFIG_R))
- return;
+ return YANG_ITER_CONTINUE;
nb_node = snode->priv;
if (debug_northbound)
@@ -756,17 +755,18 @@ static void frr_sr_subscribe_state(const struct lys_node *snode, void *arg1,
if (ret != SR_ERR_OK)
flog_err(EC_LIB_LIBSYSREPO, "sr_dp_get_items_subscribe(): %s",
sr_strerror(ret));
+
+ return YANG_ITER_CONTINUE;
}
-static void frr_sr_subscribe_rpc(const struct lys_node *snode, void *arg1,
- void *arg2)
+static int frr_sr_subscribe_rpc(const struct lys_node *snode, void *arg)
{
- struct yang_module *module = arg1;
+ struct yang_module *module = arg;
struct nb_node *nb_node;
int ret;
if (snode->nodetype != LYS_RPC)
- return;
+ return YANG_ITER_CONTINUE;
nb_node = snode->priv;
if (debug_northbound)
@@ -779,17 +779,18 @@ static void frr_sr_subscribe_rpc(const struct lys_node *snode, void *arg1,
if (ret != SR_ERR_OK)
flog_err(EC_LIB_LIBSYSREPO, "sr_rpc_subscribe(): %s",
sr_strerror(ret));
+
+ return YANG_ITER_CONTINUE;
}
-static void frr_sr_subscribe_action(const struct lys_node *snode, void *arg1,
- void *arg2)
+static int frr_sr_subscribe_action(const struct lys_node *snode, void *arg)
{
- struct yang_module *module = arg1;
+ struct yang_module *module = arg;
struct nb_node *nb_node;
int ret;
if (snode->nodetype != LYS_ACTION)
- return;
+ return YANG_ITER_CONTINUE;
nb_node = snode->priv;
if (debug_northbound)
@@ -802,6 +803,8 @@ static void frr_sr_subscribe_action(const struct lys_node *snode, void *arg1,
if (ret != SR_ERR_OK)
flog_err(EC_LIB_LIBSYSREPO, "sr_action_subscribe(): %s",
sr_strerror(ret));
+
+ return YANG_ITER_CONTINUE;
}
/* FRR's Sysrepo initialization. */
@@ -839,12 +842,12 @@ static int frr_sr_init(const char *program_name)
/* Perform subscriptions. */
RB_FOREACH (module, yang_modules, &yang_modules) {
frr_sr_subscribe_config(module);
- yang_module_snodes_iterate(module->info, frr_sr_subscribe_state,
- 0, module, NULL);
- yang_module_snodes_iterate(module->info, frr_sr_subscribe_rpc,
- 0, module, NULL);
- yang_module_snodes_iterate(
- module->info, frr_sr_subscribe_action, 0, module, NULL);
+ 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(module->info,
+ frr_sr_subscribe_action, 0, module);
}
hook_register(nb_notification_send, frr_sr_notification_send);