* Netconf message-id attribute changed from optional to mandatory
* Made NETCONF message handling more strict according to RFC 6241 * Set `CLICON_NETCONF_MESSAGE_ID_OPTIONAL` to true to accept omission of message-id attribute * Fixed: [need make sure message-id exist in rpc validate #240](https://github.com/clicon/clixon/issues/240)
This commit is contained in:
parent
96c9296056
commit
85e2945ec9
22 changed files with 196 additions and 89 deletions
|
|
@ -747,11 +747,6 @@ main(int argc,
|
|||
clicon_configfile(h));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Treat unknown XML as anydata */
|
||||
if (clicon_option_bool(h, "CLICON_YANG_UNKNOWN_ANYDATA") == 1)
|
||||
xml_bind_yang_unknown_anydata(1);
|
||||
|
||||
/* Publish stream on pubsub channels.
|
||||
* CLICON_STREAM_PUB should be set to URL to where streams are published
|
||||
* and configure should be run with --enable-publish
|
||||
|
|
|
|||
|
|
@ -635,11 +635,6 @@ main(int argc,
|
|||
goto done;
|
||||
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
|
||||
xml_nsctx_namespace_netconf_default(h);
|
||||
|
||||
/* Treat unknwon XML as anydata */
|
||||
if (clicon_option_bool(h, "CLICON_YANG_UNKNOWN_ANYDATA") == 1)
|
||||
xml_bind_yang_unknown_anydata(1);
|
||||
|
||||
/* Create top-level and store as option */
|
||||
if ((yspec = yspec_new()) == NULL)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -495,8 +495,8 @@ cli_show_config1(clicon_handle h,
|
|||
cli_xml2cli(xc, prefix, gt, cligen_output); /* cli syntax */
|
||||
break;
|
||||
case FORMAT_NETCONF:
|
||||
cligen_output(stdout, "<rpc xmlns=\"%s\"><edit-config><target><candidate/></target><config>\n",
|
||||
NETCONF_BASE_NAMESPACE);
|
||||
cligen_output(stdout, "<rpc xmlns=\"%s\" %s><edit-config><target><candidate/></target><config>\n",
|
||||
NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR);
|
||||
xc = NULL; /* Dont print xt itself */
|
||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
|
||||
cli_xml2file(xc, 2, 1, cligen_output);
|
||||
|
|
|
|||
|
|
@ -375,10 +375,6 @@ main(int argc,
|
|||
if ((yspec = yspec_new()) == NULL)
|
||||
goto done;
|
||||
clicon_dbspec_yang_set(h, yspec);
|
||||
/* Treat unknown XML as anydata */
|
||||
if (clicon_option_bool(h, "CLICON_YANG_UNKNOWN_ANYDATA") == 1)
|
||||
xml_bind_yang_unknown_anydata(1);
|
||||
|
||||
/* Initialize plugin module by creating a handle holding plugin and callback lists */
|
||||
if (clixon_plugin_module_init(h) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -1687,10 +1687,6 @@ restconf_clixon_init(clicon_handle h,
|
|||
if ((yspec = yspec_new()) == NULL)
|
||||
goto done;
|
||||
clicon_dbspec_yang_set(h, yspec);
|
||||
/* Treat unknown XML as anydata */
|
||||
if (clicon_option_bool(h, "CLICON_YANG_UNKNOWN_ANYDATA") == 1)
|
||||
xml_bind_yang_unknown_anydata(1);
|
||||
|
||||
/* Load restconf plugins before yangs are loaded (eg extension callbacks) */
|
||||
if ((dir = clicon_restconf_dir(h)) != NULL)
|
||||
if (clixon_plugins_load(h, CLIXON_PLUGIN_INIT, dir, NULL) < 0)
|
||||
|
|
|
|||
|
|
@ -513,11 +513,12 @@ api_data_write(clicon_handle h,
|
|||
/* Create text buffer for transfer to backend */
|
||||
if ((cbx = cbuf_new()) == NULL)
|
||||
goto done;
|
||||
cprintf(cbx, "<rpc xmlns=\"%s\" username=\"%s\" xmlns:%s=\"%s\">",
|
||||
cprintf(cbx, "<rpc xmlns=\"%s\" username=\"%s\" xmlns:%s=\"%s\" %s>",
|
||||
NETCONF_BASE_NAMESPACE,
|
||||
username?username:"",
|
||||
NETCONF_BASE_PREFIX,
|
||||
NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */
|
||||
NETCONF_BASE_NAMESPACE, /* bind nc to netconf namespace */
|
||||
NETCONF_MESSAGE_ID_ATTR);
|
||||
cprintf(cbx, "<edit-config");
|
||||
/* RFC8040 Sec 1.4:
|
||||
* If this is a "data" request and the NETCONF server supports :startup,
|
||||
|
|
@ -753,11 +754,12 @@ api_data_delete(clicon_handle h,
|
|||
/* For internal XML protocol: add username attribute for access control
|
||||
*/
|
||||
username = clicon_username_get(h);
|
||||
cprintf(cbx, "<rpc xmlns=\"%s\" username=\"%s\" xmlns:%s=\"%s\">",
|
||||
cprintf(cbx, "<rpc xmlns=\"%s\" username=\"%s\" xmlns:%s=\"%s\" %s>",
|
||||
NETCONF_BASE_NAMESPACE,
|
||||
username?username:"",
|
||||
NETCONF_BASE_PREFIX,
|
||||
NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */
|
||||
NETCONF_BASE_NAMESPACE,
|
||||
NETCONF_MESSAGE_ID_ATTR); /* bind nc to netconf namespace */
|
||||
|
||||
cprintf(cbx, "<edit-config");
|
||||
/* RFC8040 Sec 1.4:
|
||||
|
|
|
|||
|
|
@ -336,11 +336,12 @@ api_data_post(clicon_handle h,
|
|||
/* For internal XML protocol: add username attribute for access control
|
||||
*/
|
||||
username = clicon_username_get(h);
|
||||
cprintf(cbx, "<rpc xmlns=\"%s\" username=\"%s\" xmlns:%s=\"%s\">",
|
||||
cprintf(cbx, "<rpc xmlns=\"%s\" username=\"%s\" xmlns:%s=\"%s\" %s>",
|
||||
NETCONF_BASE_NAMESPACE,
|
||||
username?username:"",
|
||||
NETCONF_BASE_PREFIX,
|
||||
NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */
|
||||
NETCONF_BASE_NAMESPACE,
|
||||
NETCONF_MESSAGE_ID_ATTR); /* bind nc to netconf namespace */
|
||||
|
||||
cprintf(cbx, "<edit-config");
|
||||
/* RFC8040 Sec 1.4:
|
||||
|
|
@ -755,13 +756,13 @@ api_operations_post(clicon_handle h,
|
|||
* <rpc username="foo"><myfn xmlns="uri"/>
|
||||
*/
|
||||
if ((username = clicon_username_get(h)) != NULL){
|
||||
if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, "<rpc xmlns=\"%s\" username=\"%s\"/>",
|
||||
NETCONF_BASE_NAMESPACE, username) < 0)
|
||||
if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, "<rpc xmlns=\"%s\" username=\"%s\" %s/>",
|
||||
NETCONF_BASE_NAMESPACE, username, NETCONF_MESSAGE_ID_ATTR) < 0)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, "<rpc xmlns=\"%s\"/>",
|
||||
NETCONF_BASE_NAMESPACE) < 0)
|
||||
if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, "<rpc xmlns=\"%s\" %s/>",
|
||||
NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR) < 0)
|
||||
goto done;
|
||||
if (xml_rootchild(xtop, 0, &xtop) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -269,8 +269,8 @@ restconf_stream(clicon_handle h,
|
|||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "<rpc xmlns=\"%s\"><create-subscription xmlns=\"%s\"><stream>%s</stream>",
|
||||
NETCONF_BASE_NAMESPACE, EVENT_RFC5277_NAMESPACE, name);
|
||||
cprintf(cb, "<rpc xmlns=\"%s\" %s><create-subscription xmlns=\"%s\"><stream>%s</stream>",
|
||||
NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR, EVENT_RFC5277_NAMESPACE, name);
|
||||
/* Print all fields */
|
||||
for (i=0; i<cvec_len(qvec); i++){
|
||||
cv = cvec_i(qvec, i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue