Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for SNMP traps (v2 at least) #23

Open
mitchell-es opened this issue Feb 24, 2023 · 0 comments
Open

Support for SNMP traps (v2 at least) #23

mitchell-es opened this issue Feb 24, 2023 · 0 comments

Comments

@mitchell-es
Copy link

mitchell-es commented Feb 24, 2023

Support for SNMP v2 traps would be nice. I actually have it working and could provide a pull request but it's such a small change I'm not sure it's worth it a pull request. Simply adding ASN_SNMP_TRAP2 to the list of packet types works. SNMP v1 traps have such an oddball format and are so rarely used I'm not sure adding support for them is worth the effort. It isn't for me.

diff --git a/fastsnmp/snmp_parser.pyx b/fastsnmp/snmp_parser.pyx
index 2420cc3..a6060f0 100644
--- a/fastsnmp/snmp_parser.pyx
+++ b/fastsnmp/snmp_parser.pyx
@@ -640,7 +640,7 @@ cdef tuple sequence_decode_c(const unsigned char *stream, const size_t stream_le
             objects.append(object_str)
         elif tag == ASN_U_NULL:
             objects.append(None)
-        elif tag == ASN_U_SEQUENCE or tag == ASN_SNMP_RESPONSE or tag == ASN_SNMP_GETBULK:
+        elif tag == ASN_U_SEQUENCE or tag == ASN_SNMP_RESPONSE or tag == ASN_SNMP_GETBULK or tag == ASN_SNMP_TRAP2:
             tmp_list_val, ex = sequence_decode_c(stream_char, length)
             if tmp_list_val is not None:
                 objects.append(tmp_list_val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant