Commit graph

285 commits

Author SHA1 Message Date
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
3916fa919c Netconf monitoring RFC 6022 Sessions (https://github.com/clicon/clixon/issues/370)
- statistics and transport/source-host parameters
  - extended internal NETCONF hello with transport and source-host attributes
clixon-lib,yang
  - Moved all extended internal NETCONF attributes to the clicon-lib namespace
C-API:
  - wrapped most attribute creation into new fn xml_add_attr()
2023-01-15 12:36:59 +01:00
Olof hagsand
ffe918dd0e Fixed: [Defaults in choice does not work properly](https://github.com/clicon/clixon/issues/390)
C: Added new file clixon_xml_default.[ch] and moved all default handling there
2022-12-22 12:13:20 +01:00
Olof hagsand
0d41d49fa9 Moved with-defaults processing from get(-config) to xmldb_get when reading db
With-defaults: fixed cornercase in xpath used in list pagination
C-API: Added `with-defaults` parameter (default 0) to `xmldb_get0()`
2022-12-18 19:59:02 +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
1eb78a78f8 Fixed: [YANG when condition evaluated as false combined with a mandatory leaf does not work](https://github.com/clicon/clixon/issues/380)
Replaced yang_mandatory() with yang_xml_mandatory() by extending existing it with when check
2022-10-17 13:49:55 +02:00
Olof hagsand
e532543cea Fixed: With-defaults: top-level container not properly trimmed 2022-09-20 10:52:44 +02:00
Olof hagsand
743076b171 With-defaults CLI support
Extended cli_auto_show() with with-defaults argument, also changing its signature
Example: Added with-defaults argument to clispec
C-API: Added with-defaults argument to clicon_rpc_get_config
Replaced with-defaults prefix/namespace with constants
2022-09-09 13:46:20 +02:00
Olof hagsand
38f501be19 Extended purge argument to xml_defaults_nopresence to handle non-config case
Test: with-defaults: added headings to all test cases
2022-09-09 13:46:20 +02:00
Olof hagsand
15fcae3c23 Fixed: [Clixon backend transaction callback fails for empty types](https://github.com/clicon/clixon/issues/360)
Fixed: [Clixon backend transactions for choice/case is not logical](https://github.com/clicon/clixon/issues/361)
2022-09-07 10:02:30 +02:00
Olof hagsand
c8bf718db8 replace xml_nopresence functions with xml_defaults_nopresence 2022-08-29 18:29:31 +02:00
Jan-Olof Carlson
0a20348b3b rfc6243 with-defaults Capability for NETCONF 2022-08-29 18:27:07 +02:00
Olof hagsand
74da966096 Fixed: [Missing/no namespace error in YANG augments with default values](https://github.com/clicon/clixon/issues/354)
Tests: ensure all netconf requests with identityref have declared namespaces.
  * This is part of fixing [Yang identityref XML encoding is not general](https://github.com/clicon/clixon/issues/90)
2022-08-18 16:38:24 +02:00
Olof hagsand
6f7a33d196 SNMP frontend, new preli table handling code
Skipped data set and use table-helper only
Specialized SNMP error handling
2022-06-26 11:28:42 +02:00
Olof hagsand
05f3ebb59e SNMP frontend: SNMP2YANG type conversion for snmpset 2022-06-26 11:28:42 +02:00
Olof hagsand
aa95ead1cc SNMP frontend: Reworked types for GET types translation
YANG enum type, split up enum to int into two functions
2022-06-26 11:28:42 +02:00
Olof hagsand
bdb516fec9 YANG Action (RFC 7950 Section 7.15)
See [Support for "action" statement](https://github.com/clicon/clixon/issues/101)
2022-06-21 15:44:02 +02:00
Olof hagsand
609e27e0c2 Augmented XML uses default namespace
* Instead of using prefixes for augmented XML, assign the default namespace
Test: moved datastore format tests from test_cli to new test_datastore_format
2022-06-08 11:49:48 +02:00
Olof hagsand
2ece0b8f51 * Experimental text syntax parser/loader
* Added new text syntax parsing and loading from CLI
  * Unified text output functions to `xml2txt` and moved to clixon_text_syntax.[ch]
    * The following are removed: `cli_xml2txt` and `xml2txt_cb`
  * Text output format changed:
    * Namespace/modulename added to top-level
  * See [Support performant load_config_file(...) for TEXT format](https://github.com/clicon/clixon/issues/324)
2022-06-01 11:07:15 +02:00
Olof hagsand
614c927343 * Added nsc parameter to xml2xpath() and ensured the xpath uses prefixes.
* Old code: add `NULL` as second parameter
2022-05-09 13:48:07 +02:00
Olof hagsand
77b4468eb3 Updated copyright statements to 2022 2022-01-18 16:36:00 +01:00
Olof hagsand
081e6871b3 * Renamed clixon-clispec.yang to clixon-autocli.yang
* First version of clixon-autocli.yang semantics
   * Default rules for module exclusion, list-keywords, completion, treeref-state
   * Specialized rules for compress and exclusion of modules
   * See [autocli documentation](https://clixon-docs.readthedocs.io/en/latest/cli.html#autocli)
* Obsoleted and moved autocli config options from clixon-config.yang to clixon-autocli.yang as follows:
   * `CLICON_CLI_GENMODEL`, use: `autocli/module-default=false` instead
      * Removed `clicon_cli_genmodel()`
   * `CLICON_CLI_GENMODEL_TYPE`, use `autocli/list-keyword-default` and compress rules instead)
      * Removed `clicon_cli_genmodel_type()`
   * `CLICON_CLI_GENMODEL_COMPLETION`, use `autocli/completion-default` instead
      * Removed `clicon_cli_genmodel_completion()`
   * `CLICON_CLI_AUTOCLI_EXCLUDE`, use `autocli/rule/operation=exclude` instead
   * `CLICON_CLI_MODEL_TREENAME`, use constant `AUTOCLI_TREENAME` instead
     * Removed `clicon_cli_model_treename()`
* New YANG functions: yang_single_child_type, yang_find_namespace_by_prefix, yang_str2key
* Changed return values of yang_find_prefix_by_namespace
* Merged `cli_cli2xml()` into `cli2xml()`
2022-01-07 12:50:07 +01:00
Olof hagsand
f8f34e3571 * Replaced separate autocli trees with a single @basemodel tree by using filter labels
* Added lastkey argument to yang_key_match()
* Fixed segv in process-sigchld
* Added ietf-yang-library to CLICON_CLI_AUTOCLI_EXCLUDE default value
* Added yang_spec_print() function
2021-12-16 20:23:09 +01:00
Kristofer Hallin
4ac1f0bad0
Implementation of OpenConfig path compression. 2021-10-15 13:55:31 +02:00
Olof hagsand
60193cca0d - Add remaining argument to state callback 2021-09-21 11:27:58 +02:00
Olof hagsand
c9843b34a6 - Rewrite of netconf get/get-config code
- Unified get and get-config code to single function get_common
  - Integrated list-pagination code
  - Moved get code to new files backend_get.[ch]
2021-09-21 11:24:53 +02:00
Olof hagsand
2b5dceb82c cli pagination 2021-09-21 11:22:40 +02:00
Olof hagsand
c35ca82083 * Fixed: Netconf diff callback did not work with choice and same value replace
* Eg if YANG is `choice c { leaf x; leaf y }` and XML changed from `<x>42</x>` to `<y>42</y>` the datastrore changed, but was not detected by diff algorithms and provided to validate callbacks.
  * Thanks: Alexander Skorichenko, Netgate
2021-08-17 16:51:08 +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
3ed41c5a04 cli exclude clixon-restconf, extra cv check in default1 2021-08-05 12:07:07 +02:00
Olof hagsand
603f9724ce * Fixed: YANG when was not properly implemented for LEAF default values 2021-08-03 13:38:31 +02:00
Olof hagsand
babdc6f496 * Fixed: [OpenConfig BGP afi-safi and when condition issues #249](https://github.com/clicon/clixon/issues/249)
* YANG when was not properly implemented for default values
* Improved error message on leafref validation errors
2021-08-02 15:48:38 +02:00
Olof hagsand
a122efceff * Fixed: [restconf patch method adds redundant namespaces #235](https://github.com/clicon/clixon/issues/235) 2021-06-10 13:05:03 +02:00
Olof hagsand
783b0a4857 * YANG when statement in conjunction with grouping/uses/augment
* Several cases were not implemented fully according to RFC 7950
    * Do not extend default values if when statements evaluate to false
    * Do not allow edit-config of nodes if when statements evaluate to false (Sec 8.3.2)
    * If a key leaf is defined in a grouping that is used in a list, the "uses" statement MUST NOT have a "when" statement. (See 7.21.5)
  * See [yang uses's substatement when has no effect #218](https://github.com/clicon/clixon/issues/2$
2021-05-13 14:26:02 +02:00
Olof hagsand
ac51cb0293 * Fix: XPath:s used in netconf (eg get-config) did not correctly access default values 2021-05-07 13:07:34 +02:00
Olof hagsand
1d29d29415 - Fixed: [xml2txt last param not used #204](https://github.com/clicon/clixon/issues/204)
- test: coverage test scripts for CI
2021-04-20 13:05:23 +02:00
Olof hagsand
9087694b58 Fixed: [Backend can not read datastore with container named config #147](https://github.com/clicon/clixon/issues/147) 2021-03-13 17:15:00 +01:00
Olof hagsand
dea3962cc0 * Fixed: [The config false leaf shouldn't be configed in startup stage #189](https://github.com/clicon/clixon/issues/189) 2021-03-11 09:11:14 +01:00
Olof hagsand
b7991d9b39 * Made a separate Clixon datastore XML/JSON top-level symbol
* Replaces the hardcoded "config" keyword.
  * Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h
* Tests: added endtest to all tests. Removed all premature exits if BE=0
2021-03-05 14:15:15 +01:00
Olof hagsand
96b50b88e8 Copyright 2021 2021-01-13 14:40:34 +01:00
Olof hagsand
906d8bc63c [Presence container configs not displayed in 'show config set' #164 ](https://github.com/clicon/clixon/issues/164) 2020-12-28 14:52:56 +01:00
Olof hagsand
07f96934b3 need to check grand-parent exists 2020-12-16 11:37:02 +01:00
Dave Cornejo
1af53a32ce make xml2xpath1() less picky
this function would never traverse up an XML tree from a node that
was not bound to a YANG model. this prevents the function from
working in some cases where it could.
2020-11-13 11:41:31 -05:00
Olof hagsand
1df420255e Fixed [Clixon backend generates wrong XML on empty string value #144](https://github.com/clicon/clixon/issues/144) 2020-10-28 14:28:34 +01:00
Olof hagsand
1614bcd19c Cleanup master for 4.9.0.PRE 2020-10-19 20:06:20 +02:00
Olof hagsand
0b3391836f * Fixed: Validate/commit error with false positive yang choice changes detected in validation found in ietf-ipfix-psamp.yang. 2020-10-15 21:35:14 +02:00
Olof hagsand
6465022f57 Find non-config nodes and mark/return error with better error message 2020-10-15 13:55:44 +02:00
Olof hagsand
9984cfa1c8 Fixed: [default state data returned with get-config](https://github.com/clicon/clixon/issues/140)
* Generalized default code for both config and state
2020-09-27 17:14:28 +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
804b329301 rearranged default code to be outside of copying in xml_get inner loop, and that no defaults are computed if no yang binding is made 2020-09-09 15:52:54 +02:00