Commit graph

43 commits

Author SHA1 Message Date
Olof hagsand
c2841d6e40 Various memory and file resource cleanup after valgrind tests 2024-06-23 18:46:44 +02:00
Olof hagsand
a1badc312e Fixes after coverity static analysis 2024-03-03 17:05:36 +01:00
Philip Prindeville
cf2e27b43d Drop __FUNCTION__ from clixon_debug() calls 2024-01-11 17:29:37 +01:00
Philip Prindeville
af77da38bb Discriminate XPath debugging 2024-01-10 20:06:38 +01:00
Olof hagsand
9e54f0602f Changed ca_errmsg callback to a more generic variant
Includes all error, log and debug messages
See [Customized NETCONF error message](https://github.com/clicon/clixon/issues/454)
2024-01-05 16:41:53 +01:00
Olof hagsand
24a4991ec8 Restructured error,debug anf log API
Renamed functions clicon->clixon, replaced global variables w access functions
Unified clicon_netconf_error with clixon_err()
2023-12-18 08:29:14 +01:00
Olof hagsand
62348fc9c7 C-style update: Unified comment, retvals in order, remove trailing spaces
Changed function name for `clicon_debug` functions
2023-10-23 09:58:13 +02:00
Olof hagsand
79d1d2e95a * Fixed: [xpath // abbreviation does not work other than on the top-level](https://github.com/clicon/clixon/issues/435) 2023-06-21 11:45:49 +02:00
Olof hagsand
da2edceb7e * Added new functions: xml_tree_equal and xpath2xml
* RFC 8528 yang schema mount-points:
  * Made expand_dbvar and cli_dbxml mountpoint-aware (RFC 8528)
  * autocli supportgenerate
  * Made api_path2xml and xml2api_path mount-point-aware
  * Temporar fix in clixon_custom.h: XPATH_CANONICAL_SKIP_CHECK
* `xml2xpath()`: Added `apostrophe` as 4th parameter, default 0
* removed extra assert.h includes
2023-03-23 22:16:33 +01:00
Olof hagsand
da9bfcbb53 * Changed debug levels in clicon_debug() to be based on maskable flags
* Added flag names: `CLIXON_DBG_*`
  * Added maskable flags that can be combined when debugging:
    * `DEFAULT` = 1: Basic debug message, espcially initialization
    * `MSG` = 2: Input and output packets, read datastore
    * `DETAIL` = 4: Details: message dump in hex, xpath parse trees, etc
    * `EXTRA` = 8: Extra detailed logs
* Test: some errors in yang-lib where content-id was in wrong place
2023-01-27 14:56:58 +01:00
Olof Hagsand
bc6cc2b31f C-API: All calls to clicon_log_xml() changed to new function `clicon_debug_xml()\
Debugging, moved many detailed debugs from level 1 to 2
2023-01-15 13:17:58 +01:00
Olof hagsand
b67ef69b7f Fixed: XPath evaluation of two nodes reverted to strcmp even if both were numbers 2022-12-22 16:42:41 +01:00
Olof hagsand
2cdc78c576 Fixed static compile of util validate
FIxed mem-leaks on xpath errors
Test: valgrind of confirmed-commit
2022-11-25 17:57:24 +01:00
Olof hagsand
779fcf5458 Fixed xpath crashes discovered by fuzzing
Added fuzz code for xpath
Test: added negative xpath tests
2022-11-04 17:45:54 +01:00
Olof hagsand
e3d621c66d Fixed: SEGV when using NETCONF get filter xpath and non-existent key
* eg `select="/ex:table[ex:non-exist='a']`
2022-11-01 11:13:40 +01:00
Olof hagsand
d84c529ff1 [Code formatting: Change indentation style to space](https://github.com/clicon/clixon/issues/379)
* Applies to all c/h/y/l/sh files and .editorconfig
2022-10-27 14:21:17 +02:00
Olof hagsand
38027c8331 Added XPATH function boolean()
* This caused problem for new NTP YANG in RFC 9249
Fixed segv on anydata for http parser
2022-07-08 15:11:56 +02:00
Olof hagsand
77b4468eb3 Updated copyright statements to 2022 2022-01-18 16:36:00 +01:00
Olof hagsand
bc1f80b28e Added support for the XPATH function bit-is-set() 2021-11-27 15:40:44 +01:00
Olof hagsand
3cd3f7987d - Cannot reproduce https://github.com/clicon/clixon/issues/245, added sanity chaeck and regression test 2021-09-09 14:01:48 +02:00
Olof hagsand
980718178a * YANG Leafref feature update
* Closer adherence to RFC 7950. Some of this is changed behavior, some is new feature.
  * Essentially instead of looking at the referring leaf, context is referred(target) node
  * Validation uses referred node
    * Validation changed to use type of referred node, instead of just "string"
  * Auto-cli
    * Changed to use type of referred node for typecheck
    * Completion uses referred node
  * Required instance / less strict validation
    * New: Leafrefs must refer to existing data leaf ONLY IF YANG `required-instance` is true
    * Previous: All leafrefs must refer to existing data leaf node
* Fixed: [Autocli does not offer completions for leafref to identityref #254](https://github.com/clicon/clixon/issues/254)
2021-08-16 17:14:27 +02:00
Olof hagsand
965cce5e5d * Added SM_RUNNING_STARTUP to translation table
* Fixed https://github.com/clicon/clixon/issues/224 yet again by addressing a mixed xml and yang namespace xpath case
2021-05-27 15:05:50 +02:00
Olof hagsand
e0c3f5467c * Added new startup-mode: running-startup: First try running db, if it is empty try startup db.
* See [Can startup mode to be extended to support running-startup mode? #234](https://github.com/clicon/clixon/issues/234)
* Improved error message on failed MUST condition
2021-05-27 13:18:01 +02:00
Olof hagsand
1ef7a280d7 * Fixed: [when condition error under augment in restconf #227](https://github.com/clicon/clixon/issues/227)
* As part of this fix added custom constant XML_PARENT_CANDIDATE
2021-05-25 15:25:26 +02:00
Olof hagsand
17e7b25537 * RESTCONF in Clixon used empty key as "wildchar". But according to RFC 8040 it should mean the "empty string".
* Example: `GET restconf/data/x:a=`
  * Previous meaning (wrong): Return all `a` elements.
  * New meaning (correct): Return the `a` instance with empty key string: "".
* [RESTCONF GET request of single-key list with empty string returns all elements #213](https://github.com/clicon/clixon/issues/213)
* [RESTCONF GETof lists with empty string keys does not work #214](https://github.com/clicon/clixon/issues/214)
2021-05-05 15:04:22 +02:00
Olof hagsand
5692072d36 * Fixed: [CLIXON is not waiting for the hello message #184](https://github.com/clicon/clixon/issues/184)
* Hello message semantics has been made stricter according to RFC 6241 Sec 8.1, for example:
  * A client MUST send a <hello> element.
  * Each peer MUST send at least the base NETCONF capability, "urn:ietf:params:netconf:base:1.1" (or 1.0 for RFC 4741)
  * The netconf client will terminate (close the socket) if the client does not comply
  * You can set `CLICON_NETCONF_HELLO_OPTIONAL` to true to use the old behavior of essentially ignoring hellos.
* New clixon-config@2020-03-08.yang revision
  * Added: `CLICON_NETCONF_HELLO_OPTIONAL`
* The base capability has been changed to "urn:ietf:params:netconf:base:1.1" following RFC6241.
2021-03-10 14:18:16 +01:00
Olof hagsand
2a4de52e56 * Added support for the following XPATH functions:
* `false`, `true`
* Fixed: [Negation operator in 'must' statement makes backend segmentation fault](https://github.com/clicon/clixon/issues/179)
2021-02-23 15:24:39 +01:00
Olof hagsand
96b50b88e8 Copyright 2021 2021-01-13 14:40:34 +01:00
Olof hagsand
fab261cb53 * Added XPATH functions position 2020-10-27 09:40:45 +01:00
Olof hagsand
21ac47915b More XPath function support
* `count`, `name`, `contains`, `not`, as defined in [xpath 1.0](https://www.w3.org/TR/xpath-10)
  * `deref`, `derived-from` and `derived-from-or-self` from RFC7950 Section 10.
    * in particular in augment/when statements
  * Improved error handling
    * Verification of XPath functions is done at startup when yang modules are loaded, not when XPaths are evaluated.
    * Separation of "not found" and "not implemented" XPath functions
    * Both give a fatal error (backend does not start).
2020-09-25 11:52:06 +02:00
Olof hagsand
c616aa1569 Added support for XPATH functions:
* `contains`,
  * `derived-from` and `derived-from-or-self`
    * in particular in augment/when statements as shown in eg RFC 7950.
2020-09-22 22:40:42 +02:00
Olof hagsand
ff5462ecac Replaced the global variable debug with access function: clicon_debug_get(). 2020-06-09 16:04:49 +02:00
Olof hagsand
65806f1ef2 Copyright change: LLC -> LLC(Netgate) 2020-04-23 16:55:56 +02:00
Olof hagsand
04017c97ba Length of xml vector in many structs changed from to since it is a vector size, not byte size. This includes transaction_data_t 2020-04-21 10:17:09 +02:00
Olof hagsand
9fa5e216c4 * New "general-purpose" datastore upgrade callback added which i called once on startup, intended for lo
w-level general upgrades and as a complement to module-specific upgrade.
  * Called on startup after initial XML parsing, but before module-specific upgrades
  * Enabled by definign the `.ca_datastore_upgrade`
  * [General-purpose upgrade documentation](https://clixon-docs.readthedocs.io/en/latest/backend.html#ge
neral-purpose)
* JSON parse error messages change from ` on line x: syntax error,..` to `json_parse: line x: syntax err
or`
* Unknown-element error message is more descriptive, eg from `namespace is: urn:example:clixon` to: `Fai
led to find YANG spec of XML node: x with parent: xp in namespace urn:example:clixon`.
* C-API parse and validation API more capable
  * `xml_spec_populate` family of functions extended with three-value return values
    * -1: error, 0: parse OK, 1: parse and YANG binding OK.
  * `xml_parse` and `json_parse` API changes
    * Three value returns: -1: error, 0: parse OK, 1: parse and YANG binding OK.
    * Extended `xml_parse_file2` and `xml_parse_string2` extended API functions with all options available.
      * New concept called `yang_bind` that defines how XML symbols are bound to YANG after parsing
    * Existing API same except `xml_parse_file` `endtag` argument moved to `xml_parse_file2`
* C-API: Added instrumentation: `xml_size` and `xml_stats_get`.
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
  * Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set
2020-02-20 14:00:01 +01:00
Olof hagsand
19e21be0bc Very large commit for upcoming 4.4 release
Major New features

* New and updated search functions using xpath, api-path and instance-id
  * New search functions using api-path and instance_id:
    * C search functions: `clixon_find_instance_id()` and `clixon_find_api_path()`
  * Binary search optimization in lists for indexed leafs in all three formats.
    * This improves search performance to O(logN) which is drastical improvements for large lists.
  * You can also register explicit indexes for making binary search (not only list keys)
  * For more info, see docs at [paths](https://clixon-docs.readthedocs.io/en/latest/paths.html) and
[search](https://clixon-docs.readthedocs.io/en/latest/xml.html#searching-in-xml)

API changes on existing features (you may need to change your code)
* On failed validation of leafrefs, error message changed from: `No such leaf` to `No leaf <name> matching path <path>`.
* CLI Error message (clicon_rpc_generate_error()) changed when backend returns netconf error to be more descriptive:
  * Original: `Config error: Validate failed. Edit and try again or discard changes: Invalid argument`
  * New (example): `Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes"

Minor changes

* Test framework
  * Added `-- -S <file>` command-line to main example to be able to return any state to main example.
  * Added `test/cicd` test scripts for running on a set of other hosts
* C-code restructuring
  * clixon_yang.c partitioned and moved code into clixon_yang_parse_lib.c and clixon_yang_module.c and move back some code from clixon_yang_type.c.
    * partly to reduce size, but most important to limit code that accesses internal yang structures, only clixon_yang.c does this now.
2020-02-02 15:52:30 +01:00
Olof hagsand
b340c36f79 Experimental optimized XPath, multiple keys 2019-12-31 13:29:25 +01:00
Olof hagsand
7ad16bd84b * C-API: Added xpath_first_localonly() as an xpath function that skips prefix and namespace checks.
* Added experimental code for optizing XPath search using binary search.
  * Enable with XPATH_LIST_OPTIMIZE
* Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)`
2019-12-20 18:21:46 +01:00
Olof hagsand
728fe9c6ac * Bumped version to 4.3.0.PRE
* Added wildcard `*` as a mode to `CLICON_MODE` in clispec files
* [Add missing includes](https://github.com/clicon/clixon/pulls)
2019-11-03 13:05:50 +01:00
Olof hagsand
279614d64f * The backend socket has now support of credentials of peer clients
* Added: CLICON_NACM_CREDENTIALS and CLICON_NACM_RECOVERY_USER
2019-10-18 19:33:23 +02:00
Olof hagsand
291f173505 libm needed in xpath 2019-07-24 09:46:08 +02:00
Olof hagsand
bb04f778ab documentation 2019-07-09 13:15:25 +02:00
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