I'm trying to write an SNMP agent and frankly the whole process has been like reading pooorly translated stereo instructions. But I'm close, except for one problem: implementing the GETNEXT operation.
Consider the following chunk of the system OID space:
.1.3.6.1.2.1 .1.5.0
.1.6.0
.1.8.0
.1.9.1 .2.1
.2.2
.2.3
For definiteness, let's say that I want to do
$ snmpwalk -On -v 2c -c public localhost .1.3.6.1.2.1.1.8.0
net-snmp implements this by first performing a GET on .1.8.0, followed by a GETNEXT. The GETNEXT should go from .1.8.0 to .1.9.1.2.1, then .1.9.1.2.2 and so on.
I recognize that this is conceptually merely a depth first walk, but for some reason -- age, perhaps -- I just can't figure out a clean way to implement that search when it has to find the GET node, then back up on the next call and find the "next" node.
Feel free to show me that it's foolishly simple.
Update
I wrote this after a 26 hour programming bout, so I can imagine it's not clear. Here's the question:
I need a function successor which takes an OID as input and returns the next OID -- where next is in depth-first order as implemented by SNMP tools. I've got a couple of solutions that work by enumerating the OIDs in depth-first order and waiting for the right one to come around, ; I'm looking for an elegant one thatis better than O(l+n) where l is length of the OID and n is number of OIDs.