Yang "unique" feature supported according to RFC 7950 7.8.3

This commit is contained in:
Olof hagsand 2019-05-03 14:03:10 +02:00
parent a5e955c95f
commit 2fc37d2470
7 changed files with 455 additions and 3 deletions

View file

@ -1213,7 +1213,6 @@ yang_print_cbuf(cbuf *cb,
return 0;
}
/*! Populate yang leafs after parsing. Create cv and fill it in.
*
* Populate leaf in 2nd round of yang parsing, now that context is complete:
@ -1308,7 +1307,8 @@ ys_populate_list(yang_stmt *ys,
if ((ykey = yang_find(ys, Y_KEY, NULL)) == NULL)
return 0;
cvec_free(ys->ys_cvec);
if (ys->ys_cvec)
cvec_free(ys->ys_cvec);
if ((ys->ys_cvec = yang_arg2cvec(ykey, " ")) == NULL)
return -1;
return 0;
@ -1681,6 +1681,18 @@ ys_populate_feature(clicon_handle h,
return retval;
}
/*! Populate the unique statement with a cvec
*/
static int
ys_populate_unique(yang_stmt *ys)
{
if (ys->ys_cvec)
cvec_free(ys->ys_cvec);
if ((ys->ys_cvec = yang_arg2cvec(ys, " ")) == NULL)
return -1;
return 0;
}
/*! Populate unknown node with extension
*/
static int
@ -1770,6 +1782,10 @@ ys_populate(yang_stmt *ys,
if (ys_populate_identity(ys, NULL) < 0)
goto done;
break;
case Y_UNIQUE:
if (ys_populate_unique(ys) < 0)
goto done;
break;
case Y_UNKNOWN:
if (ys_populate_unknown(ys) < 0)
goto done;