Open
Conversation
a length of exactly 256 should be encoded as: 0x82 0x01 0x00 without this change, I was seeing the encoded length of a get response (that happened to be exactly 256 bytes long) encoded as: 0x81 0x00 that was causing snmpbulkwalk to fail, since it was reading the encoded length as 0.
…elds (SNMP version, error status / non-repeaters, error index / repeaters). add _knownLen to IntegerType: defaults to 4 (1 for ByteType), and is set to the decoded _length in fromBuffer(). this is then used in serialise(), where it selectively outputs extra bytes only when needed. with all that, the resultant outgoing packet will be at least 9 bytes shorter. for certain packets, it could be 10 bytes shorter, if the decrease by 9 forces a containing struct's length to drop from requiring 2 bytes to encode its length down to 1, etc. that is the case for the test packet returned by the test.cpp GenerateTestSNMPRequestPacket() function. it was generating a 133 byte packet, but now is only 123. update the unit tests to now use a const (const int expected_length = 123;) throughout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #61
add ByteType (derived from IntegerType), and use this for protocol fields (SNMP version, error status / non-repeaters, error index / repeaters).
add _knownLen to IntegerType: defaults to 4 (1 for ByteType), and is set to the decoded _length in fromBuffer().
this is then used in serialise(), where it selectively outputs extra bytes only when needed.
with all that, the resultant outgoing packet will be at least 9 bytes shorter.
for certain packets, it could be 10 bytes shorter, if the decrease by 9 forces a containing struct's length to drop from requiring 2 bytes to encode its length down to 1, etc.
that is the case for the test packet returned by the test.cpp GenerateTestSNMPRequestPacket() function.
it was generating a 133 byte packet, but now is only 123.
update the unit tests to now use a const (const int expected_length = 123;) throughout.