[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #48342] SNMP Traps not working correct
From: |
Marco Veeneman |
Subject: |
[lwip-devel] [bug #48342] SNMP Traps not working correct |
Date: |
Wed, 29 Jun 2016 14:12:44 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 |
URL:
<http://savannah.nongnu.org/bugs/?48342>
Summary: SNMP Traps not working correct
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: mave
Submitted on: Wed 29 Jun 2016 02:12:42 PM GMT
Category: None
Severity: 3 - Normal
Item Group: Faulty Behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release:
lwIP version: git head
_______________________________________________________
Details:
I found two issues regarding SNMP Traps.
1) When trying to receive some generic traps (coldstart(0),
authenticationfailure(4)) i noticed the traps are received by my PC, but not
in the trap server.
This had worked before the SNMP rewrite. Diving into the trap encoding
functions and comparing wireshark captures i found the issue: the variable
bindings field is missing in the trap message. Even if there are no varbinds
attached to the trap, this field should still be present. See patch:
diff --git a/src/apps/snmp/snmp_traps.c b/src/apps/snmp/snmp_traps.c
index 3da2dca..528a054 100644
--- a/src/apps/snmp/snmp_traps.c
+++ b/src/apps/snmp/snmp_traps.c
@@ -247,6 +247,9 @@ snmp_trap_header_sum(struct snmp_msg_trap *trap)
tot_len = 0;
+ snmp_asn1_enc_length_cnt(0, &lenlen);
+ tot_len += 1 + lenlen;
+
snmp_asn1_enc_u32t_cnt(trap->ts, &len);
snmp_asn1_enc_length_cnt(len, &lenlen);
tot_len += 1 + len + lenlen;
@@ -359,6 +362,9 @@ snmp_trap_header_enc(struct snmp_msg_trap *trap, struct
snmp_pbuf_stream *pbuf_s
snmp_asn1_enc_s32t_cnt(trap->ts, &tlv.value_len);
snmp_ans1_enc_tlv(pbuf_stream, &tlv);
snmp_asn1_enc_s32t(pbuf_stream, tlv.value_len, trap->ts);
+
+ SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_SEQUENCE, 0, 0);
+ snmp_ans1_enc_tlv(pbuf_stream, &tlv);
}
#endif /* LWIP_SNMP */
2) Generic snmpv1 traps should be sent from .1.3.6.1.2.1.11
(iso.org.dod.internet.mgmt.mib-2.snmp).
Currently they are sent from the oid set to snmp_device_enterprise_oid because
NULL is passed to snmp_send_trap from snmp_send_trap_generic. See patch:
diff --git a/src/apps/snmp/snmp_traps.c b/src/apps/snmp/snmp_traps.c
index 3da2dca..52ec101 100644
--- a/src/apps/snmp/snmp_traps.c
+++ b/src/apps/snmp/snmp_traps.c
@@ -207,7 +207,8 @@ snmp_send_trap(const struct snmp_obj_id
*device_enterprise_oid, s32_t generic_tr
err_t
snmp_send_trap_generic(s32_t generic_trap)
{
- return snmp_send_trap(NULL, generic_trap, 0);
+ static const struct snmp_obj_id oid = { 7, { 1, 3, 6, 1, 2, 1, 11 } };
+ return snmp_send_trap(&oid, generic_trap, 0, NULL);
}
err_t
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?48342>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [lwip-devel] [bug #48342] SNMP Traps not working correct,
Marco Veeneman <=