Commit graph

165 commits

Author SHA1 Message Date
Olof Hagsand
9d64ddd305 handle null 2019-03-21 20:51:57 +01:00
Olof hagsand
77387e9c65 Merge branch 'master' of https://github.com/dcornejo/clixon into dcornejo-master 2019-03-06 10:03:58 +01:00
Olof hagsand
2394c6f46e Merge branch 'modules-state' 2019-02-26 16:53:59 +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
Dave Cornejo
e282493095 FreeBSD compatibility & pedanticism patches
use ETIMEDOUT rather than ETIME - this seems more the intent of its
usage here and it compiles under FreeBSD & Linux.
in yang_spec_parse_file() the function basename() is not declared,
the declaration is in libgen.h, so include it. also basename() takes
char * for its argument not const char *, yang_spec_parse_file()
has to be changed to char *filename to compile w/o warnings
2019-02-22 19:59:14 -10:00
Olof hagsand
83edd29678 Revert "Revert "* Added valgrind memory leak tests in testmem.sh for restconf""
This reverts commit a73d2bd242.
2019-02-20 16:25:42 +01:00
Olof hagsand
a73d2bd242 Revert "* Added valgrind memory leak tests in testmem.sh for restconf"
String error
This reverts commit 6e63f0a77b.
2019-02-20 16:19:07 +01:00
Olof Hagsand
6e63f0a77b * Added valgrind memory leak tests in testmem.sh for restconf
* Added clicon_socket_set() and clicon_socket_get() functions for cleaning up backend server and restconf FCGI socket on termination.
* Removed obsolete `-x` command-line option to clixon_cli.
2019-02-20 13:06:18 +01:00
Olof hagsand
0267afcb21 * Added -o "<option>=<value>" command-line option to all programs: backend, cli, netconf, restconf.
* Added -p <dir> command-line option to all programs: backend, cli, netconf, restconf.
* Moved and updated all standard ietf and iana yang files from example and yang/ to `yang/standard`.
* Renamed example yang from example.yang -> clixon-example.yang
2019-01-13 17:34:15 +01:00
Olof hagsand
207858e20d * Support of yangmodels supported, see test_yangmodels.sh
* Added -o "<option>=<value>" command-line option to all programs: backend, cli, netconf, restconf.
* Ignore CR(\r) in yang files for DOS files
2019-01-10 20:52:19 +01:00
Olof hagsand
5b6af82e29 Validation of mandatory choice and recursive mandatory containers. 2019-01-05 11:08:16 +01:00
Olof hagsand
058a14579f Yang choice functionality improved and stricter validation for CLI generation, mandatory flags, etc. 2019-01-04 11:37:26 +01:00
Olof hagsand
7a8f242a09 Added new clixon-lib yang module for internal netconf protocol. Currently only extends the standard with a debug RPC. 2019-01-02 22:50:03 +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
861300d6c0 netconf error handling and test summary script 2018-12-21 14:44:59 +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
ae1af8da9e * NACM extension (RFC8341)
* NACM module support (RFC8341 A1+A2)
   * Recovery user "_nacm_recovery" added.
     * Example use is restconf PUT when NACM edit-config is permitted, then automatic commit and discard are permitted using recovery user.
   * Example user changed adm1 to andy to comply with RFC8341 example

 * Yang code upgrade (RFC7950)
   * RPC method input parameters validated
     * see https://github.com/clicon/clixon/issues/4
