Commit graph

70 commits

Author SHA1 Message Date
Olof hagsand
8cdb0bb062 * Changed so that 400 Bad Request are for invalid api-path or unknown yang elements, 404 Not Found for valid xml when object not found. 2019-10-07 22:20:34 +02:00
Olof hagsand
6e41592aec * Changed clicon_rpc_get and clicon_rpc_get_config functions: added username and replaced namespace with namespace context
* Fixed several issues with multiple namespaces.
2019-10-03 22:01:16 +02:00
Olof hagsand
ee329ee382 * RESTCONF "depth" query parameter supported
* C API change: Added `depth` parameter to function `clicon_xml2cbuf`, default is -1.
2019-08-17 10:54:13 +02:00
Olof hagsand
10a2dbe8ec * Added experimental binary search API function: xml_binsearch
* Added content parameter to `clicon_rpc_get` (-1 or CONTENT_ALL is default)
* Reverted change in clixon-lib.yang
2019-08-14 11:13:24 +02:00
Olof hagsand
aa653d0831 CLI multi-key bug for ordered-by user 2019-08-04 17:38:13 +02:00
Olof hagsand
df9e4734f9 Bugfix: multiple key cli bug, ambiguous commands in expand_dbvar 2019-08-04 17:07:11 +02:00
Olof hagsand
1fe7d916f4 segv on multiple keys 2019-08-03 15:08:10 +02:00
Olof hagsand
e7b60619da * Pushed tag to 4.0.1.PRE
* Restconf RFC 8040 increased feature compliance
  * Cache-Control: no-cache added in HTTP responses (RFC Section 5.5)
  * Restconf monitoring capabilities (RFC Section 9.1)
* Added support for Yang extensions
  * New plugin callback: ca_extension
  * Main backend example includes example code on how to implement a Yang extension in a plugin.
