Yang choice functionality improved and stricter validation for CLI generation, mandatory flags, etc.

This commit is contained in:
Olof hagsand 2019-01-04 11:37:26 +01:00
parent 7a8f242a09
commit 058a14579f
16 changed files with 412 additions and 86 deletions

View file

@ -768,6 +768,7 @@ yang2cli_stmt(clicon_handle h,
if (yang2cli_leaf(h, ys, cbuf, gt, level, 1) < 0)
goto done;
break;
case Y_CASE:
case Y_SUBMODULE:
case Y_MODULE:
for (i=0; i<ys->ys_len; i++)

View file

@ -80,7 +80,7 @@
* @param[in] cb Packet buffer
*/
static int
process_incoming_packet(clicon_handle h,
netconf_input_packet(clicon_handle h,
cbuf *cb)
{
int retval = -1;
@ -94,6 +94,8 @@ process_incoming_packet(clicon_handle h,
cxobj *xc;
yang_spec *yspec;
int ret;
cxobj *xa;
cxobj *xa2;
clicon_debug(1, "RECV");
clicon_debug(2, "%s: RCV: \"%s\"", __FUNCTION__, cbuf_get(cb));
@ -110,7 +112,7 @@ process_incoming_packet(clicon_handle h,
/* Parse incoming XML message */
if (xml_parse_string(str, yspec, &xreq) < 0){
free(str0);
if (netconf_operation_failed(cbret, "rpc", "internal error")< 0)
if (netconf_operation_failed(cbret, "rpc", clicon_err_reason)< 0)
goto done;
netconf_output_encap(1, cbret, "rpc-error");
goto done;
@ -143,8 +145,13 @@ process_incoming_packet(clicon_handle h,
goto done;
}
else{ /* there is a return message in xret */
cxobj *xa, *xa2;
assert(xret);
if (xret == NULL){
if (netconf_operation_failed(cbret, "rpc", "Internal error: no xml return")< 0)
goto done;
netconf_output_encap(1, cbret, "rpc-error");
goto done;
}
if ((xc = xml_child_i(xret,0))!=NULL){
xa=NULL;
/* Copy message-id attribute from incoming to reply.
@ -228,7 +235,7 @@ netconf_input_cb(int s,
/* OK, we have an xml string from a client */
/* Remove trailer */
*(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0';
if (process_incoming_packet(h, cb) < 0)
if (netconf_input_packet(h, cb) < 0)
; //goto done; // ignore errors
if (cc_closed)
break;

View file

@ -314,7 +314,6 @@ netconf_edit_config(clicon_handle h,
enum operation_type operation = OP_MERGE;
enum test_option testopt = TEST_THEN_SET;/* only supports this */
enum error_option erropt = STOP_ON_ERROR; /* only supports this */
cxobj *xc; /* config */
cxobj *x;
cxobj *xfilter;
char *ftype = NULL;
@ -366,18 +365,8 @@ netconf_edit_config(clicon_handle h,
"</rpc-error></rpc-reply>");
goto ok;
}
/* operation is OP_REPLACE, OP_MERGE, or OP_NONE pass all to backend */
if ((xc = xpath_first(xn, "config")) != NULL){
#if 0
/* application-specific code registers 'config' */
if ((ret = netconf_plugin_callbacks(h, xc, xret)) < 0){
goto ok;
}
#endif
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
goto done;
}
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
goto done;
ok:
retval = 0;
done: