Merge pull request #406 from StasSt-siklu/SNMP_accepts_only_u32_and_u64
Added translation from Yang type to SNMP type
This commit is contained in:
commit
b58635554c
1 changed files with 17 additions and 0 deletions
|
|
@ -143,6 +143,22 @@ static const map_str2int snmp_msg_map[] = {
|
|||
{NULL, -1}
|
||||
};
|
||||
|
||||
/* Map between yang type / SNMP type
|
||||
SNMP does not accept int8, int16 etc. Only int32, int64
|
||||
*/
|
||||
static const map_str2str yang_snmp_types[] = {
|
||||
{"int8", "int32"},
|
||||
{"int16", "int32"},
|
||||
{"uint8", "uint32"},
|
||||
{"uint16", "uint32"},
|
||||
{ NULL, NULL} /* if not found */
|
||||
};
|
||||
char* yang_type_to_snmp(char* yang_type)
|
||||
{
|
||||
char* ret = clicon_str2str(yang_snmp_types, yang_type);
|
||||
return (NULL == ret) ? yang_type : ret;
|
||||
}
|
||||
|
||||
/*! Translate from snmp string to int representation
|
||||
* @note Internal snmpd, maybe find something in netsnmpd?
|
||||
*/
|
||||
|
|
@ -278,6 +294,7 @@ snmp_yang_type_get(yang_stmt *ys,
|
|||
if (yang_type_get(ys, &origtype, &yrestype, NULL, NULL, NULL, NULL, NULL) < 0)
|
||||
goto done;
|
||||
restype = yrestype?yang_argument_get(yrestype):NULL;
|
||||
restype = yang_type_to_snmp(restype);
|
||||
if (strcmp(restype, "leafref")==0){
|
||||
if ((ypath = yang_find(yrestype, Y_PATH, NULL)) == NULL){
|
||||
clicon_err(OE_YANG, 0, "No path in leafref");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue