etingof / snmpsim

SNMP Simulator
http://snmplabs.com/snmpsim/
BSD 2-Clause "Simplified" License
376 stars 119 forks source link

writecache and hex values #135

Open mmodenesi opened 4 years ago

mmodenesi commented 4 years ago

Good behavior

Given this mib file

root@a0b8702ee6f6:/# cat /tmp/snmprec/write.snmprec 
1.3.6.1.2.1.27070.3.1.2.2.2.1.5.1|64x|0a110019

When served with this command line:

snmpsim-command-responder --data-dir=/tmp/snmprec --agent-udpv4-endpoint=0.0.0.0:161 --process-user root --process-group root --debug all

Is avaliable to be queried:

root@d4abfe8a1569:/# snmpwalk -v 2c -c write snmphost:161
iso.3.6.1.2.1.27070.3.1.2.2.2.1.5.1 = IpAddress: 10.17.0.25
iso.3.6.1.2.1.27070.3.1.2.2.2.1.5.1 = No more variables left in this MIB View (It is past the end of the MIB tree)

Bad behavior

If I want to use writecache to allow write operations to be simulated, then

root@a0b8702ee6f6:/# cat /tmp/snmprec/write.snmprec 
1.3.6.1.2.1.27070.3.1.2.2.2.1.5.1|64x:writecache|value=0a110019

Is not available to be queried:

root@d4abfe8a1569:/# snmpwalk -v 2c -c write dektec:161
iso.3.6.1.2.1 = No more variables left in this MIB View (It is past the end of the MIB tree)

And I see this error log:

ERROR data error at /tmp/snmprec/write.snmprec controller for 1.3.6.1.2.1: value evaluation for 1.3.6.1.2.1.27070.3.1.2.2.2.1.5.1 = 'value=0a110019' failed: Bad IP address syntax 0a110019caused by <class 'ValueError'>: invalid literal for int() with base 10: '0a110019

As a workaround, I can serve the "writable" version with

1.3.6.1.2.1.27070.3.1.2.2.2.1.5.1|64:writecache|value=10.17.0.25

Is it ok that writecache is not properly handling the x in 64x?

Thank you!