soniah/gosnmp — pull request #1 by codedance (2014-06-15 11:33:34+00:00)
Title: Few bug fixes and walk support

Hi Sonia,

I've been reviewing a few Go SNMP implementations and running them through a few real world cases. I really like the changes you've done on your fork. Are you willing to accept some full requests?

Assuming you're are, please review this pull request and let me know what changes you'd like before merging.

I also noted that @virtuallynathan is also doing some good work on your branch. Hopefully we can all coordinate to make SNMP great in Go!

Changes:

**Changes to minimise impact of unimplemented types**

* If GetMultiple or GetBulk returns a MIB with an Unimplemented type
(e.g. Opaque) the whole call would return an error. It's more
desirable to return an UnknownType so it's at least possible to read
other values. The UnknownType's byte number has been set to 0x00.
Java SNMP takes the same approach.

* Minor bugfix - The RequestID was not being correctly parsed.

* Added FIXME to the RequestID. This should be set to an atomic counter
and the read should discard (and retry) if the sent ID does not match
the received ID. In the current implementation it would be possible
for a late arriving packet form a pervious (failed) request to be
incorrectly associated with the call. This will be fixed in a future
commit.

**Added SNMP walk (via both GETBULK and GETNEXT)**
The original 'alouca' version has a limited walk implementation. This
version's logic is more robust and is able to successfully walk large
trees across a range of different devices/agents. Flow is based off
existing walk implementations found in net-snmp and Java snmp.

TODO: To make this just as reliable as other implementations, we'll need to
add retry support at the send() layer, and ensure packet request IDs are
matched. I'll open this as an issue.

Cheers from Melbourne,

Chris