loosen yang check of keys in lists to not do it in rpc declarations
This commit is contained in:
parent
8131bd1834
commit
0fd71ec372
3 changed files with 39 additions and 6 deletions
|
|
@ -2,7 +2,8 @@
|
|||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2009-2020 Olof Hagsand
|
||||
Copyright (C) 2009-2019 Olof Hagsand
|
||||
Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
|
|
@ -223,6 +224,7 @@ yang_stmt *yang_find_schemanode(yang_stmt *yn, char *argument);
|
|||
char *yang_find_myprefix(yang_stmt *ys);
|
||||
char *yang_find_mynamespace(yang_stmt *ys);
|
||||
int yang_find_prefix_by_namespace(yang_stmt *ys, char *namespace, char **prefix);
|
||||
yang_stmt *yang_myroot(yang_stmt *ys);
|
||||
yang_stmt *yang_choice(yang_stmt *y);
|
||||
int yang_order(yang_stmt *y);
|
||||
int yang_print(FILE *f, yang_stmt *yn);
|
||||
|
|
|
|||
|
|
@ -920,6 +920,31 @@ yang_find_prefix_by_namespace(yang_stmt *ys,
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*! Return topmost yang root node directly under module/submodule
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
* @retval ytop Topmost yang node (can be ys itself)
|
||||
* @retval NULL ys is spec, module, NULL etc with no reasonable rootnode
|
||||
*/
|
||||
yang_stmt *
|
||||
yang_myroot(yang_stmt *ys)
|
||||
{
|
||||
yang_stmt *yp;
|
||||
enum rfc_6020 kw;
|
||||
|
||||
kw = yang_keyword_get(ys);
|
||||
if (ys==NULL || kw==Y_SPEC || kw == Y_MODULE || kw == Y_SUBMODULE)
|
||||
return NULL;
|
||||
yp = yang_parent_get(ys);
|
||||
while((yp = yang_parent_get(ys)) != NULL) {
|
||||
kw = yang_keyword_get(yp);
|
||||
if (kw == Y_MODULE || kw == Y_SUBMODULE)
|
||||
return ys;
|
||||
ys = yp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*! If a given yang stmt has a choice/case as parent, return the choice statement
|
||||
*/
|
||||
yang_stmt *
|
||||
|
|
@ -2386,7 +2411,7 @@ yang_config(yang_stmt *ys)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*! Return config state of this node taking parent into account
|
||||
/*! Return config state of this node taking parents/anceestors into account
|
||||
*
|
||||
* config statement is default true.
|
||||
* @param[in] ys Yang statement
|
||||
|
|
|
|||
|
|
@ -923,10 +923,16 @@ ys_list_check(clicon_handle h,
|
|||
yang_stmt *ymod;
|
||||
yang_stmt *yc = NULL;
|
||||
enum rfc_6020 keyw;
|
||||
yang_stmt *yroot;
|
||||
|
||||
/* This node is state, not config */
|
||||
if (yang_config_ancestor(ys) == 0)
|
||||
goto ok;
|
||||
/* Find root, examine if this node is part of a rpc declaration */
|
||||
if ((yroot = yang_myroot(ys)) != NULL &&
|
||||
yang_keyword_get(yroot) == Y_RPC)
|
||||
goto ok;
|
||||
|
||||
/* This node has config false */
|
||||
if (yang_config(ys) == 0)
|
||||
return 0;
|
||||
keyw = yang_keyword_get(ys);
|
||||
/* Check if list and if keys do not exist */
|
||||
if (keyw == Y_LIST &&
|
||||
|
|
@ -963,7 +969,7 @@ ys_list_check(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue