Skip to content

Commit

Permalink
Restconf returns error when RPC generates "ok" reply [#69]
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Jan 18, 2019
1 parent 66f80e9 commit 906b93c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
* <!DOCTYPE (ie DTD) is not supported.
### Corrected Bugs
* Restconf returns error when RPC generates "ok" reply [https://github.com/clicon/clixon/issues/69]
* xsd regular expression support for character classes [https://github.com/clicon/clixon/issues/68]
* added support for \c, \d, \w, \W, \s, \S.
* Removing newlines from XML data [https://github.com/clicon/clixon/issues/65]
Expand Down
8 changes: 7 additions & 1 deletion apps/netconf/netconf_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,12 +614,18 @@ netconf_application_rpc(clicon_handle h,
else /* Send to backend */
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
goto done;
/* Sanity check of outgoing XML */
/* Sanity check of outgoing XML
* For now, skip outgoing checks.
* (1) Does not handle <ok/> properly
* (2) Uncertain how validation errors should be logged/handled
*/
if (0)
if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL){
xoutput=xpath_first(*xret, "/");
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0)
goto done;

if ((ret = xml_yang_validate_all_top(xoutput, cbret)) < 0)
goto done;
if (ret == 0){
Expand Down
11 changes: 9 additions & 2 deletions apps/restconf/restconf_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ api_operations_post_output(clicon_handle h,
}
#endif
/* Validate output (in case handlers are wrong) */
if (youtput==NULL){
if (youtput==NULL){
/* Special case, no yang output
* RFC 7950 7.14.4
* If the RPC operation invocation succeeded and no output parameters
Expand Down Expand Up @@ -1428,10 +1428,17 @@ api_operations_post_output(clicon_handle h,
}
else{
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
if (0){
/* Sanity check of outgoing XML
* For now, skip outgoing checks.
* (1) Does not handle <ok/> properly
* (2) Uncertain how validation errors should be logged/handled
*/
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0)
goto done;
if ((ret = xml_yang_validate_all(xoutput, cbret)) < 0)
goto done;

if (ret == 1 &&
(ret = xml_yang_validate_add(xoutput, cbret)) < 0)
goto done;
Expand All @@ -1446,7 +1453,7 @@ api_operations_post_output(clicon_handle h,
goto done;
goto fail;
}
}
/* Clear namespace of parameters */
x = NULL;
while ((x = xml_child_each(xoutput, x, CX_ELMNT)) != NULL) {
Expand Down

0 comments on commit 906b93c

Please sign in to comment.