* C-code changes:
  - Replaced stream uri:s w constants
  - Replaced large debug print code with single clicon_log_xml
  - Restconf put and post handling refactored using new parse API
This commit is contained in:
Olof hagsand 2020-02-24 15:25:06 +01:00
parent de3853a126
commit a71c256898
27 changed files with 308 additions and 250 deletions

View file

@ -50,6 +50,7 @@ int xml2json(FILE *f, cxobj *x, int pretty);
int json_print(FILE *f, cxobj *x);
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty);
int json_parse_str(char *str, yang_stmt *yspec, cxobj **xt, cxobj **xret);
int json_parse_str2(char *str, enum yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);
int json_parse_file(int fd, yang_stmt *yspec, cxobj **xt, cxobj **xret);
#endif /* _CLIXON_JSON_H */

View file

@ -36,6 +36,26 @@
#ifndef _CLIXON_STREAM_H_
#define _CLIXON_STREAM_H_
/*
* 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
*/

View file

@ -86,9 +86,11 @@ enum cxobj_type {CX_ERROR=-1,
/* How to bind yang to XML top-level when parsing */
enum yang_bind{
YB_UNKNOWN=0, /* System derive binding: top if parent not exist or no spec, otherwise parent */
YB_NONE, /* Dont try to do Yang binding */
YB_PARENT, /* Get yang binding from parents yang */
YB_TOP, /* Get yang binding from top-level modules */
YB_RPC, /* Assume top-level xml is an netconf RPC message */
};
#define CX_ANY CX_ERROR /* catch all and error is same */
@ -117,8 +119,8 @@ typedef int (xml_applyfn_t)(cxobj *x, void *arg);
* Prototypes
*/
char *xml_type2str(enum cxobj_type type);
int xml_stats_get(uint64_t *nr);
size_t xml_size(cxobj *xt, size_t *szp);
int xml_stats_global(uint64_t *nr);
size_t xml_stats(cxobj *xt, uint64_t *nrp, size_t *szp);
char *xml_name(cxobj *xn);
int xml_name_set(cxobj *xn, char *name);
char *xml_prefix(cxobj *xn);