* Correct XML namespace handling
   * XML multiple modules was based on "loose" semantics so that yang modules were found by iterating thorugh namespaces until a match was made. This did not adhere to proper [XML namespace handling](https://www.w3.org/TR/2009/REC-xml-names-20091208), and causes problems with overlapping names and false positives. Below see XML accepted (but wrong), and correct namespace declaration:
```
      <rpc><my-own-method></rpc> # Wrong but accepted
      <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> # Correct
        <my-own-method xmlns="http://example.net/me/my-own/1.0">
      </rpc>
```
   * To keep old loose semantics set config option CLICON_XML_NS_ITERATE (true by default)
   * XML to JSON translator support for mapping xmlns attribute to module name prefix.
   * Default namespace is still "urn:ietf:params:xml:ns:netconf:base:1.0"
   * See https://github.com/clicon/clixon/issues/49
* Changed all make tags --> make TAGS
* Keyvalue datastore removed (it has been disabled since 3.3.3)
* debug rpc added in example application (should be in clixon-config).
2018-12-16 19:49:19 +01:00
Olof hagsand
ac1aa44fc4 * Yang Configure options changed
* `CLICON_YANG_DIR` is changed from a single directory to a path of directories
    * Note CLIXON_DATADIR (=/usr/local/share/clixon) need to be in the list
  * CLICON_YANG_MAIN_FILE Provides a filename with a single module filename.
  * CLICON_YANG_MAIN_DIR Provides a directory where all yang modules should be loaded.
* Change all @datamodel:tree to @datamodel in all CLI specification files
  * If you generate CLI code from the model (CLIXON_CLI_GENMODEL).
  * For backward compatibility, define CLICON_CLI_MODEL_TREENAME_PATCH in clixon_custom.h
* Removed return value ymodp from yang parse functions (eg yang_parse()).
* New config option: CLICON_CLI_MODEL_TREENAME defining name of generated syntax tree if CLIXON_CLI_GENMODEL is set.
2018-12-03 21:16:35 +01:00
Olof hagsand
d09a8c08aa getopt return value changed from char to int (https://github.com/clicon/clixon/issues/58) 2018-12-01 18:34:52 +01:00
Olof hagsand
39a5086218 * Yang Support of submodule, include and belongs-to.
* Improved unknown handling
* Configure option `CLICON_YANG_DIR` is changed from a single directory to a path of directories
    * Note CLIXON_DATADIR (=/usr/local/share/clixon) need to be in the list
2018-12-01 18:17:42 +01:00
Olof hagsand
af16760279 * Stream replay support
* RFC8040 Restconf replay support: start-time and stop-time query parameter support
    * This only applies to "native" restconf stream support, Nchan mode has different replay functionality
  * RFC5277 Netconf replay support using <startTime> and
  * Replay support is only in-memory and not persistent. External time-series DB could be added.
2018-10-27 11:12:01 +02:00
Olof hagsand
77e56868d4 Load netconf notification and add create-subscription to yang. 2018-10-23 20:43:59 +02:00
Olof hagsand
a4e29bcdb7 * All yang modules are stored in the clicon_dbspec_yang() option.
* Except clixon-config module due to bug reported below
* Bug: Top-level Yang symbol cannot be called "config" in any imported yang file.
  * datastore uses "config" as reserved keyword for storing any XML whoich collides with code for detecting Yang sanit
2018-10-19 15:26:22 +02:00
Olof hagsand
40cda7b6a4 * ietf-netconf yang module added with candidate, validate, startup and xpath features enabled.
* Added urn:ietf:params:netconf:capability:yang-library:1.0
* Thanks SCadilhac for helping out, see https://github.com/clicon/clixon/issues/39
* uri_percent_encode() and xml_chardata_encode() changed to use stdarg parameters
2018-10-17 22:36:59 +02:00
Olof hagsand
65c44b41e8 RFC 7895:
* Changed Netconf hello to single capabilty urn:ietf:params:netconf:capability:yang-library:1.0 according to YANG 1.1 RFC7950 Sec 5.6.4.
  * Set by option: CLICON_MODULE_LIBRARY_RFC7895 - enabled by default
  * Option CLICON_MODULE_SET_ID is set and changed when modules change.
2018-10-12 18:41:53 +02:00
Olof hagsand
ea77e7f02d * YANG Features
* Yang 1.1 feature and if-feature according to RFC 7950 7.20.1 and 7.20.2.
  * See https://github.com/clicon/clixon/issues/41
  * Features are declared via CLICON_FEATURE in the configuration file.
  * logical combination of features not implemented, eg if-feature "not foo or
* Identity without any identityref:s caused SEGV
2018-10-10 20:11:20 +02:00
Olof hagsand
acb8748470 * Generilized top-level yang parsing functions
* Clarified semantics of main yang module:
    * -y option to commands MUST specify filename
    * CLICON_YANG_MODULE_MAIN MUST specify a module
    * yang_parse() changed to take either filename or module name and revision.
  * Removed clicon_dbspec_name[_set]().
    * Use yang_main_module_name() instead.
  * Replaced yang_spec_main with yang_spec_parse_module
  * Added yang_spec_parse_file
2018-10-07 11:04:33 +02:00
Olof hagsand
98f3cd0e32 * Major rewrite of event streams
* If you used old event callbacks API, you need to switch to the streams API
    * See clixon_stream.[ch]
  * Old streams API which needs to be removed include:
    * clicon_log_register_callback()
    * subscription_add() --> stream_register()
    * backend_notify() and backend_notify_xml() - use stream_notify() instead
* Example uses "NETCONF" stream instead of "ROUTING"
* Added timeout option -t for clixon_netconf - quit after max time.
2018-09-30 14:51:30 +02:00
Olof Hagsand
7c94991fe9 * clixon_restconf and clixon_netconf now take -D <level> as command-line option\
instead of just -D
  * This aligns to clixon_cli and clixon_backend
2018-08-03 13:24:41 +02:00
Olof Hagsand
c53f3f2fe3 Added file logging (-l f or -l f<file>) for cases where neither syslog nor stderr is useful\
.
2018-07-30 17:35:45 +00:00
Olof Hagsand
e48f8dd00e clixon_netconf -S is obsolete. Use clixon_netconf -l s instead.
* Unified log handling for all clicon applications using -l e|o|s|f.
  * The options stand for e:stderr, o:stdout, s: syslog, f:file
2018-07-29 19:41:10 +02:00
Olof Hagsand
5164db3603 Added clicon_log_init(.., CLICON_LOG_FILE) option and clicon_log_file() for c\
ases where neither syslog or stderr is useful.
2018-07-26 20:13:02 +02:00
Olof Hagsand
539a60d613 backend socket options -a -u 2018-07-25 11:40:06 +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
ff5f93ac1e tag all netconf msg with username 2018-06-08 13:23:43 +02:00
Olof hagsand
5cabc11bfb * Added -U <user> command line to clixon_cli and clixon_netconf for NACM pseudo-user tests 2018-06-07 21:34:52 +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
d541c49c6f Plugin RPC callback interface have been unified between backend, netconf and restconf.
* Backend RPC register callback function (Netconf RPC or restconf operation POST) has been changed from: `backend_rpc_cb_register()` to `rpc_callback_register()`
    * Backend RPC callback signature has been changed from: `int cb(clicon_handle h, cxobj *xe, struct client_entry *ce, cbuf *cbret, void *arg)` has been changed to : `int cb(clicon_handle h, cxobj *xe, struct client_entry *ce, cbuf *cbret, void *arg)`
    * Frontend netconf and restconf plugins can register callbacks as well with same API as backends.
2018-04-07 18:20:33 +02:00
Olof hagsand
b9a54f07f3 Restructure and more generic plugin API for backend 2018-04-02 19:27:57 +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
bfce20c760 * Added Clixon Restconf library
* Builds and installs a new restconf library: libclixon_restconf.so and clixon_restconf.h
  * The restconf library can be included by a restconf plugin.
  * Example code in example/Makefile.in and example/restconf_lib.c
* Authorization
  * Example extended with authorization
  * Test added with http basic authorization (test/test_auth.sh)
  * Documentation in FAQ.md
* README.md extended with new yang, netconf, restconf, datastore, and auth sections.
2018-03-25 15:47:27 +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
38f0b446fa 2017->2018 2018-01-01 12:25:33 +01:00
Olof hagsand
79767045ad mem leaks 2017-12-31 12:05:21 +01:00
Olof Hagsand
4742fde1e9 XML creation and parse API changes 2017-12-09 14:14:40 +01:00
Olof hagsand
056b5c97dd experimental netconf yang spec 2017-12-08 19:37:09 +01:00
Olof hagsand
e169485985 Datastore cache introduced; Added yang to XML API 2017-12-02 14:49:49 +01:00
Olof hagsand
548ffd2da6 Disabled key-value datastore; Removed mandatory requirements for BACKEND, NETCONF, RESTCONF and CLI dirs 2017-11-19 18:04:23 +01:00
Olof hagsand
7a7bfc48a4 experimental xml hash for better performance 2017-09-18 20:53:49 +02:00