YANG Action (RFC 7950 Section 7.15)

See [Support for "action" statement](https://github.com/clicon/clixon/issues/101)
This commit is contained in:
Olof hagsand 2022-06-03 11:14:58 +02:00
parent 87c65c3541
commit bdb516fec9
16 changed files with 583 additions and 104 deletions

View file

@ -360,6 +360,26 @@ typedef struct clixon_plugin clixon_plugin_t;
* The internal struct is defined in clixon_plugin.c */
typedef struct plugin_context plugin_context_t;
/*
* RPC callbacks for both client/frontend and backend plugins.
* RPC callbacks are explicitly registered in the plugin_init() function
* with a tag and a function
* When the the tag is encountered, the callback is called.
* Primarily backend, but also netconf and restconf frontend plugins.
* CLI frontend so far have direct callbacks, ie functions in the cligen
* specification are directly dlsym:ed to the CLI plugin.
* It would be possible to use this rpc registering API for CLI plugins as well.
*
* When namespace and name match, the callback is made
*/
typedef struct {
qelem_t rc_qelem; /* List header */
clicon_rpc_cb rc_callback; /* RPC Callback */
void *rc_arg; /* Application specific argument to cb */
char *rc_namespace;/* Namespace to combine with name tag */
char *rc_name; /* Xml/json tag/name */
} rpc_callback_t;
/*
* Prototypes
*/
@ -402,6 +422,11 @@ int clixon_plugin_datastore_upgrade_all(clicon_handle h, const char *db, cxobj *
/* rpc callback API */
int rpc_callback_register(clicon_handle h, clicon_rpc_cb cb, void *arg, const char *ns, const char *name);
int rpc_callback_call(clicon_handle h, cxobj *xe, void *arg, int *nrp, cbuf *cbret);
/* action callback API */
int action_callback_register(clicon_handle h, yang_stmt *ya, clicon_rpc_cb cb, void *arg);
int action_callback_call(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
/* upgrade callback API */
int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *strfn, const char *ns, void *arg);
int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);

View file

@ -73,5 +73,7 @@ int xml_merge(cxobj *x0, cxobj *x1, yang_stmt *yspec, char **reason);
int yang_enum_int_value(cxobj *node, int32_t *val);
int xml_copy_marked(cxobj *x0, cxobj *x1);
int yang_check_when_xpath(cxobj *xn, cxobj *xp, yang_stmt *yn, int *hit, int *nrp, char **xpathp);
int xml_rpc_isaction(cxobj *xn);
int xml_find_action(cxobj *xn, int top, cxobj **xap);
#endif /* _CLIXON_XML_MAP_H_ */

View file

@ -282,5 +282,7 @@ int yang_extension_value(yang_stmt *ys, char *name, char *ns, int *exist,
int yang_sort_subelements(yang_stmt *ys);
int yang_init(clicon_handle h);
int yang_single_child_type(yang_stmt *ys, enum rfc_6020 subkeyw);
void *yang_action_cb_get(yang_stmt *ys);
int yang_action_cb_add(yang_stmt *ys, void *rc);
#endif /* _CLIXON_YANG_H_ */