From 79c8a04152ff8308d7521af27d3681cf466d472c Mon Sep 17 00:00:00 2001 From: Harrold Spier Date: Tue, 17 Mar 2020 09:46:56 +0100 Subject: [PATCH] SNMP netconn API should not check for core locked See patch #9907 --- src/apps/snmp/snmp_core.c | 6 +++--- src/apps/snmp/snmp_core_priv.h | 8 ++++++++ src/apps/snmp/snmp_msg.c | 8 ++++---- src/apps/snmp/snmp_netconn.c | 1 - src/apps/snmp/snmp_traps.c | 6 +++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/apps/snmp/snmp_core.c b/src/apps/snmp/snmp_core.c index a16807b1..04e0c317 100644 --- a/src/apps/snmp/snmp_core.c +++ b/src/apps/snmp/snmp_core.c @@ -238,7 +238,7 @@ static struct snmp_mib const *const *snmp_mibs = default_mibs; void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); LWIP_ASSERT("mibs pointer must be != NULL", (mibs != NULL)); LWIP_ASSERT("num_mibs pointer must be != 0", (num_mibs != 0)); snmp_mibs = mibs; @@ -261,7 +261,7 @@ snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs) */ void snmp_set_device_enterprise_oid(const struct snmp_obj_id *device_enterprise_oid) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); if (device_enterprise_oid == NULL) { snmp_device_enterprise_oid = &snmp_device_enterprise_oid_default; } else { @@ -275,7 +275,7 @@ void snmp_set_device_enterprise_oid(const struct snmp_obj_id *device_enterprise_ */ const struct snmp_obj_id *snmp_get_device_enterprise_oid(void) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); return snmp_device_enterprise_oid; } diff --git a/src/apps/snmp/snmp_core_priv.h b/src/apps/snmp/snmp_core_priv.h index 9532c05e..e4323180 100644 --- a/src/apps/snmp/snmp_core_priv.h +++ b/src/apps/snmp/snmp_core_priv.h @@ -44,6 +44,14 @@ extern "C" { #endif +#if !defined LWIP_ASSERT_SNMP_LOCKED +#if SNMP_USE_RAW +#define LWIP_ASSERT_SNMP_LOCKED() LWIP_ASSERT_CORE_LOCKED() +#else +#define LWIP_ASSERT_SNMP_LOCKED() +#endif +#endif + /* (outdated) SNMPv1 error codes * shall not be used by MIBS anymore, nevertheless required from core for properly answering a v1 request */ diff --git a/src/apps/snmp/snmp_msg.c b/src/apps/snmp/snmp_msg.c index 3d04094e..d0f490b3 100644 --- a/src/apps/snmp/snmp_msg.c +++ b/src/apps/snmp/snmp_msg.c @@ -180,7 +180,7 @@ snmp_get_community(void) void snmp_set_community(const char *const community) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); LWIP_ASSERT("community string is too long!", strlen(community) <= SNMP_MAX_COMMUNITY_STR_LEN); snmp_community = community; } @@ -218,7 +218,7 @@ snmp_get_community_trap(void) void snmp_set_community_write(const char *const community) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); LWIP_ASSERT("community string must not be NULL", community != NULL); LWIP_ASSERT("community string is too long!", strlen(community) <= SNMP_MAX_COMMUNITY_STR_LEN); snmp_community_write = community; @@ -235,7 +235,7 @@ snmp_set_community_write(const char *const community) void snmp_set_community_trap(const char *const community) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); LWIP_ASSERT("community string is too long!", strlen(community) <= SNMP_MAX_COMMUNITY_STR_LEN); snmp_community_trap = community; } @@ -247,7 +247,7 @@ snmp_set_community_trap(const char *const community) void snmp_set_write_callback(snmp_write_callback_fct write_callback, void *callback_arg) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); snmp_write_callback = write_callback; snmp_write_callback_arg = callback_arg; } diff --git a/src/apps/snmp/snmp_netconn.c b/src/apps/snmp/snmp_netconn.c index 8850acb5..70f8bfc0 100644 --- a/src/apps/snmp/snmp_netconn.c +++ b/src/apps/snmp/snmp_netconn.c @@ -116,7 +116,6 @@ snmp_get_local_ip_for_dst(void *handle, const ip_addr_t *dst, ip_addr_t *result) void snmp_init(void) { - LWIP_ASSERT_CORE_LOCKED(); sys_thread_new("snmp_netconn", snmp_netconn_thread, NULL, SNMP_STACK_SIZE, SNMP_THREAD_PRIO); } diff --git a/src/apps/snmp/snmp_traps.c b/src/apps/snmp/snmp_traps.c index 3f83f2df..724a45d8 100644 --- a/src/apps/snmp/snmp_traps.c +++ b/src/apps/snmp/snmp_traps.c @@ -142,7 +142,7 @@ static s32_t req_id = 1; void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); if (dst_idx < SNMP_TRAP_DESTINATIONS) { trap_dst[dst_idx].enable = enable; } @@ -159,7 +159,7 @@ snmp_trap_dst_enable(u8_t dst_idx, u8_t enable) void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst) { - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); if (dst_idx < SNMP_TRAP_DESTINATIONS) { ip_addr_set(&trap_dst[dst_idx].dip, dst); } @@ -380,7 +380,7 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg, } }; - LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT_SNMP_LOCKED(); snmp_v2_special_varbinds[0].next = &snmp_v2_special_varbinds[1]; snmp_v2_special_varbinds[1].prev = &snmp_v2_special_varbinds[0];