* JSON changes
  * Non-pretty-print output removed all extra spaces.
    * Example: `{"nacm-example:x": 42}` --> {"nacm-example:x":42}`
  * Empty JSON container changed from `null` to `{}`.
    * Empty list and leafs remain as `null`
* Removed unnecessary configure dependencies
  * libnsl, libcrypt, libm, if_vlan,...
* pseudo-plugin added, to enable callbacks also for main programs. Useful for extensions
* Yang Unique statements with multiple schema identifiers did not work on some platforms due to memory error.
2019-07-23 22:11:14 +02:00
Olof hagsand
fe46a0e093 Clixon release 4.0.0 2019-07-13 16:33:23 +02:00
Olof hagsand
40d5b99d3b Reverted some of the nsc xpath API changes. In the revert, xpath_first() and xpath_vec() retain their old syntax with nsc==NULL.
The reason is to be conservative with the API. However, less used functions, such as xpath_vec_bool(), xpath_vec_ctx() and xpath_vec_flag()  are changed with a new `nsc`parameter, which should be set to NULL in most cases.
2019-07-09 12:19:03 +02:00
Olof hagsand
67b8685bab The Clixon API has been extended with namespaces, or namespace contexts in the following cases:
* CLIspec functions have added namespace parameter:
    * `cli_show_config <db> <format> <xpath>` --> `cli_show_config <db> <format> <xpath> <namespace>`
    * `cli_copy_config <db> <xpath> ...` --> `cli_copy_config <db> <xpath> <namespace> ...`
  * Xpath API
    * `xpath_first(x, format, ...)` --> `xpath_first(x, nsc, format, ...)`
    * `xpath_vec(x, format, vec, veclen, ...)` --> `xpath_vec(x, nsc, format, vec, veclen, ...)`
    * `xpath_vec_flag(x, format, flags, vec, veclen, ...)` --> `xpath_vec_flag(x, format, flags, vec, veclen, ...)`
    * `xpath_vec_bool(x, format, ...)` --> `xpath_vec_bool(x, nsc, format, ...)`
    * `xpath_vec_ctx(x, xpath, xp)` --> `xpath_vec_ctx(x, nsc, xpath, xp)`
  * xmldb_get0 has an added `nsc` parameter:
    * `xmldb_get0(h, db, xpath, copy, xret, msd)` --> `xmldb_get0(h, db, nsc, xpath, copy, xret, msd)`
  * The plugin statedata callback (ca_statedata) has been extended with an nsc parameter:
    * `int example_statedata(clicon_handle h, cvec *nsc, char *xpath, cxobj *xstate);`
  * rpc get and get-config api function has an added namespace argument:
    * `clicon_rpc_get_config(clicon_handle h, char *db, char *xpath, char *namespace, cxobj **xt);`
    * `int clicon_rpc_get(clicon_handle h, char *xpath, char *namespace, cxobj **xt);`
2019-07-08 10:36:37 +02:00
Olof Hagsand
a7af7e7593 memleaks 2019-05-22 18:27:53 +00:00
Olof hagsand
bc54f2d04c * Regexp improvements
* Added check for libxml in configure';
  * Added clixon_util_regexp utility function
* Yang state get improvements
  * Integrated state and config into same tree on retrieval, not separate trees
  * Added cli functions `cli_show_config_state()` and `cli_show_auto_state()` for showing combined config and state info.
  * Added integrated state in the main example: `interface/oper-state`.
  * Added performance tests for getting state, see [test/test_perf_state.sh].
2019-05-20 16:03:29 +02:00
Olof hagsand
c17784cfe9 Removed O(n^2) in cli expand/completion code 2019-05-16 20:08:25 +02:00
Olof hagsand
06e6ef80d1 Non-key list now not accepted in edit-config (before only on validation) 2019-05-08 12:51:10 +02:00
Olof hagsand
cef0dc5a22 * Added yang access functions
* Change all y->ys_parent to yang_parent_get(y)
    * Change all y->ys_keyword to yang_keyword_get(y)
    * Change all y->ys_argument to yang_argument_get(y)
    * Change all y->ys_cv to yang_cv_get(y)
    * Change all y->ys_cvec to yang_cvec_get(y)
2019-04-11 15:53:25 +02:00
Olof hagsand
56f32371ce * Backend plugin returning NULL was still installed - is now logged and skipped.
* [Parent list key is not validated if not provided via RESTCONF #83](https://github.com/clicon/clixon/issues/83), thanks achernavin22.
2019-04-11 11:25:42 +02:00
Olof hagsand
b5f1f7346e Structural C-code change: Merged yang_spec and yang_node types into yang_stmt 2019-04-02 12:27:33 +02:00
Olof hagsand
5b1c3d9a86 * clixon-config YAML file has new revision: 2019-02-06.
* Replaced all calls to (obsolete) `cli_output` with `fprintf`
* Added _experimental_ config option `CLICON_CLI_UTF8` default set to 0.
  * CLIgen UTF8 does not work with scrolling and control editing
2019-02-06 14:33:04 +01:00
Olof hagsand
0103d58994 2019 2019-01-02 15:48:30 +01:00
Olof hagsand
0baebc93fd * Strict namespace setting can be a problem when upgrading existing database files, such as startup-db or persistent running-db, or any other saved XML file.
* For backward compatibility, load of startup and running set CLICON_XML_NS_STRICT to false temporarily.
* Added three-valued return values for several validate functions where -1 is fatal error, 0 is validation failed and 1 is validation OK.
  * This includes: `xmldb_put`, `xml_yang_validate_all`, `xml_yang_validate_add`, `xml_yang_validate_rpc`, `api_path2xml`, `api_path2xpath`
* Added new xml functions for specific types: `xml_child_nr_notype`, `xml_child_nr_notype`, `xml_child_i_type`, `xml_find_type`.
2019-01-02 15:18:29 +01:00
Olof hagsand
56e51f1a8d 3.8.0.PRE preparations and
* Obsoleted COMPAT_CLIV and COMPAT_XSL that were optional in 3.7
2018-07-22 21:29:21 +02:00
Olof hagsand
ba7f84afee * Much better support for XPATH 1.0 according to https://www.w3.org/TR/xpath-10 using yacc/lex
* NOTE: Due to an error in the previous implementation, all XPATH calls on the form `x[a=str]` where `str` is a string (not a number or XML symbol), must be changed to: `x[a='str'] or x[a="str"]`
    * This includes all calls to `xpath_vec, xpath_first`, etc.
    * All calls to cli_copy_config in CLI spec files must replace 2nd argument from `x[%s=%s]` to `x[%s='%s']`
  * The old API is stillenabled. To define the new, define XPATH_USE_NEW in include/clixon_custom.h and recompile
2018-07-17 16:59:32 +02:00
Olof hagsand
85c4782e36 Dedicated xml,json,yang and xsl parser utility programs added
Sanity check of stdarg (...) added
Cleanup of error messages.
2018-06-17 19:40:06 +02:00
Olof hagsand
dacd2fe3a0 replace obsolete cvec_find_var with cvec_find 2018-06-08 15:54:43 +02:00
Olof hagsand
c5991c9844 * Added a generated CLI show command that works on the generated parse tree with auto completion.
* A typical call is: 	show @datamodel:example, cli_show_auto("candidate", "json");
  * The example contains a more elaborate example.
  * Thanks ngashok for request, see https://github.com/clicon/clixon/issues/24
2018-06-05 16:45:43 +02:00
Olof hagsand
39538461c2 dont exit cli when expand gets auth denied from backend 2018-06-03 20:18:43 +02:00
Olof hagsand
ea13727e97 * Removed cli callback vector functions. Set COMPAT_COMPAT_CLIV if you need to keep these functions in clixon_custom.h.
* Added --enable-debug.
2018-05-30 22:38:12 +02:00
Olof hagsand
1ac57dedaf Some memleaks and last minute 3.6 release changes. 2018-04-29 18:35:06 +02:00
Olof hagsand
67c0abead7 Fixed issue https://github.com/clicon/clixon/issues/17 special character in strings can break RPCs 2018-04-21 16:32:46 +02:00
Olof hagsand
7650803475 * Experimental NACM RFC8341 Network Configuration Access Control Model.
* CLICON_NACM_MODE config option, default is disabled.
  * Added username attribute to all rpc:s from frontend to backend
  * Added NACM backend module in example
2018-04-19 22:44:15 +02:00
Olof hagsand
79e3fbdaa9 * Restructure and more generic plugin API (cli,backend,restconf,netconf)
* For preparation for authorization RFC8341
  * Plugins add clixon_plugin_init() and api struct for function pointers, eg:
```
static const struct clixon_plugin_api api = {
    "example",
    clixon_plugin_init,
    ...
}
clixon_plugin_api *clixon_plugin_init(clicon_handle h)
{
    return (void*)&api;
}
```
  * Moved specific plugin functions from apps/ to generic functions in lib/
    * New generic plugin load function: clixon_plugins_load()
  * Removed client-local netconf plugins netconf_plugin_callbacks()
    * This was code used before generic YANG rpc calls
  * Added username to clixon handle:
    * clicon_username_get() / clicon_username_set()
  * Added authentication plugin callback
  * Removed some obscure plugin code that seem not to be used (please report if needed!)
    * CLI parse hook
    * CLICON_FIND_PLUGIN
    * clicon_valcb()
* Removed username to rpc calls (added below)
2018-04-02 10:38:53 +02:00
Olof Hagsand
ac7480b9f5 * Invalid key to api_path2xml gives warning instead of error and quit. 2018-03-05 20:00:10 +00:00
Olof hagsand
990700b68d https://github.com/clicon/clixon/issues/16
Added restconf/operations get, see RFC8040 Sec 3.3.2:
2018-03-04 21:24:38 +01:00
Olof hagsand
35b142cf4d * Added Yang "extension" statement. This includes parsing unknown
statements and identifying them as extensions or not. However,
  semantics for specific extensions must still be added.
* Renamed ytype_id and ytype_prefix to yarg_id and yarg_prefix, respectively

* Added cli_show_version()
2018-02-25 20:01:53 +01:00
Olof hagsand
278f3de840 Adding username to all restconf backend calls 2018-02-13 09:17:32 +07:00
Olof hagsand
e40d785d5c * Added a "user" parameter to plugin_credentials() restconf callback.
To enable authentication and in preparation for access control a la RFC 6536.
* yang string length "max" keyword set to MAXPATHLEN
2018-02-08 15:24:05 +07:00
Olof hagsand
363bd5d19d New configuration option: CLICON_RESTCONF_PRETTY
Changed RESTCONF GET to return object referenced. ie, GET /restconf/data/X returns X.
2018-01-07 18:01:42 +01:00
Olof hagsand
38f0b446fa 2017->2018 2018-01-01 12:25:33 +01:00
Olof Hagsand
0076a8b838 leafref bug 2017-12-09 20:48:29 +01:00
Olof hagsand
e169485985 Datastore cache introduced; Added yang to XML API 2017-12-02 14:49:49 +01:00
Olof hagsand
14cfc46ce4 Apple Darwin port 2017-10-12 22:03:02 +02:00
Olof hagsand
5cea5fa768 xml config default; api_path_fmt2api_path cleanup 2017-10-03 22:41:12 +02:00
Olof hagsand
becddfab41 Added format string to clicon_rpc_generate_error() and used that to make better backend error messages 2017-09-27 18:10:13 +02:00
Olof hagsand
d8065551b6 cli_copy config bug; allow non-api-path expand_dbvar() 2017-08-03 22:35:02 +02:00
Olof hagsand
fd91bb2933 restconf RPC 2017-07-30 16:16:10 +02:00
Olof hagsand
e5b625e722 Added support for yang presence and no-presence containers. 2017-07-23 12:59:02 +02:00
Olof hagsand
f995f1e268 Added completion for generated cli leafrefs for both absolute and relatve paths. 2017-07-19 09:26:56 +02:00
Olof hagsand
1b6c9aacbe Added validation for leafref forward and nackward references. 2017-07-18 19:56:54 +02:00
Olof hagsand
43c39160a5 Restricted yang (sub)module file match to match RFC6020 exactly 2017-06-25 17:48:21 +02:00