clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
215 stars 72 forks source link

snmpwalk doesn't show properly SNMP boolean values which equal false #400

Closed vvsosed closed 1 year ago

vvsosed commented 1 year ago

We use definition like leaf ifConnectorPresent { type boolean; description "This object has the value 'true(1)' if the interface sublayer has a physical connector and the value 'false(2)' otherwise."; smiv2:max-access "read-only"; smiv2:oid "1.3.6.1.2.1.31.1.1.1.17"; }

but unfortunately, we are able to see snmpwalk output like IF-MIB::ifConnectorPresent.5 = INTEGER: true(1) IF-MIB::ifConnectorPresent.7 = INTEGER: 0 According to RFC-1212 we should see IF-MIB::ifConnectorPresent.5 = BOOLEAN: true(1) IF-MIB::ifConnectorPresent.7 = BOOLEAN: false(2) I suspect that problem happens because the CLIXON SNMP module uses integer type to support SNMP boolean value.

olofhagsand commented 1 year ago

There seems to be two problems,

This is a comment in the code regarding netsnmp support:

Athough smidump translates TruthValue to boolean
     * and there is an ASN_BOOLEAN constant:
     * 1) there is no code for ASN_BOOLEAN and
     * 2) Truthvalue actually translates to enum true(1)/false(0)

Would it be OK to fix the first false problem, since the second seems to be absent from the libnetsmp code available. But I need to revisit that to be sure.

shmuelhazan commented 1 year ago

@olofhagsand I tested now with a some network equipment (Netgear swtich), and looks like they are representing it as an INTEGER too:

...
IF-MIB::ifConnectorPresent.939 = INTEGER: false(2)
...

So probably the main bug is that false is 0 instead of 2.

vvsosed commented 1 year ago

Successfully fixed, thanks!