Merge pull request #402 from doron2020/Yang_leaves_without_smiv2_oid_directive_are_not_shown+well_in_snmpwalk
Fixed: [Yang leaves without smiv2:oid directive are not shown well in…
This commit is contained in:
commit
fe291fe73d
4 changed files with 36 additions and 7 deletions
|
|
@ -875,7 +875,7 @@ snmp_table_get(clicon_handle h,
|
|||
if ((ret = yangext_oid_get(ys, oidleaf, &oidleaflen, NULL)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto done;
|
||||
continue;
|
||||
if (oidtlen + 1 != oidleaflen) /* Indexes may be from other OID scope, skip those */
|
||||
continue;
|
||||
if (oids[oidleaflen-1] == oidleaf[oidleaflen-1])
|
||||
|
|
@ -1003,7 +1003,7 @@ snmp_table_set(clicon_handle h,
|
|||
if ((ret = yangext_oid_get(yi, oidleaf, &oidleaflen, NULL)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto done;
|
||||
continue;
|
||||
if (oidtlen + 1 != oidleaflen) /* Indexes may be from other OID scope, skip those */
|
||||
continue;
|
||||
if (oids[oidleaflen-1] == oidleaf[oidleaflen-1]){
|
||||
|
|
@ -1090,7 +1090,7 @@ snmp_table_set(clicon_handle h,
|
|||
cvk_val,
|
||||
&rowstatus)) < 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* If no rowstatus object, default to active */
|
||||
rowstatus = 1;
|
||||
|
|
@ -1231,6 +1231,8 @@ snmp_table_getnext(clicon_handle h,
|
|||
continue;
|
||||
if ((ret = yangext_oid_get(ycol, oidc, &oidclen, NULL)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
continue;
|
||||
/* Append key oid */
|
||||
if (oid_append(oidc, &oidclen, oidk, oidklen) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -365,6 +365,30 @@ yangext_oid_get(yang_stmt *yn,
|
|||
goto done;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! Given a YANG node, return 1 if leaf has oid directive in it, otherwise 0
|
||||
* @param[in] yn Yang node
|
||||
* @retval 1 found
|
||||
* @retval 0 not found
|
||||
*/
|
||||
int yangext_is_oid_exist(yang_stmt *yn) {
|
||||
|
||||
int exist = 0;
|
||||
char *oidstr = NULL;
|
||||
|
||||
if ((yang_keyword_get(yn) != Y_LEAF) ||
|
||||
(yang_extension_value(yn, "oid", IETF_YANG_SMIV2_NS, &exist, &oidstr) < 0) ||
|
||||
(exist == 0) ||
|
||||
(oidstr == NULL)) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! Duplicate clixon snmp handler struct
|
||||
* Use signature of libnetsnmp data_clone field of netsnmp_mib_handler in agent_handler.h
|
||||
* @param[in] arg
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ int oid_cbuf(cbuf *cb, const oid *objid, size_t objidlen);
|
|||
int oid_print(FILE *f, const oid *objid, size_t objidlen);
|
||||
int snmp_yang_type_get(yang_stmt *ys, yang_stmt **yrefp, char **origtypep, yang_stmt **yrestypep, char **restypep);
|
||||
int yangext_oid_get(yang_stmt *yn, oid *objid, size_t *objidlen, char **objidstr);
|
||||
int yangext_is_oid_exist(yang_stmt *yn);
|
||||
int snmp_access_str2int(char *modes_str);
|
||||
const char *snmp_msg_int2str(int msg);
|
||||
void *snmp_handle_clone(void *arg);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ mibyang_leaf_register(clicon_handle h,
|
|||
}
|
||||
oid_cbuf(cboid, oid1, oid1len);
|
||||
clicon_debug(1, "%s register: %s %s", __FUNCTION__, name, cbuf_get(cboid));
|
||||
ok:
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
if (cboid)
|
||||
|
|
@ -317,10 +317,12 @@ mibyang_table_register(clicon_handle h,
|
|||
|
||||
/* Count columns */
|
||||
yleaf = NULL;
|
||||
table_info->max_column = 0;
|
||||
table_info->max_column = 0;
|
||||
while ((yleaf = yn_each(ylist, yleaf)) != NULL) {
|
||||
if (yang_keyword_get(yleaf) == Y_LEAF)
|
||||
table_info->max_column++;
|
||||
if ((yang_keyword_get(yleaf) != Y_LEAF) || (ret = yangext_is_oid_exist(yleaf)) != 1)
|
||||
continue;
|
||||
|
||||
table_info->max_column++;
|
||||
}
|
||||
if ((ret = netsnmp_register_table(nhreg, table_info)) != SNMPERR_SUCCESS){
|
||||
clicon_err(OE_SNMP, ret, "netsnmp_register_table");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue