* Error-type changed from protocol to application for data-not-unique netconf/restconf errors
* Added new revision of main example yang: `clixon-example@2020-12-01.yang` * Fixed [YANG: key statement in rpc/notification list #148](https://github.com/clicon/clixon/issues/148) * Do not check uniqueness among lists without keys
This commit is contained in:
parent
1cd6d37fa1
commit
e46f6f4a36
11 changed files with 275 additions and 26 deletions
|
|
@ -654,11 +654,15 @@ check_insert_duplicate(char **vec,
|
|||
* @param[in] xt The parent of x
|
||||
* @param[in] y Its yang spec (Y_LIST)
|
||||
* @param[in] yu A yang unique spec (Y_UNIQUE) for unique keyword or (Y_LIST) for list keys
|
||||
* @param[out] xret Error XML tree. Free with xml_free after use
|
||||
* @param[out] xret Error XML tree. Free with xml_free after use
|
||||
* @retval 1 Validation OK
|
||||
* @retval 0 Validation failed (cbret set)
|
||||
* @retval -1 Error
|
||||
* @note It would be possible to cache the vector built below
|
||||
* All key leafs MUST be present for all list entries.
|
||||
* The combined values of all the leafs specified in the key are used to
|
||||
* uniquely identify a list entry. All key leafs MUST be given values
|
||||
* when a list entry is created.
|
||||
*/
|
||||
static int
|
||||
check_unique_list(cxobj *x,
|
||||
|
|
@ -666,7 +670,6 @@ check_unique_list(cxobj *x,
|
|||
yang_stmt *y,
|
||||
yang_stmt *yu,
|
||||
cxobj **xret)
|
||||
|
||||
{
|
||||
int retval = -1;
|
||||
cvec *cvk; /* unique vector */
|
||||
|
|
@ -686,7 +689,11 @@ check_unique_list(cxobj *x,
|
|||
sorted = (yang_keyword_get(yu) == Y_LIST &&
|
||||
yang_find(y, Y_ORDERED_BY, "user") == NULL);
|
||||
cvk = yang_cvec_get(yu);
|
||||
vlen = cvec_len(cvk); /* nr of unique elements to check */
|
||||
/* nr of unique elements to check */
|
||||
if ((vlen = cvec_len(cvk)) == 0){
|
||||
/* No keys: no checks necessary */
|
||||
goto ok;
|
||||
}
|
||||
if ((vec = calloc(vlen*xml_child_nr(xt), sizeof(char*))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "calloc");
|
||||
goto done;
|
||||
|
|
@ -718,6 +725,7 @@ check_unique_list(cxobj *x,
|
|||
x = xml_child_each(xt, x, CX_ELMNT);
|
||||
i++;
|
||||
} while (x && y == xml_spec(x)); /* stop if list ends, others may follow */
|
||||
ok:
|
||||
/* It would be possible to cache vec here as an optimization */
|
||||
retval = 1;
|
||||
done:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue