snmp_traps.c: Portability fix: Don't use non-constant initializers

This commit is contained in:
Dirk Ziegelmeier 2018-11-22 13:14:52 +01:00
parent 5da6c0cfd0
commit 45a055840d

View File

@ -356,7 +356,7 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
struct snmp_varbind snmp_v2_special_varbinds[] = { struct snmp_varbind snmp_v2_special_varbinds[] = {
/* First varbind is used to store sysUpTime */ /* First varbind is used to store sysUpTime */
{ {
&snmp_v2_special_varbinds[1], /* *next */ NULL, /* *next */
NULL, /* *prev */ NULL, /* *prev */
{ /* oid */ { /* oid */
8, /* oid len */ 8, /* oid len */
@ -364,12 +364,12 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
}, },
SNMP_ASN1_TYPE_TIMETICKS, /* type */ SNMP_ASN1_TYPE_TIMETICKS, /* type */
sizeof(u32_t), /* value_len */ sizeof(u32_t), /* value_len */
&timestamp /* value */ NULL /* value */
}, },
/* Second varbind is used to store snmpTrapOID */ /* Second varbind is used to store snmpTrapOID */
{ {
varbinds, /* *next */ NULL, /* *next */
&snmp_v2_special_varbinds[0], /* *prev */ NULL, /* *prev */
{ /* oid */ { /* oid */
10, /* oid len */ 10, /* oid len */
{1, 3, 6, 1, 6, 3, 1, 1, 4, 1} /* oid for snmpTrapOID */ {1, 3, 6, 1, 6, 3, 1, 1, 4, 1} /* oid for snmpTrapOID */
@ -382,6 +382,13 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
LWIP_ASSERT_CORE_LOCKED(); LWIP_ASSERT_CORE_LOCKED();
snmp_v2_special_varbinds[0].next = &snmp_v2_special_varbinds[1];
snmp_v2_special_varbinds[1].prev = &snmp_v2_special_varbinds[0];
snmp_v2_special_varbinds[0].value = &timestamp;
snmp_v2_special_varbinds[1].next = varbinds;
/* see rfc3584 */ /* see rfc3584 */
if (trap_msg->snmp_version == SNMP_VERSION_2c) { if (trap_msg->snmp_version == SNMP_VERSION_2c) {
struct snmp_obj_id snmp_trap_oid = { 0 }; /* used for converting SNMPv1 generic/specific trap parameter to SNMPv2 snmpTrapOID */ struct snmp_obj_id snmp_trap_oid = { 0 }; /* used for converting SNMPv1 generic/specific trap parameter to SNMPv2 snmpTrapOID */