* New XML parsing API:
* `clixon_xml_parse_string()` * `clixon_xml_parse_file()` * New JSON parsing API, with same signature as XML parsing: * `clixon_json_parse_string()` * `clixon_xml_parse_file()` * XML YANG binding API have been rearranged as follows: * `xml_bind_yang_rpc()` * `xml_bind_yang_rpc_reply()` * `xml_bind_yang()` * `xml_bind_yang0()`
This commit is contained in:
parent
c4b0491754
commit
09a2e09848
54 changed files with 590 additions and 711 deletions
|
|
@ -93,9 +93,9 @@ extern char clicon_err_reason[ERR_STRLEN];
|
|||
*/
|
||||
int clicon_err_reset(void);
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int clicon_err_fn(const char *fn, const int line, int level, int err, char *format, ...) __attribute__ ((format (printf, 5, 6)));
|
||||
int clicon_err_fn(const char *fn, const int line, int category, int err, char *format, ...) __attribute__ ((format (printf, 5, 6)));
|
||||
#else
|
||||
int clicon_err_fn(const char *fn, const int line, int level, int err, char *format, ...);
|
||||
int clicon_err_fn(const char *fn, const int line, int category, int err, char *format, ...);
|
||||
#endif
|
||||
char *clicon_strerror(int err);
|
||||
void *clicon_err_save(void);
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ int xml2json_cbuf_vec(cbuf *cb, cxobj **vec, size_t veclen, int pretty);
|
|||
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);
|
||||
int clixon_json_parse_string(char *str, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);
|
||||
int clixon_json_parse_file(int fd, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xret);
|
||||
|
||||
#endif /* _CLIXON_JSON_H */
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ enum netconf_content{
|
|||
};
|
||||
typedef enum netconf_content netconf_content;
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
#define clixon_netconf_error(c, x, f, a) clixon_netconf_error_fn(__FUNCTION__, __LINE__, (c), (x), (f), (a))
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
|
|
@ -96,4 +101,7 @@ const char *netconf_content_int2str(netconf_content nr);
|
|||
int netconf_hello_server(clicon_handle h, cbuf *cb, uint32_t session_id);
|
||||
int netconf_hello_req(clicon_handle h, cbuf *cb);
|
||||
|
||||
int clicon_err_fn(const char *fn, const int line, int level, int err, char *format, ...);
|
||||
int clixon_netconf_error_fn(const char *fn, const int line, int category, cxobj *xerr, const char *fmt, const char *arg);
|
||||
|
||||
#endif /* _CLIXON_NETCONF_LIB_H */
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ int clicon_rpc_msg(clicon_handle h, struct clicon_msg *msg, cxobj **xret0,
|
|||
int *sock0);
|
||||
int clicon_rpc_netconf(clicon_handle h, char *xmlst, cxobj **xret, int *sp);
|
||||
int clicon_rpc_netconf_xml(clicon_handle h, cxobj *xml, cxobj **xret, int *sp);
|
||||
int clicon_rpc_generate_error(cxobj *xerr, const char *fmt, const char *arg);
|
||||
int clicon_rpc_get_config(clicon_handle h, char *username, char *db, char *xpath, cvec *nsc, cxobj **xret);
|
||||
int clicon_rpc_edit_config(clicon_handle h, char *db, enum operation_type op,
|
||||
char *xml);
|
||||
|
|
|
|||
|
|
@ -84,14 +84,47 @@ enum cxobj_type {CX_ERROR=-1,
|
|||
CX_ATTR,
|
||||
CX_BODY};
|
||||
|
||||
/* How to bind yang to XML top-level when parsing */
|
||||
/* How to bind yang to XML top-level when parsing
|
||||
* Assume an XML tree x with parent xp (or NULL) and a set of children c1,c2:
|
||||
*
|
||||
* (XML) xp
|
||||
* |
|
||||
* x
|
||||
* / \
|
||||
* c1 c2
|
||||
* (1) If you make a binding using YB_MODULE, you assume there is a loaded module "ym" with a top-level
|
||||
* data resource "y" that the XML node x can match to:
|
||||
*
|
||||
* (XML) xp ym (YANG)
|
||||
* | |
|
||||
* x - - - - - y
|
||||
* / \ / \
|
||||
* x1 x2 - - y1 y2
|
||||
* In that case, "y" is a container, list, leaf or leaf-list with same name as "x".
|
||||
*
|
||||
* (2) If you make a binding using YB_PARENT, you assume xp already have a YANG binding (eg to "yp"):
|
||||
*
|
||||
* (XML) xp - - - - yp (YANG)
|
||||
* |
|
||||
* x
|
||||
* so that the yang binding of "x" is a child of "yp":
|
||||
*
|
||||
* (XML) xp - - - - yp (YANG)
|
||||
* | |
|
||||
* x - - - - y
|
||||
* / \ / \
|
||||
* x1 x2 - - y1 y2
|
||||
* XXX: lacks support for incoming restconf rpc, see api_operations_post_input)
|
||||
*/
|
||||
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 */
|
||||
YB_MODULE=0, /* Search for matching yang binding among top-level symbols of Yang modules */
|
||||
YB_PARENT, /* Assume yang binding of existing parent and match its children by name */
|
||||
YB_NONE, /* Dont do Yang binding */
|
||||
#ifdef NYI
|
||||
YB_RPC, /* Assume top-level xml is an netconf RPC message (NYI) */
|
||||
#endif
|
||||
};
|
||||
typedef enum yang_bind yang_bind;
|
||||
|
||||
#define CX_ANY CX_ERROR /* catch all and error is same */
|
||||
|
||||
|
|
|
|||
|
|
@ -48,18 +48,15 @@ int xml_print(FILE *f, cxobj *xn);
|
|||
int clicon_xml2cbuf(cbuf *cb, cxobj *x, int level, int prettyprint, int32_t depth);
|
||||
int xmltree2cbuf(cbuf *cb, cxobj *x, int level);
|
||||
|
||||
int xml_parse_file(int fd, yang_stmt *yspec, cxobj **xt);
|
||||
int xml_parse_file2(int fd, enum yang_bind yb, yang_stmt *yspec, char *endtag, cxobj **xt, cxobj **xerr);
|
||||
int xml_parse_string2(const char *str, enum yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr);
|
||||
int xml_parse_string(const char *str, yang_stmt *yspec, cxobj **xt);
|
||||
int clixon_xml_parse_file(int fd, yang_bind yb, yang_stmt *yspec, char *endtag, cxobj **xt, cxobj **xerr);
|
||||
int clixon_xml_parse_string(const char *str, yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr);
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int xml_parse_va(cxobj **xt, yang_stmt *yspec, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
int clixon_xml_parse_va(yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr,
|
||||
const char *format, ...) __attribute__ ((format (printf, 5, 6)));
|
||||
#else
|
||||
int xml_parse_va(cxobj **xt, yang_stmt *yspec, const char *format, ...);
|
||||
#endif
|
||||
#ifdef NOTUSED
|
||||
int xml_body_int32(cxobj *xb, int32_t *val);
|
||||
int xml_body_uint32(cxobj *xb, uint32_t *val);
|
||||
int clixon_xml_parse_va(yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr,
|
||||
const char *format, ...);
|
||||
#endif
|
||||
|
||||
#endif /* _CLIXON_XML_IO_H_ */
|
||||
|
|
|
|||
|
|
@ -63,10 +63,8 @@ int xml_sanity(cxobj *x, void *arg);
|
|||
int xml_non_config_data(cxobj *xt, void *arg);
|
||||
int xml_bind_yang_rpc(cxobj *xrpc, yang_stmt *yspec, cxobj **xerr);
|
||||
int xml_bind_yang_rpc_reply(cxobj *xrpc, char *name, yang_stmt *yspec, cxobj **xerr);
|
||||
int xml_bind_yang0(cxobj *xt, yang_stmt *yspec, cxobj **xerr);
|
||||
int xml_bind_yang0_parent(cxobj *xt, cxobj **xerr);
|
||||
int xml_bind_yang(cxobj *xt, yang_stmt *yspec, cxobj **xerr);
|
||||
int xml_bind_yang_parent(cxobj *xt, cxobj **xerr);
|
||||
int xml_bind_yang0(cxobj *xt, yang_bind yb, yang_stmt *yspec, cxobj **xerr);
|
||||
int xml_bind_yang(cxobj *xt, yang_bind yb, yang_stmt *yspec, cxobj **xerr);
|
||||
|
||||
int xml2xpath(cxobj *x, char **xpath);
|
||||
int assign_namespaces(cxobj *x0, cxobj *x1, cxobj *x1p);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue