diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c index 9c04601e..bdf32d6f 100644 --- a/apps/backend/backend_get.c +++ b/apps/backend/backend_get.c @@ -194,10 +194,10 @@ client_get_streams(clixon_handle h, * message. But this needs to be explored in all sub-functions */ static int -get_statedata(clixon_handle h, - char *xpath, - cvec *nsc, - cxobj **xret) +get_state_data(clixon_handle h, + char *xpath, + cvec *nsc, + cxobj **xret) { int retval = -1; yang_stmt *yspec; @@ -777,7 +777,7 @@ get_list_pagination(clixon_handle h, } else { if (content != CONTENT_CONFIG){ - if ((ret = get_statedata(h, xpath?xpath:"/", nsc, &xret)) < 0) + if ((ret = get_state_data(h, xpath?xpath:"/", nsc, &xret)) < 0) goto done; if (ret == 0){ /* Error from callback (error in xret) */ if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0) @@ -959,8 +959,8 @@ get_common(clixon_handle h, withdefaults_type wdef; char *wdefstr; - wdef = WITHDEFAULTS_EXPLICIT; clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, ""); + wdef = WITHDEFAULTS_EXPLICIT; username = clicon_username_get(h); if ((yspec = clicon_dbspec_yang(h)) == NULL){ clixon_err(OE_YANG, ENOENT, "No yang spec9"); @@ -1008,7 +1008,6 @@ get_common(clixon_handle h, * If it is empty, all are default values and is regular get */ if ((xlpg = xml_find_type(xe, NULL, "list-pagination", CX_ELMNT)) != NULL){ - if ((xlpg2 = xml_dup(xlpg)) == NULL) goto done; if (xml_default_nopresence(xlpg2, 2, 0) < 0) @@ -1095,7 +1094,7 @@ get_common(clixon_handle h, break; case CONTENT_ALL: /* both config and state */ case CONTENT_NONCONFIG: /* state data only */ - if ((ret = get_statedata(h, xpath?xpath:"/", nsc, &xret)) < 0) + if ((ret = get_state_data(h, xpath?xpath:"/", nsc, &xret)) < 0) goto done; if (ret == 0){ /* Error from callback (error in xret) */ if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0) diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c index 1b580213..69f9e325 100644 --- a/apps/backend/backend_plugin.c +++ b/apps/backend/backend_plugin.c @@ -269,10 +269,6 @@ clixon_plugin_daemon_all(clixon_handle h) * @param[in] h clicon handle * @param[in] nsc namespace context for xpath * @param[in] xpath String with XPATH syntax. or NULL for all - * @param[in] pagmode List pagination mode - * @param[in] offset Offset, for list pagination - * @param[in] limit Limit, for list pagination - * @param[out] remaining Remaining elements (if limit is non-zero) * @param[out] xp If retval=1, state tree created and returned: ... * @retval 1 OK if callback found (and called) xret is set * @retval 0 Statedata callback failed. no XML tree returned diff --git a/example/main/README.md b/example/main/README.md index ce6e8da1..9c696498 100644 --- a/example/main/README.md +++ b/example/main/README.md @@ -82,6 +82,7 @@ Send netconf command: clixon_netconf -f /usr/local/etc/clixon/example.xml ``` Start clixon restconf daemon (default config listens on http IPv4 0.0.0.0 on port 8080): +(Warning: starting the native restconf daemon opens ports that may make your system less secure) ``` sudo clixon_restconf -f /usr/local/etc/clixon/example.xml ``` diff --git a/example/main/example_backend.c b/example/main/example_backend.c index 4dc595bd..48671ead 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -1,7 +1,7 @@ /* * ***** BEGIN LICENSE BLOCK ***** - + Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren Copyright (C) 2017-2019 Olof Hagsand Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate) @@ -26,20 +26,20 @@ of those above. If you wish to allow use of your version of this file only under the terms of the GPL, and not to allow others to use your version of this file under the terms of Apache License version 2, indicate - your decision by deleting the provisions above and replace them with the + your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the Apache License version 2 or the GPL. ***** END LICENSE BLOCK ***** - * The example have the following optional arguments that you can pass as + * The example have the following optional arguments that you can pass as * argc/argv after -- in clixon_backend: * -a <..> Register callback for this yang action * -m Mount this yang on mountpoint * -M Namespace of mountpoint, note both -m and -M must exist * -n Notification streams example - * -r enable the reset function + * -r enable the reset function * -s enable the state function * -S read state data from file, otherwise construct it programmatically (requires -s) * -i read state file on init not by request for optimization (requires -sS ) @@ -97,7 +97,7 @@ static char *_mount_namespace = NULL; /*! Notification stream * - * Enable notification streams for netconf/restconf + * Enable notification streams for netconf/restconf * Start backend with -- -n * where is period of stream */ @@ -149,7 +149,7 @@ static int _state_file_transaction = 0; /*! Variable to control module-specific upgrade callbacks. * - * If set, call test-case for upgrading ietf-interfaces, otherwise call + * If set, call test-case for upgrading ietf-interfaces, otherwise call * auto-upgrade * Start backend with -- -u */ @@ -163,7 +163,7 @@ static int _general_upgrade = 0; /*! Variable to control transaction logging (for debug) * - * If set, call syslog for every transaction callback + * If set, call syslog for every transaction callback * Start backend with -- -t */ static int _transaction_log = 0; @@ -300,7 +300,7 @@ main_abort(clixon_handle h, return 0; } -/*! Routing example notification timer handler. Here is where the periodic action is +/*! Routing example notification timer handler. Here is where the periodic action is */ static int example_stream_timer(int fd, @@ -319,7 +319,7 @@ example_stream_timer(int fd, return retval; } -/*! Set up example stream notification timer +/*! Set up example stream notification timer * * @param[in] h Clixon handle * @param[in] s Timeout period in seconds @@ -335,7 +335,7 @@ example_stream_timer_setup(clixon_handle h, return clixon_event_reg_timeout(t, example_stream_timer, h, "example stream timer"); } -/*! Smallest possible RPC declaration for test +/*! Smallest possible RPC declaration for test * * Yang/XML: * If the RPC operation invocation succeeded and no output parameters @@ -442,7 +442,7 @@ example_action_reset(clixon_handle h, /* Clixon handle */ * @param[in] h Clixon handle * @param[in] nsc External XML namespace context, or NULL * @param[in] xpath String with XPATH syntax. or NULL for all - * @param[out] xstate XML tree, on entry. + * @param[out] xstate XML tree, on entry. * @retval 0 OK * @retval -1 Error * @see xmldb_get @@ -458,10 +458,10 @@ example_action_reset(clixon_handle h, /* Clixon handle */ * @see example_statefile where state is read from file and also pagination */ int -example_statedata(clixon_handle h, - cvec *nsc, - char *xpath, - cxobj *xstate) +example_statedata(clixon_handle h, + cvec *nsc, + char *xpath, + cxobj *xstate) { int retval = -1; cxobj **xvec = NULL; @@ -481,7 +481,7 @@ example_statedata(clixon_handle h, goto done; } yspec = clicon_dbspec_yang(h); - /* Example of statedata, in this case merging state data with + /* Example of statedata, in this case merging state data with * state information. In this case adding dummy interface operation state * to configured interfaces. * Get config according to xpath */ @@ -518,8 +518,8 @@ example_statedata(clixon_handle h, NULL, &xstate, NULL) < 0) goto done; /* For the case when urn:example:clixon is not loaded */ } - /* Event state from RFC8040 Appendix B.3.1 - * Note: (1) order is by-system so is different, + /* Event state from RFC8040 Appendix B.3.1 + * Note: (1) order is by-system so is different, * (2) event-count is XOR on name, so is not 42 and 4 */ if (yang_find_module_by_namespace(yspec, "urn:example:events") != NULL){ @@ -600,7 +600,7 @@ example_statefile(clixon_handle h, if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, xpath) < 0) goto done; /* Mark elements to copy: - * For every node found in x0, mark the tree as changed + * For every node found in x0, mark the tree as changed */ for (i=0; i..., ..., ..., Mount this yang on mountpoint * -M Namespace of mountpoint, note both -m and -M must exist @@ -74,7 +74,7 @@ static char *_mount_namespace = NULL; static clixon_plugin_api api; -/*! Example cli function +/*! Example cli function */ int mycallback(clixon_handle h, @@ -110,7 +110,7 @@ mycallback(clixon_handle h, return retval; } -/*! Example "downcall", ie initiate an RPC to the backend +/*! Example "downcall", ie initiate an RPC to the backend */ int example_client_rpc(clixon_handle h, @@ -356,7 +356,7 @@ example_cli_errmsg(clixon_handle h, /*! Callback for printing version output and exit * - * A plugin can customize a version (or banner) output on stdout. + * A plugin can customize a version (or banner) output on stdout. * Several version strings can be printed if there are multiple callbacks. * If no registered plugins exist, clixon prints CLIXON_GITHASH * Typically invoked by command-line option -V diff --git a/example/main/example_netconf.c b/example/main/example_netconf.c index ac0c3fb5..c0f620e2 100644 --- a/example/main/example_netconf.c +++ b/example/main/example_netconf.c @@ -26,7 +26,7 @@ of those above. If you wish to allow use of your version of this file only under the terms of the GPL, and not to allow others to use your version of this file under the terms of Apache License version 2, indicate - your decision by deleting the provisions above and replace them with the + your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the Apache License version 2 or the GPL. @@ -66,7 +66,7 @@ plugin_exit(clixon_handle h) return 0; } -/*! Local example netconf rpc callback +/*! Local example netconf rpc callback */ int netconf_client_rpc(clixon_handle h, diff --git a/example/main/example_restconf.c b/example/main/example_restconf.c index 65f4b292..8ad00d48 100644 --- a/example/main/example_restconf.c +++ b/example/main/example_restconf.c @@ -1,7 +1,7 @@ /* * ***** BEGIN LICENSE BLOCK ***** - + Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren Copyright (C) 2017-2019 Olof Hagsand Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgat)e @@ -25,14 +25,14 @@ in which case the provisions of the GPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the GPL, and not to allow others to - use your version of this file under the terms of Apache License version 2, + use your version of this file under the terms of Apache License version 2, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the Apache License version 2 or the GPL. ***** END LICENSE BLOCK ***** - * + * */ #include @@ -49,7 +49,7 @@ #include #include /* minor use */ -/* Command line options to be passed to getopt(3) +/* Command line options to be passed to getopt(3) */ #define RESTCONF_EXAMPLE_OPTS "m:M:" @@ -197,7 +197,7 @@ b64_decode(const char *src, * * @param[in] h Clixon handle * @param[in] req Per-message request www handle to use with restconf_api.h - * @param[out] authp NULL: Credentials failed, no user set (401 returned). + * @param[out] authp NULL: Credentials failed, no user set (401 returned). * String: Credentials OK, the associated user, must be mallloc:ed * Parameter signtificant only if retval is 1/OK * @retval 1 OK, see authp parameter for result. @@ -281,7 +281,7 @@ example_basic_auth(clixon_handle h, * @param[in] h Clixon handle * @param[in] req Per-message request www handle to use with restconf_api.h * @param[in] auth_type Authentication type: none, user-defined, or client-cert - * @param[out] authp NULL: Credentials failed, no user set (401 returned). + * @param[out] authp NULL: Credentials failed, no user set (401 returned). * String: Credentials OK, the associated user, must be mallloc:ed * Parameter signtificant only if retval is 1/OK * @retval 1 OK, see authp parameter for result. @@ -315,7 +315,7 @@ example_restconf_credentials(clixon_handle h, return retval; } -/*! Local example restconf rpc callback +/*! Local example restconf rpc callback */ int restconf_client_rpc(clixon_handle h, diff --git a/lib/src/clixon_data.c b/lib/src/clixon_data.c index e171506f..62ec0ed6 100644 --- a/lib/src/clixon_data.c +++ b/lib/src/clixon_data.c @@ -281,11 +281,11 @@ clicon_data_int_get(clixon_handle h, return atoi(s); } -/*! Set a single string data via handle +/*! Set a single int data via handle * * @param[in] h clixon_handle * @param[in] name option name - * @param[in] val option value, must be null-terminated string + * @param[in] val option value * @retval 0 OK * @retval -1 Error */ diff --git a/lib/src/clixon_datastore.c b/lib/src/clixon_datastore.c index 0f130b88..d8880ba8 100644 --- a/lib/src/clixon_datastore.c +++ b/lib/src/clixon_datastore.c @@ -278,7 +278,7 @@ xmldb_disconnect(clixon_handle h) return retval; } -/*! Copy datastore from db1 to db2 +/*! Copy datastore from db1 to db2, both cache and datastore * * May include copying datastore directory structure * @param[in] h Clixon handle diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 6fdaf391..885d9605 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -203,7 +203,7 @@ new "Check nothing added" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Add subtree eth/0/0 using none and create which should add eth/0/0" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone" "" "" # Too many quotes, (single inside double inside single) need to fool bash rpc=$(chunked_framing "") @@ -215,19 +215,19 @@ new "Check eth/0/0 added using xpath" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "eth/0/0ex:eth" new "Re-create same eth/0/0 which should generate error" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone" "" "" new "Delete eth/0/0 using none config" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone" "" "" new "Check deleted eth/0/0 (non-presence container)" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Re-Delete eth/0/0 using none should generate error" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone" "" "" new "Add interface without key" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:ethnone " "applicationmissing-elementnameerrorMandatory key in 'list interface' in ietf-interfaces.yang" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:ethnone" "applicationmissing-elementnameerrorMandatory key in 'list interface' in ietf-interfaces.yang" new "netconf discard-changes" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" diff --git a/test/test_restconf_plain_patch.sh b/test/test_restconf_plain_patch.sh index e13fe0c1..a75c5fac 100755 --- a/test/test_restconf_plain_patch.sh +++ b/test/test_restconf_plain_patch.sh @@ -197,8 +197,9 @@ wait_restconf new "Create album London Calling with PUT" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash/album=London%20Calling -d '{"example-jukebox:album":{"name":"London Calling"}}')" 0 "HTTP/$HVER 201" -new "The message-body for a plain patch MUST be present" -expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Beatles -d '')" 0 "HTTP/$HVER 400" "The message-body MUST contain exactly one instance of the expected data resource" +#new "The message-body for a plain patch MUST be present" +# XXXThis sometimes hangs +#expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Beatles -d '')" 0 "HTTP/$HVER 400" "The message-body MUST contain exactly one instance of the expected data resource" # Plain patch can be used to create or update, but not delete, a child # resource within the target resource.