Added new API function `xpath_parse()` to split parsing and xml evaluation.
This commit is contained in:
Olof hagsand 2019-07-08 14:47:18 +02:00
commit 1f8c759f3d
64 changed files with 2282 additions and 1350 deletions

View file

@ -343,11 +343,12 @@ validate_identityref(cxobj *xt,
{
int retval = -1;
char *node;
char *node = NULL;
yang_stmt *ybaseref; /* This is the type's base reference */
yang_stmt *ybaseid;
char *prefix = NULL;
cbuf *cb = NULL;
cbuf *cb2 = NULL;
/* Get idref value. Then see if this value is derived from ytype.
* Always add default prefix because derived identifiers are stored with
@ -380,10 +381,13 @@ validate_identityref(cxobj *xt,
* The derived node list is a cvec computed XXX
*/
if (cvec_find(yang_cvec_get(ybaseid), node) == NULL){
cbuf_reset(cb);
cprintf(cb, "Identityref validation failed, %s not derived from %s",
if ((cb2 = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
cprintf(cb2, "Identityref validation failed, %s not derived from %s",
node, yang_argument_get(ybaseid));
if (netconf_operation_failed_xml(xret, "application", cbuf_get(cb)) < 0)
if (netconf_operation_failed_xml(xret, "application", cbuf_get(cb2)) < 0)
goto done;
goto fail;
}
@ -391,6 +395,8 @@ validate_identityref(cxobj *xt,
done:
if (cb)
cbuf_free(cb);
if (cb2)
cbuf_free(cb2);
return retval;
fail:
retval = 0;
@ -1221,19 +1227,20 @@ xml_yang_validate_all(clicon_handle h,
/* Special case if leaf is leafref, then first check against
current xml tree
*/
if ((yc = yang_find(ys, Y_TYPE, NULL)) != NULL){
if (strcmp(yc->ys_argument, "leafref") == 0){
if ((ret = validate_leafref(xt, yc, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
}
else if (strcmp(yc->ys_argument, "identityref") == 0){
if ((ret = validate_identityref(xt, ys, yc, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
/* Get base type yc */
if (yang_type_get(ys, NULL, &yc, NULL, NULL, NULL, NULL, NULL) < 0)
goto done;
if (strcmp(yang_argument_get(yc), "leafref") == 0){
if ((ret = validate_leafref(xt, yc, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
}
else if (strcmp(yang_argument_get(yc), "identityref") == 0){
if ((ret = validate_identityref(xt, ys, yc, xret)) < 0)
goto done;
if (ret == 0)
goto fail;
}
break;
default:
@ -2557,7 +2564,7 @@ api_path2xml_vec(char **vec,
else{
if ((valvec = clicon_strsep(restval, ",", &nvalvec)) == NULL)
goto done;
if (nvalvec != cvec_len(cvk)){
if ((nvalvec != cvec_len(cvk)) && strict){
clicon_err(OE_XML, EINVAL, "List key %s length mismatch", name);
goto fail;
}