New plugin callback: ca_yang_patch - for modifying existing YANG modules
C-API: Added `spec` parameter to `xml2xpath()`
This commit is contained in:
parent
48a0fb9968
commit
a5220805b1
16 changed files with 318 additions and 193 deletions
|
|
@ -289,6 +289,19 @@ typedef int (datastore_upgrade_t)(clicon_handle h, const char *db, cxobj *xt, mo
|
|||
*/
|
||||
typedef int (yang_mount_t)(clicon_handle h, cxobj *xt, cxobj **yanglib);
|
||||
|
||||
/*! YANG module patch
|
||||
*
|
||||
* Given a parsed YANG module, give the ability to patch it before import recursion,
|
||||
* grouping/uses checks, augments, etc
|
||||
* Can be useful if YANG in some way needs modification.
|
||||
* Deviations could be used as alternative (probably better)
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ymod YANG module
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
typedef int (yang_patch_t)(clicon_handle h, yang_stmt *ymod);
|
||||
|
||||
/*! Startup status for use in startup-callback
|
||||
* Note that for STARTUP_ERR and STARTUP_INVALID, running runs in failsafe mode
|
||||
* and startup contains the erroneous or invalid database.
|
||||
|
|
@ -315,6 +328,8 @@ struct clixon_plugin_api{
|
|||
plgstart_t *ca_start; /* Plugin start */
|
||||
plgexit_t *ca_exit; /* Plugin exit */
|
||||
plgextension_t *ca_extension; /* Yang extension/unknown handler */
|
||||
yang_mount_t *ca_yang_mount; /* RFC 8528 schema mount */
|
||||
yang_patch_t *ca_yang_patch; /* Patch yang after parse */
|
||||
union {
|
||||
struct { /* cli-specific */
|
||||
cli_prompthook_t *ci_prompt; /* Prompt hook */
|
||||
|
|
@ -342,7 +357,6 @@ struct clixon_plugin_api{
|
|||
trans_cb_t *cb_trans_end; /* Transaction completed */
|
||||
trans_cb_t *cb_trans_abort; /* Transaction aborted */
|
||||
datastore_upgrade_t *cb_datastore_upgrade; /* General-purpose datastore upgrade */
|
||||
yang_mount_t *cb_yang_mount; /* RFC 8528 schema mount */
|
||||
} cau_backend;
|
||||
} u;
|
||||
};
|
||||
|
|
@ -365,7 +379,6 @@ struct clixon_plugin_api{
|
|||
#define ca_trans_end u.cau_backend.cb_trans_end
|
||||
#define ca_trans_abort u.cau_backend.cb_trans_abort
|
||||
#define ca_datastore_upgrade u.cau_backend.cb_datastore_upgrade
|
||||
#define ca_yang_mount u.cau_backend.cb_yang_mount
|
||||
|
||||
/*
|
||||
* Macros
|
||||
|
|
@ -444,6 +457,9 @@ int clixon_plugin_datastore_upgrade_all(clicon_handle h, const char *db, cxobj *
|
|||
int clixon_plugin_yang_mount_one(clixon_plugin_t *cp, clicon_handle h, cxobj *xt, cxobj **yanglib);
|
||||
int clixon_plugin_yang_mount_all(clicon_handle h, cxobj *xt, cxobj **yanglib);
|
||||
|
||||
int clixon_plugin_yang_patch_one(clixon_plugin_t *cp, clicon_handle h, yang_stmt *ymod);
|
||||
int clixon_plugin_yang_patch_all(clicon_handle h, yang_stmt *ymod);
|
||||
|
||||
/* 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);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ int xml_tree_prune_flags(cxobj *xt, int flags, int mask);
|
|||
int xml_namespace_change(cxobj *x, char *ns, char *prefix);
|
||||
int xml_sanity(cxobj *x, void *arg);
|
||||
int xml_non_config_data(cxobj *xt, cxobj **xerr);
|
||||
int xml2xpath(cxobj *x, cvec *nsc, char **xpath);
|
||||
int assign_namespace_element(cxobj *x0, cxobj *x1, cxobj *x1p);
|
||||
int assign_namespace_body(cxobj *x0, cxobj *x1);
|
||||
int xml_merge(cxobj *x0, cxobj *x1, yang_stmt *yspec, char **reason);
|
||||
|
|
|
|||
|
|
@ -150,5 +150,6 @@ int xpath_vec(cxobj *xcur, cvec *nsc, const char *xpformat, cxobj ***vec, siz
|
|||
|
||||
int xpath2canonical(const char *xpath0, cvec *nsc0, yang_stmt *yspec, char **xpath1, cvec **nsc1, cbuf **cbreason);
|
||||
int xpath_count(cxobj *xcur, cvec *nsc, const char *xpath, uint32_t *count);
|
||||
int xml2xpath(cxobj *x, cvec *nsc, int spec, char **xpath);
|
||||
|
||||
#endif /* _CLIXON_XPATH_H */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
*/
|
||||
yang_stmt *yang_parse_file(FILE *fp, const char *name, yang_stmt *ysp);
|
||||
int yang_file_find_match(clicon_handle h, const char *module, const char *revision, cbuf *fbuf);
|
||||
yang_stmt *yang_parse_filename(const char *filename, yang_stmt *ysp);
|
||||
yang_stmt *yang_parse_filename(clicon_handle h, const char *filename, yang_stmt *ysp);
|
||||
yang_stmt *yang_parse_module(clicon_handle h, const char *module, const char *revision, yang_stmt *yspec, char *origname);
|
||||
int yang_parse_post(clicon_handle h, yang_stmt *yspec, int modmin);
|
||||
int yang_spec_parse_module(clicon_handle h, const char *module,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue