C-API changes: Replace yn_each with yn_iter, add keyw argument to yang_stats()

This commit is contained in:
Olof hagsand 2024-06-17 12:51:39 +02:00
parent 3e07a1d279
commit 4b9ee6740b
23 changed files with 358 additions and 248 deletions

View file

@ -852,11 +852,12 @@ snmp_table_get(clixon_handle h,
int i;
cg_var *cv;
char *defaultval = NULL;
int inext;
int ret;
/* Get yang of leaf from first part of OID */
ys = NULL;
while ((ys = yn_each(yt, ys)) != NULL) {
inext = 0;
while ((ys = yn_iter(yt, &inext)) != NULL) {
if (yang_keyword_get(ys) != Y_LEAF)
continue;
/* reset oid */
@ -973,6 +974,7 @@ snmp_table_set(clixon_handle h,
netsnmp_variable_list *requestvb;
int rowstatus = 0;
char *origtype;
int inext;
/* Get OID from table /list */
if ((ret = yangext_oid_get(yt, oidt, &oidtlen, NULL)) < 0)
@ -984,8 +986,8 @@ snmp_table_set(clixon_handle h,
*/
ys = NULL;
yrowst = NULL;
yi = NULL;
while ((yi = yn_each(yt, yi)) != NULL) {
inext = 0;
while ((yi = yn_iter(yt, &inext)) != NULL) {
if (yang_keyword_get(yi) != Y_LEAF)
continue;
/* reset oid */

View file

@ -170,7 +170,7 @@ is_same_subtypes_union(yang_stmt *ytype,
char **restype)
{
int retval = 0;
yang_stmt *y_sub_type = NULL;
yang_stmt *y_sub_type;
yang_stmt *y_resolved_type = NULL; /* resolved type */
char *resolved_type_str; /* resolved type */
char *type_str = NULL;
@ -178,12 +178,14 @@ is_same_subtypes_union(yang_stmt *ytype,
cvec *cvv = NULL;
cvec *patterns = NULL;
uint8_t fraction_digits = 0;
int inext;
/* Loop over all sub-types in the resolved union type, note these are
* not resolved types (unless they are built-in, but the resolve call is
* made in the union_one call.
*/
while ((y_sub_type = yn_each(ytype, y_sub_type)) != NULL){
inext = 0;
while ((y_sub_type = yn_iter(ytype, &inext)) != NULL){
if (yang_keyword_get(y_sub_type) != Y_TYPE)
continue;
@ -413,6 +415,7 @@ yang_extension_value_opt(yang_stmt *ys,
int retval = -1;
yang_stmt *yext;
cg_var *cv;
int inext;
if (ys == NULL){
clixon_err(OE_YANG, EINVAL, "ys is NULL");
@ -420,8 +423,9 @@ yang_extension_value_opt(yang_stmt *ys,
}
if (exist)
*exist = 0;
yext = NULL; /* This loop gets complicated in the case the extension is augmented */
while ((yext = yn_each(ys, yext)) != NULL) {
/* This loop gets complicated in the case the extension is augmented */
inext = 0;
while ((yext = yn_iter(ys, &inext)) != NULL) {
if (yang_keyword_get(yext) != Y_UNKNOWN)
continue;
if (strcmp(yang_argument_get(yext), id) != 0)

View file

@ -237,6 +237,7 @@ mibyang_table_register(clixon_handle h,
int asn1type;
yang_stmt *ys;
char *name;
int inext;
if ((ys = yang_parent_get(ylist)) == NULL ||
yang_keyword_get(ys) != Y_CONTAINER){
@ -315,9 +316,9 @@ mibyang_table_register(clixon_handle h,
table_info->min_column = 1;
/* Count columns */
yleaf = NULL;
table_info->max_column = 0;
while ((yleaf = yn_each(ylist, yleaf)) != NULL) {
inext = 0;
while ((yleaf = yn_iter(ylist, &inext)) != NULL) {
if ((yang_keyword_get(yleaf) != Y_LEAF) || (ret = yangext_is_oid_exist(yleaf)) != 1)
continue;
table_info->max_column++;
@ -557,6 +558,7 @@ mibyang_traverse(clixon_handle h,
yang_stmt *ys = NULL;
yang_stmt *yp;
int ret;
int inext;
static oid zero_oid = 0;
clixon_debug(CLIXON_DBG_SNMP, "%s", yang_argument_get(yn));
@ -586,8 +588,8 @@ mibyang_traverse(clixon_handle h,
break;
}
/* Traverse data nodes in tree (module is special case */
ys = NULL;
while ((ys = yn_each(yn, ys)) != NULL) {
inext = 0;
while ((ys = yn_iter(yn, &inext)) != NULL) {
/* augment special case of table */
if (!yang_schemanode(ys) && yang_keyword_get(ys) != Y_AUGMENT)
continue;