diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2018-11-03 00:56:26 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2018-11-26 20:38:08 +0100 |
commit | e0ccfad220d80c1d02b327fd0ee24faf6a8d2bd4 (patch) | |
tree | fcfd051fb691b38b615c3c77631dcf4e876060f5 /tools/gen_northbound_callbacks.c | |
parent | lib: introduce function that loads all FRR native YANG modules (diff) | |
download | frr-e0ccfad220d80c1d02b327fd0ee24faf6a8d2bd4.tar.xz frr-e0ccfad220d80c1d02b327fd0ee24faf6a8d2bd4.zip |
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 'tools/gen_northbound_callbacks.c')
-rw-r--r-- | tools/gen_northbound_callbacks.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/gen_northbound_callbacks.c b/tools/gen_northbound_callbacks.c index 24c7aa97b..9417155e6 100644 --- a/tools/gen_northbound_callbacks.c +++ b/tools/gen_northbound_callbacks.c @@ -149,8 +149,7 @@ static void generate_callback_name(struct lys_node *snode, replace_hyphens_by_underscores(buffer); } -static void generate_callbacks(const struct lys_node *snode, void *arg1, - void *arg2) +static int generate_callbacks(const struct lys_node *snode, void *arg) { bool first = true; @@ -163,7 +162,7 @@ static void generate_callbacks(const struct lys_node *snode, void *arg1, case LYS_RPC: break; default: - return; + return YANG_ITER_CONTINUE; } for (struct nb_callback_info *cb = &nb_callbacks[0]; @@ -198,10 +197,11 @@ static void generate_callbacks(const struct lys_node *snode, void *arg1, nb_callbacks[cb->operation].arguments, nb_callbacks[cb->operation].return_value); } + + return YANG_ITER_CONTINUE; } -static void generate_nb_nodes(const struct lys_node *snode, void *arg1, - void *arg2) +static int generate_nb_nodes(const struct lys_node *snode, void *arg) { bool first = true; @@ -214,7 +214,7 @@ static void generate_nb_nodes(const struct lys_node *snode, void *arg1, case LYS_RPC: break; default: - return; + return YANG_ITER_CONTINUE; } for (struct nb_callback_info *cb = &nb_callbacks[0]; @@ -245,6 +245,8 @@ static void generate_nb_nodes(const struct lys_node *snode, void *arg1, if (!first) printf("\t\t},\n"); + + return YANG_ITER_CONTINUE; } int main(int argc, char *argv[]) @@ -274,8 +276,7 @@ int main(int argc, char *argv[]) module = yang_module_load(argv[0]); /* Generate callback functions. */ - yang_module_snodes_iterate(module->info, generate_callbacks, 0, NULL, - NULL); + yang_snodes_iterate_module(module->info, generate_callbacks, 0, NULL); strlcpy(module_name_underscores, module->name, sizeof(module_name_underscores)); @@ -287,8 +288,7 @@ int main(int argc, char *argv[]) "\t.name = \"%s\",\n" "\t.nodes = {\n", module_name_underscores, module->name); - yang_module_snodes_iterate(module->info, generate_nb_nodes, 0, NULL, - NULL); + yang_snodes_iterate_module(module->info, generate_nb_nodes, 0, NULL); printf("\t\t{\n" "\t\t\t.xpath = NULL,\n" "\t\t},\n"); |