diff --git a/src/core/snmp/msg_in.c b/src/core/snmp/msg_in.c index 718c3886..0c2f5c03 100644 --- a/src/core/snmp/msg_in.c +++ b/src/core/snmp/msg_in.c @@ -102,6 +102,30 @@ snmp_init(void) snmp_coldstart_trap(); } +/** + * Returns current SNMP community string. + * @return current SNMP community string + */ +const char * +snmp_get_community(void) +{ + return snmp_community; +} + +/** + * Sets SNMP community string. + * The string itself (its storage) must be valid throughout the whole life of + * program (or until it is changed to sth else). + * + * @param community is a pointer to new community string + */ +void +snmp_set_community(const char * const community) +{ + LWIP_ASSERT("community string is too long!", strlen(community) <= SNMP_COMMUNITY_STR_LEN); + snmp_community = community; +} + static void snmp_error_response(struct snmp_msg_pstat *msg_ps, u8_t error) { diff --git a/src/include/lwip/snmp.h b/src/include/lwip/snmp.h index 101bb66d..8c34e315 100644 --- a/src/include/lwip/snmp.h +++ b/src/include/lwip/snmp.h @@ -97,6 +97,9 @@ struct snmp_obj_id s32_t id[LWIP_SNMP_OBJ_ID_LEN]; }; +const char * snmp_get_community(void); +void snmp_set_community(const char *community); + /* system */ void snmp_set_sysdescr(const u8_t* str, const u8_t* len); void snmp_set_sysobjid(const struct snmp_obj_id *oid);