From c529847790dfb748aa967920272d3b84507e616c Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 7 May 2019 11:47:30 +0200 Subject: [PATCH] * Yang "min-element" and "max-element" feature supported * New Clixon Yang RPC: ping. To check if backup is running. * Fixed support for multiple datanodes in a choice/case statement. --- CHANGELOG.md | 14 +- README.md | 5 +- apps/backend/backend_client.c | 25 ++- apps/netconf/netconf_main.c | 20 +- apps/restconf/restconf_methods.c | 12 ++ lib/clixon/clixon_netconf_lib.h | 1 + lib/src/clixon_netconf_lib.c | 35 ++++ lib/src/clixon_plugin.c | 3 +- lib/src/clixon_xml_map.c | 272 +++++++++++++++++++------ lib/src/clixon_yang.c | 109 +++++++--- test/lib.sh | 34 +++- test/mem.sh | 2 +- test/test_choice.sh | 124 +++++++---- test/test_list.sh | 141 ------------- test/test_minmax.sh | 241 ++++++++++++++++++++++ test/test_nacm_default.sh | 6 +- test/test_restconf.sh | 7 +- test/test_restconf2.sh | 3 +- test/test_stream.sh | 5 +- yang/clixon/clixon-lib@2019-01-02.yang | 3 + 20 files changed, 776 insertions(+), 286 deletions(-) delete mode 100755 test/test_list.sh create mode 100755 test/test_minmax.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f9e91c2..c5e53f55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,15 @@ ## 3.10.0/4.0.0 (Upcoming) ### Major New features +* Yang "min-element" and "max-element" feature supported + * According to RFC 7950 7.7.4 and 7.7.5 + * See (tests)[test/test_minmax.sh] + * The following cornercases are not supported: + * Check for min-elements>0 for empty lists on top-level + * Check for min-elements>0 for empty lists in choice/case * Yang "unique" feature supported - * See RFC 7950 7.8.3 + * According to RFC 7950 7.8.3 + * See (tests)[test/test_unique.sh] * Persistent CLI history: [Preserve CLI command history across sessions. The up/down arrows](https://github.com/clicon/clixon/issues/79) * The design is similar to bash history: * The CLI loads/saves its complete history to a file on entry and exit, respectively @@ -46,6 +53,8 @@ ### API changes on existing features (you may need to change your code) +* New Clixon Yang RPC: ping. To check if backup is running. + * Try with `]]>]]>` * Restconf with startup feature will now copy all edit changes to startup db (as it should according to RFC 8040) * Netconf Startup feature is no longer hardcoded, you need to explicitly enable it (See RFC 6241, Section 8.7) * Enable in config file with: `ietf-netconf:startup`, or use `*:*` @@ -116,6 +125,8 @@ ### Minor changes +* Netconf error handling modified + * New option -e added. If set, the netconf client returns -1 on error. * A new minimal "hello world" example has been added * Experimental customized error output strings, see [lib/clixon/clixon_err_string.h] * Empty leaf values, eg are now checked at validation. @@ -143,6 +154,7 @@ * Added libgen.h for baseline() ### Corrected Bugs +* Fixed support for multiple datanodes in a choice/case statement. Only single datanode was supported. * Fixed an ordering problem showing up in validate/commit callbacks. If two new items following each order (yang-wise), only the first showed up in the new-list. Thanks achernavin! * Fixed a problem caused by recent sorting patches that made "ordered-by user" lists fail in some cases, causing multiple list entries with same keys. NACM being one example. Thanks vratnikov! * [Restconf does not handle startup datastore according to the RFC](https://github.com/clicon/clixon/issues/74) diff --git a/README.md b/README.md index e01bafcd..36c29745 100644 --- a/README.md +++ b/README.md @@ -111,12 +111,11 @@ Clixon follows: However, the following YANG syntax modules are not implemented: - deviation -- min/max-elements - action - refine -- Yang extended Xpath functions: re-match, deref, derived-from, derived-from-or-self, enum-value, bit-is-set -Restrictions on Yang types are as follows: +The following restrictions on Yang exists: +- Yang extended Xpath functions: re-match, deref, derived-from, derived-from-or-self, enum-value, bit-is-set - Submodules cannot re-use a prefix in an import statement that is already used for another imported module in the module that the submodule belongs to. (see https://github.com/clicon/clixon/issues/60) - Default values on leaf-lists are not supported (RFC7950 7.7.2) diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index 358d4c5e..cdb9393d 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -1039,6 +1039,26 @@ from_client_debug(clicon_handle h, return retval; } +/*! Check liveness of backend daemon, just send a reply + * @param[in] h Clicon handle + * @param[in] xe Request: + * @param[out] cbret Return xml tree, eg ..., "); + return 0; +} + /*! An internal clicon message has arrived from a client. Receive and dispatch. * @param[in] h Clicon handle * @param[in] s Socket where message arrived. read from this. @@ -1271,10 +1291,13 @@ backend_rpc_init(clicon_handle h) if (rpc_callback_register(h, from_client_create_subscription, NULL, "urn:ietf:params:xml:ns:netmod:notification", "create-subscription") < 0) goto done; - /* In backend_client.? Clixon RPC */ + /* Clixon RPC */ if (rpc_callback_register(h, from_client_debug, NULL, "http://clicon.org/lib", "debug") < 0) goto done; + if (rpc_callback_register(h, from_client_ping, NULL, + "http://clicon.org/lib", "ping") < 0) + goto done; retval =0; done: return retval; diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index f85bba32..68d82705 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -71,10 +71,13 @@ #include "netconf_rpc.h" /* Command line options to be passed to getopt(3) */ -#define NETCONF_OPTS "hD:f:l:qa:u:d:p:y:U:t:o:" +#define NETCONF_OPTS "hD:f:l:qa:u:d:p:y:U:t:eo:" #define NETCONF_LOGFILE "/tmp/clixon_netconf.log" +/*! Ignore errors on packet errors: continue */ +static int ignore_packet_errors = 1; + /*! Process incoming packet * @param[in] h Clicon handle * @param[in] cb Packet buffer @@ -235,8 +238,9 @@ netconf_input_cb(int s, /* OK, we have an xml string from a client */ /* Remove trailer */ *(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0'; - if (netconf_input_packet(h, cb) < 0) - ; //goto done; // ignore errors + if (netconf_input_packet(h, cb) < 0 && + !ignore_packet_errors) // default is to ignore errors + goto done; if (cc_closed) break; cbuf_reset(cb); @@ -338,6 +342,7 @@ usage(clicon_handle h, "\t-y \tLoad yang spec file (override yang main module)\n" "\t-U \tOver-ride unix user with a pseudo user for NACM.\n" "\t-t \tTimeout in seconds. Quit after this time.\n" + "\t-e \tDont ignore errors on packet input.\n" "\t-o \"