Commit graph

108 commits

Author SHA1 Message Date
Olof hagsand
1f8c759f3d Merge branch 'master' of https://github.com/clicon/clixon.
Added new API function `xpath_parse()` to split parsing and xml evaluation.
2019-07-08 14:47:18 +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
c3245f0600 On validation callbacks, XML_FLAG_ADD is added to all nodes at startup validation, not just the top-level. This is the same behaviour as for steady-state validation. 2019-06-19 21:54:59 +02:00
Olof hagsand
fc78824110 Many validation functions have changed error parameter from cbuf to xml tree. 2019-06-10 12:49:40 +02:00
Olof hagsand
3dba0b5370 Restore xmldb_get() to original (but removed one parameter
Moved all zero-copy xmldb_get functions to xmldb_get0.
Clarified CHANGELOG for xmldb_get changes
2019-06-04 11:14:03 +02:00
Olof hagsand
2fe185d683 * Support for multiple patterns as described in RFC7950 Section 9.4.7
* Added regex cache to type resolution
* Added compiled regexp parameter as part of internal yang type resolution functions
* All internal `ys_populate_*()` functions (except ys_populate()) have switched parameters: `clicon_handle, yang_stmt *)`
2019-05-29 11:39:09 +02:00
Olof hagsand
a804e05375 * Added clicon_handle as parameter to all validate functions
* Added libxml2 XSD regexp mode as alternative to posix translation
* Added `CLICON_YANG_REGEXP` option with possible values libxml2 and posix
2019-05-23 22:48:33 +02:00
Olof hagsand
7e109d1d4b Startup transactions did not mark added tree with XML_FLAG_ADD as it should 2019-05-21 10:55:16 +02:00
Olof hagsand
b103599a1a * Clixon transaction mechanism has changed which may affect your backend plugin callbacks:
* Validate-only transactions are terminated by an `end` or `abort` callback.
* If a commit user callback fails, a new `revert` callback will be made to plugins that have made a succesful commit.
2019-05-10 14:45:23 +02:00
Olof hagsand
99b7a1fe5b Clixon config option CLICON_XMLDB_CACHE renamed to CLICON_DATASTORE_CACHE and changed type from boolean to datastore_cache 2019-05-09 14:25:16 +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
8c36083e16 * A yang type regex cache added, this helps the performance by avoiding re-running the regcomp command on every iteration.
* An XML namespace cache added (see `xml2ns()`)
* Better performance of XML whitespace parsing/scanning.
2019-04-19 16:01:39 +02:00
Olof hagsand
728c97ab6d Failure in startup - modified to handle memory exhaustion when loading file 2019-04-18 15:38:15 +02:00
Olof hagsand
4a1e0f2cbc xmldb_get cache bug 2019-04-10 15:58:21 +02:00
Olof hagsand
e29cd7cfb9 * Optimized validation by making xml_diff work on raw cache tree (not copies)
* xmldb_get() removed unnecessary config option
2019-04-07 15:55:53 +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
4de15343c9 optimize 2019-04-02 11:46:28 +02:00
Olof Hagsand
c07577b42b startup diff vector should be children of config root, not root itself 2019-03-29 15:31:00 +01:00
Olof hagsand
8624be0a67 xml changelog next iteration 2019-03-26 12:04:51 +01:00
Olof hagsand
7b9edd7112 ret error 2019-03-25 14:31:21 +01:00
Olof hagsand
a0abf8436e XML chanelog revision 2019-03-25 10:42:27 +01:00
Olof hagsand
3f68cca06c * New yang changelog experimental feature for automatic upgrade
* Added modules-state diff parameter to xmldb_get datastore function for startup scenarios.
* Allowed Yang extended Xpath functions (syntax only):
  * re-match, deref, derived-from, derived-from-or-self, enum-value, bit-is-set
* XSD regular expression handling of dash(`-`)
  *: Translate XDS `[xxx\-yyy]` to POSIX `[xxxyyy-]`.
* YANG Anydata treated same as Anyxml
2019-03-21 18:05:55 +01:00
Olof hagsand
606245ef02 * Added flags to example backend to control its behaviour:
* Start with `-- -r` to run the reset plugin
  * Start with `-- -s` to run the state callback
* Rewrote yang dir load algorithm to follow the algorithm in [FAQ](FAQ(doc/FAQ.md#how-are-yang-files-found) with more precise timestamp checks, etc.
2019-03-18 16:31:34 +01:00
Olof hagsand
b1c74b5f1f * Ensured you can add multiple callbacks for any RPC, including basic ones.
* Extra RPC:s will be called _after_ the basic ones.
  * One specific usecase is hook for `copy-config` (see [doc/ROADMAP.md] that can be implemented thus way.
* `rpc_callback_register` added a namespace parameter. Example:
   ```
     rpc_callback_register(h, empty_rpc, NULL, "urn:example:clixon", "empty");
   ```
2019-03-10 17:27:52 +01:00
Olof Hagsand
a529546c88 Merge branch 'master' of https://github.com/clicon/clixon 2019-02-28 13:11:22 +01:00
Olof hagsand
560110b4e8 * New backend startup and upgrade support, see [doc/startup.md] for details
* Datastore files contain RFC7895 module-state information
2019-02-26 15:48:15 +01:00
Olof hagsand
057f4835db Did not check for missing list keys in validate. [Key of a list isn't mandatory](https://github.com/clicon/clixon/issues/73) 2019-02-13 18:19:33 +01:00
Olof hagsand
1e4022e73c NACM cleanup, uniform rule function, change of function names, etc. 2019-02-02 11:35:50 +01:00
Olof hagsand
ffecebf32a * NACM Data node READ access module support (RFC8341 3.4.5)
* Access control points added for `get` and `get-config` in addition to incoming rpc.
   * RFC 8341 Example A.2 implemented, see: [test/test_nacm_module.sh]
* Added `username` argument on `xmldb_put()` datastore function for NACM data-node write checks
* Added `xml_rootchild_node()` lib function as variant of `xml_rootchild()`
2019-01-27 13:26:15 +01:00
Olof hagsand
5b6af82e29 Validation of mandatory choice and recursive mandatory containers. 2019-01-05 11:08:16 +01:00
Olof hagsand
6c48165340 three-valued return values for datastore text_modify 2019-01-02 18:20:50 +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
f872c7e295 * More precise Yang validation and better error messages
* For Example, adding bad-, missing-, or unknown-element error messages, etc instead of operation-failed
* Removed delete-config support for candidate db since it is not supported in RFC6241.
* Switched the order of `error-type` and `error-tag` in all netconf and restconf error messages to comply to RFC order.
* Added example_rpc RPC to example backend
* Renamed xml_namespace[_set]() to xml_prefix[_set]()
* Some restconf error messages contained "rpc-reply" or "rpc-error" which have now been removed.
* Netconf/Restconf RPC extra input arguments are ignored (https://github.com/clicon/clixon/issues/47)
2018-12-21 01:33:41 +01: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
efa72e9e6f * Proper RFC 6241 Netconf error handling
* New functions added in clixon_netconf_lib.[ch]
  * Datastore code modified for RFC 6241
  * Remaining: validate, generic restconf and netconf code
2018-03-18 18:06:02 +00:00
Olof hagsand
11e2b91a05 Experimental: Added CLICON_TRANSACTION_MOD configurqation option. If set,
modifications in validation and commit callbacks are written back
  into the datastore.
2018-03-07 22:33:47 +01:00
Olof hagsand
38f0b446fa 2017->2018 2018-01-01 12:25:33 +01:00
Olof Hagsand
dd7f790193 Fixed bug that deletes running on startup if backup started with -m running 2017-12-10 15:29:22 +01:00
Olof hagsand
5ae1aeb427 Added support for YANG anyxml; Yang union CLI generation and validation; Removed yang string escaping 2017-07-27 11:54:28 +02:00
Olof hagsand
1b6c9aacbe Added validation for leafref forward and nackward references. 2017-07-18 19:56:54 +02:00
Olof hagsand
f5c19d8586 Added state data 2017-07-01 17:42:39 +02:00
Olof hagsand
abd3eee17d Generic map_str2int generic mapping tables; Removed vector return values from xmldb_get() 2017-06-21 21:02:09 +02:00
Olof Hagsand
18093441a8 revert xsl for . and .. 2017-04-03 15:21:13 +02:00
Olof hagsand
eec5896797 internal netconf mods 2017-03-25 18:24:52 +01:00
Olof hagsand
2fcefda831 Change internal protocol from clicon_proto.h to netconf. 2017-03-25 11:10:50 +01:00
Olof hagsand
4461cc9598 Netconf startup configuration support. Set CLICON_USE_STARTUP_CONFIG to 1 to
enable. Eg, if backend_main is started with -CIr startup will be copied to
  running.
 Added .. as valid step in xpath
2017-02-10 11:54:34 +01:00
Olof hagsand
7f0b9909b3 Library functions in clixon_cli_api.h (e.g cli_commit) is rewritten in new
for (eg cli_commitv). See clixon_cli_api.h for new names.
Use restconf format for internal xmldb keys. Eg /a/b=3,4
Changed example to use multiple cli callbacks
2017-01-31 22:36:14 +01:00
Olof hagsand
bc2b606167 dual license 2016-12-30 16:14:48 +01:00
Olof hagsand
741fb97a9f double predicates in xpath; leaks; grideye debug 2016-03-26 10:47:58 +01:00