summaryrefslogtreecommitdiff
path: root/tools/gen_northbound_callbacks.c
AgeCommit message (Collapse)Author
2025-01-20tools: fix regression in gen_northbound_callback toolChristian Hopps
When support for new style `get()` was added inadvertently stopped generating other callbacks and prototypes. Fix this. Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07tools: add new-style get operation callback supportChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15tools: add support for multiple YANG pathsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-10-07lib: add flag to have libyang load internal ietf-yang-library moduleChristian Hopps
Mgmtd makes use of libyang's internal ietf-yang-library module to add support for said module to FRR management. Previously, mgmtd was loading this module explicitly; however, that required that libyang's `ietf-yang-library.yang` module definition file be co-located with FRR's yang files so that it (and ietf-datastore.yang) would be found when searched for by libyang using FRRs search path. This isn't always the case depending on how the user compiles and installs libyang so mgmtd was failing to run in some cases. Instead of doing it the above way we simply tell libyang to load it's internal version of ietf-yang-library when we initialize the libyang context. This required adding a boolean to a couple of the init functions which is why so many files are touched (although all the changes are minimal). Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-30tools: add config-write callbacks to nb templatesMark Stapp
Add the cli_show (config write) callback when emitting the create or modify callback in the northbound template. Split the config-handling and config-output callbacks into two structs/arrays; this seems to be helpful when doing mgmtd conversion. Signed-off-by: Mark Stapp <mjs@labn.net>
2024-01-28lib: add support for "features" when loading YANG modulesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11lib: split nb_operation into two typesIgor Ryzhov
Currently, nb_operation enum means two different things - edit operation type (frontend part), and callback type (backend part). These types overlap, but they are not identical. We need to add more operation types to support NETCONF/RESTCONF integration, so it's better to have separate enums to identify different entities. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-09*: remove sys/stat.h from zebra.hDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-05-13lib: adapt to version 2 of libyangChristian Hopps
Compile with v2.0.0 tag of `libyang2` branch of: https://github.com/CESNET/libyang staticd init load time of 10k routes now 6s vs ly1 time of 150s Signed-off-by: Christian Hopps <chopps@labn.net>
2020-10-23lib: combine two YANG schema iteration functions into oneRenato Westphal
Combine yang_snodes_iterate_module() and yang_snodes_iterate_all() into an unified yang_snodes_iterate() function, where the first "module" parameter is optional. There's no point in having two separate YANG schema iteration functions anymore now that they are too similar. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-11tools: nb generate callback script to use attrChirag Shah
northbound genrate callback script to use attr->event in case passed in generated callbacks.. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-23*: change the signature of the northbound callbacks to be more flexibleRenato Westphal
Having a fixed set of parameters for each northbound callback isn't a good idea since it makes it difficult to add new parameters whenever that becomes necessary, as several hundreds or thousands of existing callbacks need to be updated accordingly. To remediate this issue, this commit changes the signature of all northbound callbacks to have a single parameter: a pointer to a 'nb_cb_x_args' structure (where x is different for each type of callback). These structures encapsulate all real parameters (both input and output) the callbacks need to have access to. And adding a new parameter to a given callback is as simple as adding a new field to the corresponding 'nb_cb_x_args' structure, without needing to update any instance of that callback in any daemon. This commit includes a .cocci semantic patch that can be used to update old code to the new format automatically. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-03lib, tools: silence harmless warnings in the northbound toolsRenato Westphal
Our two northbound tools don't have embedded YANG modules like the other FRR binaries. As such, ly_ctx_set_module_imp_clb() shouldn't be called when the YANG subsystem it being initialized by a northbound tool. To make that possible, add a new "embedded_modules" parameter to the yang_init() function to control whether libyang should look for embedded modules or not. With this fix, "gen_northbound_callbacks" and "gen_yang_deviations" won't emit "YANG model X not embedded, trying external file" warnings anymore. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-10-30tools: update the northbound callbacks generatorRenato Westphal
Add a new '-s' option which controls whether the generated northbound callbacks are declared with the 'static' specifier or not. If not (the default), a prototype is generated for each callback before their declarations. It's suggested that daemons shouldn't use the '-s' option so that their northbound callbacks can be implemented in different files according to their class (config, state, rpc or notification). libfrr commands, on the other hand, can use the '-s' option when their associated YANG module is too small and putting all callbacks in the same file is desirable. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-07-30tools: generate code that handles all casesRafael Zalamena
Help developers to start implementing northbound with more complete callbacks. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-29tools: generate northbound code without warningsRafael Zalamena
Use the alternate struct instantiation that does not generates warning on old compilers. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-29tools: allow YANG model path specificationRafael Zalamena
This allows developer to set a temporary YANG model directory path for generating northbound for models not yet installed. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-11libs, rip, isis: change northbound operation enum to DESTROYMark Stapp
Change the northbound lib operation from DELETE to DESTROY; make the required changes in the users of the northbound, in the cli, rip, ripng, and isis. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-11-26lib, tests: major rework in the operational-data callbacksRenato Westphal
The northbound infrastructure for operational data was subpar compared to the infrastructure for configuration data. This commit addresses most of the existing problems, making it possible to write operational-data callbacks for more complex YANG models. Summary of the changes: * Add support for nested YANG lists. * Add support for leaf-lists. * Add support for leafs of type "empty". * Introduce the "show yang operational-data XPATH" command, and write an unit test for it. The main purpose of this command is to make it easier to test the operational-data northbound callbacks. * Introduce the nb_oper_data_iterate() function, that can be used to iterate over operational data. Make the CLI and sysrepo use this function. * Since ConfD has a very peculiar API, it can't reuse the nb_oper_data_iterate() like the other northbound clients. In this case, adapt the existing ConfD callbacks to support the new features (and make some performance improvements in the process). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: add support for YANG lists with mixed config and state dataRenato Westphal
A YANG list that contains both configuration and state data must have the following callbacks: create(), delete(), get_next(), get_keys() and lookup_entry(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: rework the yang schema node iteration functionsRenato Westphal
* 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>
2018-11-26lib, tools: use CHECK_FLAG/SET_FLAG more often in the northbound codeRenato Westphal
Cosmetic change to improve code readability a bit. No binary changes. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27lib: introduce new northbound APIRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>