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

v1 traps with empty varbinds can't be parsed #32

Closed
movaps opened this issue Jul 22, 2014 · 1 comment
Closed

v1 traps with empty varbinds can't be parsed #32

movaps opened this issue Jul 22, 2014 · 1 comment

Comments

@movaps
Copy link

movaps commented Jul 22, 2014

I've noticed that some agents (e.g. HP 2650) send their variable-less traps (e.g. authenticationFailure) with the message stopping abruptly after varbinds SEQUENCE marker, causing snmpjs to discard the trap with an error. While these traps aren't entirely kosher, every NMS I've tried handles them gracefully and there's little point in discarding the trap when all the actual information contained therein has been successfully parsed.

Here's a small patch that fixes the issue;

diff --git lib/snmp.jison lib/snmp.jison
index e9c6a7a..7958d3c 100644
--- lib/snmp.jison
+++ lib/snmp.jison
@@ -134,8 +134,7 @@ pdu
                $$.error_status = $3;
                $$.error_index = $4;
        }}
-       | obsolete_trap_pdu_tag oid ip_address integer integer time_ticks
-         varbind_list {{
+       | obsolete_trap_pdu_tag oid ip_address integer integer time_ticks varbind_list_v1 {{
                $$ = yy.pdu.createPDU({ op: $1, varbinds: $7 });
                $$.enterprise = $2;
                $$.agent_addr = $3;
@@ -160,6 +159,15 @@ obsolete_trap_pdu_tag
        : 'CONTEXT_CONSTRUCTED_4' {{ $$ = yy.pdu.Trap; }}
        ;

+
+varbind_list_v1
+       : 'SEQUENCE' varbinds {{
+               $$ = $2;
+       }}
+       | 'SEQUENCE'
+       |
+       ;
+
 varbind_list
        : 'SEQUENCE' varbinds {{
                $$ = $2;

@movaps movaps changed the title (Patch) v1 traps with empty varbinds can't be parsed (Patch) Some v1 traps with empty varbinds can't be parsed Jul 22, 2014
@ghost ghost changed the title (Patch) Some v1 traps with empty varbinds can't be parsed v1 traps with empty varbinds can't be parsed Jul 23, 2014
ghost pushed a commit that referenced this issue Jul 23, 2014
@ghost
Copy link

ghost commented Jul 23, 2014

Thanks! Fixed in 0.1.7.

@ghost ghost closed this as completed Jul 23, 2014
This issue was closed.
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