snmptranslate.c (v1.0): in/out options are toggled
Brought to you by:
alsterg
input/output options passed to "snmp translate" are toggled instead of being set/reset, resulting in unexpected behaviour between calls.
For example, try executing
snmp translate -IR -On sysDescr.0
snmp translate -IR -On sysDescr.0
the first call works, while the second call (identical) results in an error because the 'R' flag is toggled.
I'm not familiar enough with the Net-SNMP C API to suggest an appropriate solution to this, but perhaps the library datastore storing the options probably needs to be reinitialized to a known state between calls to snmptranslate().
Logged In: YES
user_id=2033368
Originator: YES
I had a deeper look into Net-SNMP source (v 5.4.1): apparently there isn't a sane way to fix this, other than backing up the whole settings in the default store, resetting all the boolean values, do the call and then restoring the previous settings.
It seems that Net-SNMP stores its settings (including things like the SNMP community and SNMPv3 parameters, which could logically be thought as belonging to a specific session) in a handful of static arrays, which is basically the same as having a bunch of global variables, so backing up and restoring the settings between calls (even for "get", "getnext", "walk", etc.) is probably required to allow for indipendent sessions
In other words, creating a new SNMP session with different settings from the previously opened ones currently results in the old sessions using the new settings.