add yang-spec as arg to decode clicon msg
This commit is contained in:
parent
b443471e7b
commit
11479f7ec3
7 changed files with 23 additions and 20 deletions
|
|
@ -160,10 +160,12 @@ clicon_msg_encode(char *format, ...)
|
|||
|
||||
/*! Decode a clicon netconf message
|
||||
* @param[in] msg CLICON msg
|
||||
* @param[in] yspec Yang specification, (can be NULL)
|
||||
* @param[out] xml XML parse tree
|
||||
*/
|
||||
int
|
||||
clicon_msg_decode(struct clicon_msg *msg,
|
||||
yang_spec *yspec,
|
||||
cxobj **xml)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -172,7 +174,7 @@ clicon_msg_decode(struct clicon_msg *msg,
|
|||
/* body */
|
||||
xmlstr = msg->op_body;
|
||||
clicon_debug(1, "%s %s", __FUNCTION__, xmlstr);
|
||||
if (xml_parse_string(xmlstr, NULL, xml) < 0)
|
||||
if (xml_parse_string(xmlstr, yspec, xml) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -1623,7 +1623,7 @@ xml_spec_populate_rpc(clicon_handle h,
|
|||
yang_stmt *ymod=NULL; /* yang module */
|
||||
yang_stmt *yi = NULL; /* input */
|
||||
cxobj *x;
|
||||
int i;
|
||||
// int i;
|
||||
|
||||
if ((strcmp(xml_name(xrpc), "rpc"))!=0){
|
||||
clicon_err(OE_UNIX, EINVAL, "RPC expected");
|
||||
|
|
@ -1635,15 +1635,12 @@ xml_spec_populate_rpc(clicon_handle h,
|
|||
goto done;
|
||||
if (ymod != NULL)
|
||||
y = yang_find((yang_node*)ymod, Y_RPC, xml_name(x));
|
||||
/* Loose semantics: loop through all modules to find the node
|
||||
/* Non-strict semantics: loop through all modules to find the node
|
||||
*/
|
||||
if (y == NULL &&
|
||||
!clicon_option_bool(h, "CLICON_XML_NS_STRICT")){
|
||||
for (i=0; i<yspec->yp_len; i++){
|
||||
ymod = yspec->yp_stmt[i];
|
||||
if ((y = yang_find((yang_node*)ymod, Y_RPC, xml_name(x))) != NULL)
|
||||
break;
|
||||
}
|
||||
if (xml_yang_find_non_strict(x, yspec, &y) < 0) /* find rpc */
|
||||
goto done;
|
||||
}
|
||||
if (y){
|
||||
xml_spec_set(x, y);
|
||||
|
|
@ -1696,9 +1693,8 @@ xml_spec_populate(cxobj *x,
|
|||
if (ys_module_by_xml(yspec, x, &ymod) < 0)
|
||||
goto done;
|
||||
if (ymod != NULL)
|
||||
y = yang_find_datanode((yang_node*)ymod, name);
|
||||
y = yang_find_schemanode((yang_node*)ymod, name);
|
||||
/* Non-strict semantics: loop through all modules to find the node
|
||||
* XXX clicon_option_bool(h, "CLICON_XML_NS_STRICT")
|
||||
*/
|
||||
if (y == NULL && !_CLICON_XML_NS_STRICT){
|
||||
if (xml_yang_find_non_strict(x, yspec, &y) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue