6#if LWIP_SNMP && LWIP_SNMP_V3
22static const struct snmp_oid_range usmUserTable_oid_ranges[] = {
23 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
24 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
25 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
26 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
27 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
28 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
29 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff },
30 { 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff }
33static void snmp_engineid_to_oid(
const char *engineid,
u32_t *oid,
u32_t len)
37 for (
i = 0;
i <
len;
i++) {
42static void snmp_oid_to_name(
char *
name,
const u32_t *oid,
size_t len)
46 for (
i = 0;
i <
len;
i++) {
51static void snmp_name_to_oid(
const char *
name,
u32_t *oid,
size_t len)
55 for (
i = 0;
i <
len;
i++) {
60static const struct snmp_obj_id *snmp_auth_algo_to_oid(snmpv3_auth_algo_t algo)
62 if (algo == SNMP_V3_AUTH_ALGO_MD5) {
63 return &usmHMACMD5AuthProtocol;
64 }
else if (algo == SNMP_V3_AUTH_ALGO_SHA) {
65 return &usmHMACSHAAuthProtocol;
68 return &usmNoAuthProtocol;
71static const struct snmp_obj_id *snmp_priv_algo_to_oid(snmpv3_priv_algo_t algo)
73 if (algo == SNMP_V3_PRIV_ALGO_DES) {
74 return &usmDESPrivProtocol;
75 }
else if (algo == SNMP_V3_PRIV_ALGO_AES) {
76 return &usmAESPrivProtocol;
79 return &usmNoPrivProtocol;
84static snmp_err_t usmusertable_get_instance(
const u32_t *
column,
const u32_t *row_oid,
u8_t row_oid_len,
struct snmp_node_instance *cell_instance)
89 u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
99 snmpv3_get_engine_id(&engineid, &eid_len);
101 engineid_len = (
u8_t)row_oid[0];
104 if (engineid_len != eid_len) {
106 return SNMP_ERR_NOSUCHINSTANCE;
109 if (engineid_len > row_oid_len) {
111 return SNMP_ERR_NOSUCHINSTANCE;
115 if (!snmp_oid_in_range(&row_oid[engineid_start], engineid_len, usmUserTable_oid_ranges, engineid_len)) {
116 return SNMP_ERR_NOSUCHINSTANCE;
119 snmp_engineid_to_oid(engineid, engineid_oid, engineid_len);
122 if (snmp_oid_equal(&row_oid[engineid_start], engineid_len, engineid_oid, engineid_len)) {
123 return SNMP_ERR_NOSUCHINSTANCE;
126 name_len = (
u8_t)row_oid[engineid_start + engineid_len];
127 name_start = engineid_start + engineid_len + 1;
129 if (name_len > SNMP_V3_MAX_USER_LENGTH) {
131 return SNMP_ERR_NOSUCHINSTANCE;
134 if (1 + engineid_len + 1 + name_len != row_oid_len) {
136 return SNMP_ERR_NOSUCHINSTANCE;
140 if (!snmp_oid_in_range(&row_oid[name_start], name_len, usmUserTable_oid_ranges, name_len)) {
141 return SNMP_ERR_NOSUCHINSTANCE;
146 snmp_oid_to_name(
username, &row_oid[name_start], name_len);
148 return SNMP_ERR_NOSUCHINSTANCE;
152 cell_instance->reference.ptr =
username;
153 cell_instance->reference_len = name_len;
156 return SNMP_ERR_NOERROR;
170static snmp_err_t usmusertable_get_next_instance(
const u32_t *
column,
struct snmp_obj_id *row_oid,
struct snmp_node_instance *cell_instance)
172 const char *engineid;
175 u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
181 u8_t engineid_start = 1;
184 struct snmp_next_oid_state
state;
190 snmpv3_get_engine_id(&engineid, &eid_len);
193 if (row_oid->len > 0) {
194 engineid_len = (
u8_t)row_oid->id[0];
197 if (engineid_len != eid_len) {
199 return SNMP_ERR_NOSUCHINSTANCE;
202 if (engineid_len > row_oid->len) {
204 snmp_engineid_to_oid(engineid, engineid_oid, row_oid->len - 1);
205 if (!snmp_oid_equal(&row_oid->id[engineid_start], row_oid->len - 1, engineid_oid, row_oid->len - 1)) {
206 return SNMP_ERR_NOSUCHINSTANCE;
210 snmp_engineid_to_oid(engineid, engineid_oid, engineid_len);
211 if (!snmp_oid_equal(&row_oid->id[engineid_start], engineid_len, engineid_oid, engineid_len)) {
212 return SNMP_ERR_NOSUCHINSTANCE;
219 if (row_oid->len > engineid_start + engineid_len) {
220 name_len = (
u8_t)row_oid->id[engineid_start + engineid_len];
221 name_start = engineid_start + engineid_len + 1;
223 if (name_len > SNMP_V3_MAX_USER_LENGTH) {
225 return SNMP_ERR_NOSUCHINSTANCE;
228 if (row_oid->len < engineid_len + name_len + 2) {
230 u8_t tmplen = row_oid->len - engineid_len - 2;
231 if (!snmp_oid_in_range(&row_oid->id[name_start], tmplen, usmUserTable_oid_ranges, tmplen)) {
232 return SNMP_ERR_NOSUCHINSTANCE;
236 u8_t tmplen = row_oid->len - engineid_len - 2;
237 if (!snmp_oid_in_range(&row_oid->id[name_start], name_len, usmUserTable_oid_ranges, tmplen)) {
238 return SNMP_ERR_NOSUCHINSTANCE;
247 snmp_next_oid_init(&
state, row_oid->id, row_oid->len, result_temp,
LWIP_ARRAYSIZE(usmUserTable_oid_ranges));
249 for (
i = 0;
i < snmpv3_get_amount_of_users();
i++) {
252 test_oid[0] = eid_len;
253 snmp_engineid_to_oid(engineid, &test_oid[1], eid_len);
265 if (
state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
266 snmp_oid_assign(row_oid,
state.next_oid,
state.next_oid_len);
270 cell_instance->reference.ptr =
username;
272 return SNMP_ERR_NOERROR;
276 return SNMP_ERR_NOSUCHINSTANCE;
279static s16_t usmusertable_get_value(
struct snmp_node_instance *cell_instance,
void *
value)
281 snmpv3_user_storagetype_t storage_type;
283 switch (SNMP_TABLE_GET_COLUMN_FROM_OID(cell_instance->instance_oid.id)) {
285 MEMCPY(
value, cell_instance->reference.ptr, cell_instance->reference_len);
286 return (
s16_t)cell_instance->reference_len;
288 MEMCPY(
value, snmp_zero_dot_zero.id, snmp_zero_dot_zero.len *
sizeof(
u32_t));
289 return snmp_zero_dot_zero.len *
sizeof(
u32_t);
291 const struct snmp_obj_id *auth_algo;
292 snmpv3_auth_algo_t auth_algo_val;
293 snmpv3_get_user((
const char *)cell_instance->reference.ptr, &auth_algo_val,
NULL,
NULL,
NULL);
294 auth_algo = snmp_auth_algo_to_oid(auth_algo_val);
296 return auth_algo->len *
sizeof(
u32_t);
303 const struct snmp_obj_id *priv_algo;
304 snmpv3_priv_algo_t priv_algo_val;
305 snmpv3_get_user((
const char *)cell_instance->reference.ptr,
NULL,
NULL, &priv_algo_val,
NULL);
306 priv_algo = snmp_priv_algo_to_oid(priv_algo_val);
308 return priv_algo->len *
sizeof(
u32_t);
318 snmpv3_get_user_storagetype((
const char *)cell_instance->reference.ptr, &storage_type);
320 return sizeof(
s32_t);
323 return sizeof(
s32_t);
325 LWIP_DEBUGF(
SNMP_MIB_DEBUG, (
"usmusertable_get_value(): unknown id: %"S32_F"\n", SNMP_TABLE_GET_COLUMN_FROM_OID(cell_instance->instance_oid.id)));
331static s16_t usmstats_scalars_get_value(
const struct snmp_scalar_array_node_def *
node,
void *
value)
336 *uint_ptr = snmp_stats.unsupportedseclevels;
339 *uint_ptr = snmp_stats.notintimewindows;
342 *uint_ptr = snmp_stats.unknownusernames;
345 *uint_ptr = snmp_stats.unknownengineids;
348 *uint_ptr = snmp_stats.wrongdigests;
351 *uint_ptr = snmp_stats.decryptionerrors;
358 return sizeof(*uint_ptr);
365static const struct snmp_table_col_def usmusertable_columns[] = {
366 {3, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY},
367 {4, SNMP_ASN1_TYPE_OBJECT_ID, SNMP_NODE_INSTANCE_READ_ONLY},
368 {5, SNMP_ASN1_TYPE_OBJECT_ID, SNMP_NODE_INSTANCE_READ_ONLY},
369 {6, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY},
370 {7, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY},
371 {8, SNMP_ASN1_TYPE_OBJECT_ID, SNMP_NODE_INSTANCE_READ_ONLY},
372 {9, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY},
373 {10, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY},
374 {11, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY},
375 {12, SNMP_ASN1_TYPE_INTEGER, SNMP_NODE_INSTANCE_READ_ONLY},
376 {13, SNMP_ASN1_TYPE_INTEGER, SNMP_NODE_INSTANCE_READ_ONLY},
378static const struct snmp_table_node usmusertable = SNMP_TABLE_CREATE(2, usmusertable_columns, usmusertable_get_instance, usmusertable_get_next_instance, usmusertable_get_value,
NULL,
NULL);
380static const struct snmp_node *
const usmuser_subnodes[] = {
381 &usmusertable.node.node
383static const struct snmp_tree_node usmuser_treenode = SNMP_CREATE_TREE_NODE(2, usmuser_subnodes);
386static const struct snmp_scalar_array_node_def usmstats_scalars_nodes[] = {
387 {1, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
388 {2, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
389 {3, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
390 {4, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
391 {5, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
392 {6, SNMP_ASN1_TYPE_COUNTER, SNMP_NODE_INSTANCE_READ_ONLY},
394static const struct snmp_scalar_array_node usmstats_scalars = SNMP_SCALAR_CREATE_ARRAY_NODE(1, usmstats_scalars_nodes, usmstats_scalars_get_value,
NULL,
NULL);
396static const struct snmp_node *
const usmmibobjects_subnodes[] = {
397 &usmstats_scalars.node.node,
398 &usmuser_treenode.node
400static const struct snmp_tree_node usmmibobjects_treenode = SNMP_CREATE_TREE_NODE(1, usmmibobjects_subnodes);
403static const struct snmp_node *
const snmpusmmib_subnodes[] = {
404 &usmmibobjects_treenode.node
406static const struct snmp_tree_node snmpusmmib_root = SNMP_CREATE_TREE_NODE(15, snmpusmmib_subnodes);
407static const u32_t snmpusmmib_base_oid[] = {1, 3, 6, 1, 6, 3, 15};
408const struct snmp_mib snmpusmmib = {snmpusmmib_base_oid,
LWIP_ARRAYSIZE(snmpusmmib_base_oid), &snmpusmmib_root.node};
ACPI_SIZE strlen(const char *String)
#define LWIP_ARRAYSIZE(x)
#define LWIP_DEBUGF(debug, message)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define LWIP_PTR_NUMERIC_CAST(target_type, val)
#define LWIP_UNUSED_ARG(x)
#define MEMCPY(DST, SRC, BYTES)