Feature Request: Support RFC 6022 (NETCONF Monitoring)

* Added capabilities and schema state, and get-schema rpc
* New `clixon-config@2022-11-01.yang` revision
  * Added option:
    * `CLICON_NETCONF_MONITORING`
    * `CLICON_NETCONF_MONITORING_LOCATION`
This commit is contained in:
Olof hagsand 2022-11-22 13:56:20 +01:00
parent 8ebab16c4c
commit c94e9dad67
20 changed files with 1988 additions and 64 deletions

View file

@ -84,6 +84,7 @@ extern "C" {
#include <clixon/clixon_xml_sort.h>
#include <clixon/clixon_yang_parse_lib.h>
#include <clixon/clixon_yang_module.h>
#include <clixon/clixon_netconf_monitoring.h>
#include <clixon/clixon_stream.h>
#include <clixon/clixon_proto.h>
#include <clixon/clixon_netconf_lib.h>

View file

@ -68,7 +68,29 @@
* operations, <error-info> content, and the <action> element.
*/
#define YANG_XML_NAMESPACE "urn:ietf:params:xml:ns:yang:1"
/* RFC 6022 YANG Module for NETCONF Monitoring
*/
#define NETCONF_MONITORING_NAMESPACE "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"
/* Default STREAM namespace (see rfc5277 3.1)
* From RFC8040:
* The structure of the event data is based on the <notification>
* element definition in Section 4 of [RFC5277]. It MUST conform to the
* schema for the <notification> element in Section 4 of [RFC5277],
* using the XML namespace as defined in the XSD as follows:
* urn:ietf:params:xml:ns:netconf:notification:1.0
* It is used everywhere in yangmodels, but not in openconfig
*/
#define NETCONF_NOTIFICATION_NAMESPACE "urn:ietf:params:xml:ns:netconf:notification:1.0"
#define NETCONF_NOTIFICATION_CAPABILITY "urn:ietf:params:netconf:capability:notification:1.0"
/*
* Then there is also this namespace that is only used in RFC5277 seems to be for "netconf"
* events. The usage seems wrong here,...
*/
#define EVENT_RFC5277_NAMESPACE "urn:ietf:params:xml:ns:netmod:notification"
/*
* Types
*/
@ -152,6 +174,7 @@ int netconf_operation_failed(cbuf *cb, char *type, char *message);
int netconf_operation_failed_xml(cxobj **xret, char *type, char *message);
int netconf_malformed_message(cbuf *cb, char *message);
int netconf_malformed_message_xml(cxobj **xret, char *message);
int netconf_data_not_unique(cbuf *cb, cxobj *x, cvec *cvk);
int netconf_data_not_unique_xml(cxobj **xret, cxobj *x, cvec *cvk);
int netconf_minmax_elements_xml(cxobj **xret, cxobj *xp, char *name, int max);
int netconf_trymerge(cxobj *x, yang_stmt *yspec, cxobj **xret);
@ -161,6 +184,7 @@ char *netconf_db_find(cxobj *xn, char *name);
int netconf_err2cb(cxobj *xerr, cbuf *cberr);
const netconf_content netconf_content_str2int(char *str);
const char *netconf_content_int2str(netconf_content nr);
int netconf_capabilites(clicon_handle h, cbuf *cb);
int netconf_hello_server(clicon_handle h, cbuf *cb, uint32_t session_id);
int netconf_hello_req(clicon_handle h, cbuf *cb);
int clixon_netconf_error_fn(const char *fn, const int line, cxobj *xerr, const char *fmt, const char *arg);

View file

@ -0,0 +1,46 @@
/*
*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2009-2019 Olof Hagsand
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
This file is part of CLIXON.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 3 or later (the "GPL"),
in which case the provisions of the GPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2,
indicate your decision by deleting the provisions above and replace them with
the notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
***** END LICENSE BLOCK *****
* RFC 6022 YANG Module for NETCONF Monitoring
*/
#ifndef _CLIXON_NETCONF_MONITORING_H_
#define _CLIXON_NETCONF_MONITORING_H_
/*
* Prototypes
*/
int netconf_monitoring_state_get(clicon_handle h, yang_stmt *yspec, char *xpath, cvec *nsc, int brief, cxobj **xret);
#endif /* _CLIXON_NETCONF_MONITORING_H_ */

View file

@ -41,22 +41,6 @@
/*
* Constants
*/
/* Default STREAM namespace (see rfc5277 3.1)
* From RFC8040:
* The structure of the event data is based on the <notification>
* element definition in Section 4 of [RFC5277]. It MUST conform to the
* schema for the <notification> element in Section 4 of [RFC5277],
* using the XML namespace as defined in the XSD as follows:
* urn:ietf:params:xml:ns:netconf:notification:1.0
* It is used everywhere in yangmodels, but not in openconfig
*/
#define NOTIFICATION_RFC5277_NAMESPACE "urn:ietf:params:xml:ns:netconf:notification:1.0"
/*
* Then there is also this namespace that is only used in RFC5277 seems to be for "netconf"
* events. The usage seems wrong here,...
*/
#define EVENT_RFC5277_NAMESPACE "urn:ietf:params:xml:ns:netmod:notification"
/*
* Types