From 77e56868d403f5c076c89c95c538f968cc1ed33e Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 23 Oct 2018 20:43:59 +0200 Subject: [PATCH] Load netconf notification and add create-subscription to yang. --- apps/netconf/netconf_main.c | 4 +- lib/clixon/clixon_xml_sort.h | 6 +-- lib/src/clixon_netconf_lib.c | 2 + .../ietf-netconf-notification@2008-07-01.yang | 43 +++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index 6855740e..6765a7eb 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -91,16 +91,18 @@ process_incoming_packet(clicon_handle h, cxobj *xret = NULL; /* Return (out) */ cxobj *xrpc; cxobj *xc; + yang_spec *yspec; clicon_debug(1, "RECV"); clicon_debug(2, "%s: RCV: \"%s\"", __FUNCTION__, cbuf_get(cb)); + yspec = clicon_dbspec_yang(h); if ((str0 = strdup(cbuf_get(cb))) == NULL){ clicon_log(LOG_ERR, "%s: strdup: %s", __FUNCTION__, strerror(errno)); return -1; } str = str0; /* Parse incoming XML message */ - if (xml_parse_string(str, NULL, &xreq) < 0){ + if (xml_parse_string(str, yspec, &xreq) < 0){ if ((cbret = cbuf_new()) == NULL){ if (netconf_operation_failed(cbret, "rpc", "internal error")< 0) goto done; diff --git a/lib/clixon/clixon_xml_sort.h b/lib/clixon/clixon_xml_sort.h index 0a7ee662..620456a0 100644 --- a/lib/clixon/clixon_xml_sort.h +++ b/lib/clixon/clixon_xml_sort.h @@ -44,9 +44,9 @@ extern int xml_child_sort; /* * Prototypes */ -int xml_child_spec(char *name, cxobj *xp, yang_spec *yspec, yang_stmt **yp); -int xml_cmp(const void* arg1, const void* arg2); -int xml_sort(cxobj *x0, void *arg); +int xml_child_spec(char *name, cxobj *xp, yang_spec *yspec, yang_stmt **yp); +int xml_cmp(const void* arg1, const void* arg2); +int xml_sort(cxobj *x0, void *arg); cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval); int xml_insert_pos(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval, int low, diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index 10784090..d832ffc9 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -990,6 +990,8 @@ netconf_module_load(clicon_handle h) /* Load yang spec */ if (yang_spec_parse_module(h, "ietf-netconf", CLIXON_DATADIR, NULL, yspec, NULL)< 0) goto done; + if (yang_spec_parse_module(h, "ietf-netconf-notification", CLIXON_DATADIR, NULL, yspec, NULL)< 0) + goto done; if ((xc = clicon_conf_xml(h)) == NULL){ clicon_err(OE_CFG, ENOENT, "Clicon configuration not loaded"); goto done; diff --git a/yang/ietf-netconf-notification@2008-07-01.yang b/yang/ietf-netconf-notification@2008-07-01.yang index 0b78ac3b..978cdd4b 100644 --- a/yang/ietf-netconf-notification@2008-07-01.yang +++ b/yang/ietf-netconf-notification@2008-07-01.yang @@ -91,4 +91,47 @@ module ietf-netconf-notification { } } } + rpc create-subscription { + description + "The command to create a notification subscription. It + takes as argument the name of the notification stream + and filter. Both of those options + limit the content of the subscription. In addition, + there are two time-related parameters, startTime and + stopTime, which can be used to select the time interval + of interest to the notification replay feature."; + reference "RFC 5277, Section 2.1"; + input { + leaf stream{ + type string; + default "NETCONF"; + description "An optional parameter, , that indicates which + stream of events is of interest. If not present, events in the + default NETCONF stream will be sent."; + } + leaf filter{ + type string; + description "An optional parameter, , that indicates which + subset of all possible events is of interest. The format of this + parameter is the same as that of the filter parameter in the + NETCONF protocol operations. If not present, all events not + precluded by other parameters will be sent. See section 3.6 + for more information on filters"; + } + leaf startTime { + type date-and-time; + description "used to trigger the replay feature + and indicate that the replay should start at the time + specified. If is not present, this is not a replay + subscription."; + } + leaf stopTime { + type date-and-time; + description "used with the optional + replay feature to indicate the newest notifications of + interest. If is not present, the notifications will + continue until the subscription is terminated."; + } + } + } }