diff --git a/CHANGELOG.md b/CHANGELOG.md index 03cd32ab..647a055e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Major changes: * Restructure and more generic plugin API (cli,backend,restconf,netconf) as preparation for authorization RFC8341 - * New design with single `clixon_plugin_init()` returning an api struct with function pointers, see example below. This means that there are no hardcoded plugin functions, except `clixon_plugin_init()`. + * New design change `plugin_init()` to a single `clixon_plugin_init()` returning an api struct with function pointers, see example below. This means that there are no hardcoded plugin functions, except `clixon_plugin_init()`. * Plugin RPC callback interface have been unified between backend, netconf and restconf. * Backend RPC register callback function (Netconf RPC or restconf operation POST) has been changed from: `backend_rpc_cb_register()` to `rpc_callback_register()` * Backend RPC callback signature has been changed from: `int cb(clicon_handle h, cxobj *xe, struct client_entry *ce, cbuf *cbret, void *arg)` has been changed to : `int cb(clicon_handle h, cxobj *xe, struct client_entry *ce, cbuf *cbret, void *arg)` @@ -45,6 +45,9 @@ static clixon_plugin_api api = { plugin_start, plugin_exit, NULL, /* auth N/A for backend */ + NULL, /* cli_prompthook_t */ + NULL, /* cligen_susp_cb_t */ + NULL, /* cligen_interrupt_cb_t */ plugin_reset, plugin_statedata, transaction_begin, diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c index 29c7a25e..ecc4b587 100644 --- a/apps/backend/backend_plugin.c +++ b/apps/backend/backend_plugin.c @@ -106,7 +106,7 @@ clixon_plugin_reset(clicon_handle h, plgreset_t *resetfn; /* Plugin auth */ int retval = 1; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((resetfn = cp->cp_api.ca_reset) == NULL) continue; if ((retval = resetfn(h, db)) < 0) { @@ -150,7 +150,7 @@ clixon_plugin_statedata(clicon_handle h, clicon_err(OE_CFG, ENOENT, "XML tree expected"); goto done; } - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_statedata) == NULL) continue; if ((x = xml_new("config", NULL, NULL)) == NULL) @@ -246,7 +246,7 @@ plugin_transaction_begin(clicon_handle h, clixon_plugin *cp = NULL; trans_cb_t *fn; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_trans_begin) == NULL) continue; if ((retval = fn(h, (transaction_data)td)) < 0){ @@ -274,7 +274,7 @@ plugin_transaction_validate(clicon_handle h, clixon_plugin *cp = NULL; trans_cb_t *fn; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_trans_validate) == NULL) continue; if ((retval = fn(h, (transaction_data)td)) < 0){ @@ -303,7 +303,7 @@ plugin_transaction_complete(clicon_handle h, clixon_plugin *cp = NULL; trans_cb_t *fn; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_trans_complete) == NULL) continue; if ((retval = fn(h, (transaction_data)td)) < 0){ @@ -349,7 +349,7 @@ plugin_transaction_revert(clicon_handle h, tr.td_scvec = td->td_tcvec; tr.td_tcvec = td->td_scvec; - while ((cp = plugin_each_revert(h, cp, nr)) != NULL) { + while ((cp = clixon_plugin_each_revert(h, cp, nr)) != NULL) { if ((fn = cp->cp_api.ca_trans_commit) == NULL) continue; if ((retval = fn(h, (transaction_data)td)) < 0){ @@ -379,7 +379,7 @@ plugin_transaction_commit(clicon_handle h, trans_cb_t *fn; int i=0; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { i++; if ((fn = cp->cp_api.ca_trans_commit) == NULL) continue; @@ -409,7 +409,7 @@ plugin_transaction_end(clicon_handle h, clixon_plugin *cp = NULL; trans_cb_t *fn; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_trans_end) == NULL) continue; if ((retval = fn(h, (transaction_data)td)) < 0){ @@ -436,7 +436,7 @@ plugin_transaction_abort(clicon_handle h, clixon_plugin *cp = NULL; trans_cb_t *fn; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_trans_abort) == NULL) continue; fn(h, (transaction_data)td); /* dont abort on error */ diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index 196d9259..81ca2e9e 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -260,7 +260,7 @@ cli_load_syntax(clicon_handle h, mode = cvec_find_str(cvv, "CLICON_MODE"); if (plgnam != NULL) { /* Find plugin for callback resolving */ - if ((cp = plugin_find(h, plgnam)) != NULL) + if ((cp = clixon_plugin_find(h, plgnam)) != NULL) handle = cp->cp_handle; if (handle == NULL){ clicon_err(OE_PLUGIN, 0, "CLICON_PLUGIN set to '%s' in %s but plugin %s.so not found in %s\n", @@ -379,7 +379,7 @@ cli_syntax_load (clicon_handle h) /* Set susp and interrupt callbacks into CLIgen */ cp = NULL; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if (fns==NULL && (fns = cp->cp_api.ca_suspend) != NULL) if (cli_susp_hook(h, fns) < 0) goto done; @@ -589,7 +589,7 @@ clicon_cliread(clicon_handle h) mode = stx->stx_active_mode; /* Get prompt from plugin callback? */ cp = NULL; - while ((cp = plugin_each(h, cp)) != NULL) { + while ((cp = clixon_plugin_each(h, cp)) != NULL) { if ((fn = cp->cp_api.ca_prompt) == NULL) continue; pfmt = fn(h, mode->csm_name); diff --git a/lib/clixon/clixon_plugin.h b/lib/clixon/clixon_plugin.h index e0281371..536b0c86 100644 --- a/lib/clixon/clixon_plugin.h +++ b/lib/clixon/clixon_plugin.h @@ -50,13 +50,19 @@ /* Dynamicically loadable plugin object handle. @see return value of dlopen(3) */ typedef void *plghndl_t; -/* Registered RPC callback function */ +/*! Registered RPC callback function + * @param[in] h Clicon handle + * @param[in] xn Request: + * @param[out] cbret Return xml tree, eg ..., */ - cbuf *cbret, /* Return xml tree, eg ...,