I am adding SNMP EtherLike MIB variables to our existing SNMP C++ codebase and doing it for very first time.
The difficulty I am facing is understanding the data types of MIB variables and map it to C++ data types - for example dot3StatsIndex MIB variable syntax is InterfaceIndex so what is it equivalent data type in C++.
Since I am implementing for very first time or rather is in learning phase - please let me know what are the different ASN.1 data types and whether the types all are listed above and how they are mapped to C++ datatypes?
Also how to derive from RFC the data type of the MIB variable?
I think if you just follow the type inheritance chain, you end up with a base SNMP type which should map to the types you have.
For InterfaceIndex
, see from which MIB it's imported (it's IF-MIB
):
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, OBJECT-IDENTITY,
Integer32, Counter32, Counter64, mib-2, transmission
FROM SNMPv2-SMI
MODULE-COMPLIANCE, OBJECT-GROUP
FROM SNMPv2-CONF
TruthValue
FROM SNMPv2-TC
ifIndex, InterfaceIndex
FROM IF-MIB;
Then find its definition which should reference a base type (it's Integer32
which probably maps to ASN1_INT
).
InterfaceIndex ::= TEXTUAL-CONVENTION
DISPLAY-HINT "d"
STATUS current
DESCRIPTION
"A unique value, greater than zero, for each interface or ...
network management system to the next re-initialization."
SYNTAX Integer32 (1..2147483647)