mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 21:35:48 +00:00
Several Win32 compile fixes in SNMP code
This commit is contained in:
parent
83de16678c
commit
0065cd915f
@ -1112,7 +1112,7 @@ snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
this methid is intended if the complete OID is not yet known but it is very expensive to build it up,
|
||||
so it is possible to test the starting part before building up the complete oid and pass it to snmp_next_oid_check()*/
|
||||
u8_t
|
||||
snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len)
|
||||
snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, u8_t oid_len)
|
||||
{
|
||||
if (state->status != SNMP_NEXT_OID_STATUS_BUF_TO_SMALL) {
|
||||
u8_t start_oid_len = (oid_len < state->start_oid_len) ? oid_len : state->start_oid_len;
|
||||
@ -1132,7 +1132,7 @@ snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, cons
|
||||
|
||||
/** checks the passed OID if it is a candidate to be the next one (get_next); returns !=0 if passed oid is currently closest, otherwise 0 */
|
||||
u8_t
|
||||
snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference)
|
||||
snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, u8_t oid_len, void* reference)
|
||||
{
|
||||
/* do not overwrite a fail result */
|
||||
if (state->status != SNMP_NEXT_OID_STATUS_BUF_TO_SMALL) {
|
||||
|
@ -30,37 +30,31 @@ static const struct snmp_oid_range usmUserTable_oid_ranges[] = {
|
||||
{ 0, 0xff }, { 0, 0xff }, { 0, 0xff }, { 0, 0xff }
|
||||
};
|
||||
|
||||
static u8_t snmp_engineid_to_oid(const char *engineid, u32_t *oid, u32_t len)
|
||||
static void snmp_engineid_to_oid(const char *engineid, u32_t *oid, u32_t len)
|
||||
{
|
||||
u8_t i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
oid[i] = engineid[i];
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static u8_t snmp_oid_to_name(char *name, const u32_t *oid, u8_t len)
|
||||
static void snmp_oid_to_name(char *name, const u32_t *oid, size_t len)
|
||||
{
|
||||
u8_t i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
name[i] = oid[i];
|
||||
name[i] = (char)oid[i];
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static u8_t snmp_name_to_oid(const char *name, u32_t *oid, u8_t len)
|
||||
static void snmp_name_to_oid(const char *name, u32_t *oid, size_t len)
|
||||
{
|
||||
u8_t i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
oid[i] = name[i];
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static const struct snmp_obj_id *snmp_auth_algo_to_oid(u8_t algo)
|
||||
@ -94,8 +88,6 @@ static snmp_err_t usmusertable_get_instance(const u32_t *column, const u32_t *ro
|
||||
const char *engineid;
|
||||
u8_t eid_len;
|
||||
|
||||
LWIP_UNUSED_ARG(column);
|
||||
|
||||
u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
|
||||
|
||||
u8_t name_len;
|
||||
@ -104,9 +96,11 @@ static snmp_err_t usmusertable_get_instance(const u32_t *column, const u32_t *ro
|
||||
u8_t name_start;
|
||||
u8_t engineid_start;
|
||||
|
||||
LWIP_UNUSED_ARG(column);
|
||||
|
||||
snmpv3_get_engine_id(&engineid, &eid_len);
|
||||
|
||||
engineid_len = row_oid[0];
|
||||
engineid_len = (u8_t)row_oid[0];
|
||||
engineid_start = 1;
|
||||
|
||||
if (engineid_len != eid_len) {
|
||||
@ -131,7 +125,7 @@ static snmp_err_t usmusertable_get_instance(const u32_t *column, const u32_t *ro
|
||||
return SNMP_ERR_NOSUCHINSTANCE;
|
||||
}
|
||||
|
||||
name_len = row_oid[engineid_start + engineid_len];
|
||||
name_len = (u8_t)row_oid[engineid_start + engineid_len];
|
||||
name_start = engineid_start + engineid_len + 1;
|
||||
|
||||
if (name_len > SNMP_V3_MAX_USER_LENGTH) {
|
||||
@ -180,8 +174,6 @@ static snmp_err_t usmusertable_get_next_instance(const u32_t *column, struct snm
|
||||
const char *engineid;
|
||||
u8_t eid_len;
|
||||
|
||||
LWIP_UNUSED_ARG(column);
|
||||
|
||||
u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
|
||||
|
||||
u8_t name_len;
|
||||
@ -195,11 +187,13 @@ static snmp_err_t usmusertable_get_next_instance(const u32_t *column, struct snm
|
||||
|
||||
u32_t result_temp[LWIP_ARRAYSIZE(usmUserTable_oid_ranges)];
|
||||
|
||||
LWIP_UNUSED_ARG(column);
|
||||
|
||||
snmpv3_get_engine_id(&engineid, &eid_len);
|
||||
|
||||
/* If EngineID might be given */
|
||||
if (row_oid->len > 0) {
|
||||
engineid_len = row_oid->id[0];
|
||||
engineid_len = (u8_t)row_oid->id[0];
|
||||
engineid_start = 1;
|
||||
|
||||
if (engineid_len != eid_len) {
|
||||
@ -226,7 +220,7 @@ static snmp_err_t usmusertable_get_next_instance(const u32_t *column, struct snm
|
||||
|
||||
/* If name might also be given */
|
||||
if (row_oid->len > engineid_start + engineid_len) {
|
||||
name_len = row_oid->id[engineid_start + engineid_len];
|
||||
name_len = (u8_t)row_oid->id[engineid_start + engineid_len];
|
||||
name_start = engineid_start + engineid_len + 1;
|
||||
|
||||
if (name_len > SNMP_V3_MAX_USER_LENGTH) {
|
||||
@ -268,7 +262,7 @@ static snmp_err_t usmusertable_get_next_instance(const u32_t *column, struct snm
|
||||
snmp_name_to_oid(username, &test_oid[2 + eid_len], strlen(username));
|
||||
|
||||
/* check generated OID: is it a candidate for the next one? */
|
||||
snmp_next_oid_check(&state, test_oid, 1 + eid_len + 1 + strlen(username), (void *)(uintptr_t)i);
|
||||
snmp_next_oid_check(&state, test_oid, (u8_t)(1 + eid_len + 1 + strlen(username)), LWIP_PTR_NUMERIC_CAST(void*, i));
|
||||
}
|
||||
|
||||
/* did we find a next one? */
|
||||
@ -276,7 +270,7 @@ static snmp_err_t usmusertable_get_next_instance(const u32_t *column, struct snm
|
||||
snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
|
||||
/* store username for subsequent operations (get/test/set) */
|
||||
memset(username, 0, sizeof(username));
|
||||
snmpv3_get_username(username, (uintptr_t)state.reference);
|
||||
snmpv3_get_username(username, LWIP_PTR_NUMERIC_CAST(u8_t, state.reference));
|
||||
cell_instance->reference.ptr = username;
|
||||
cell_instance->reference_len = strlen(username);
|
||||
return SNMP_ERR_NOERROR;
|
||||
@ -293,7 +287,7 @@ static s16_t usmusertable_get_value(struct snmp_node_instance *cell_instance, vo
|
||||
switch (SNMP_TABLE_GET_COLUMN_FROM_OID(cell_instance->instance_oid.id)) {
|
||||
case 3: /* usmUserSecurityName */
|
||||
MEMCPY(value, cell_instance->reference.ptr, cell_instance->reference_len);
|
||||
return cell_instance->reference_len;
|
||||
return (s16_t)cell_instance->reference_len;
|
||||
break;
|
||||
case 4: /* usmUserCloneFrom */
|
||||
MEMCPY(value, snmp_zero_dot_zero.id, snmp_zero_dot_zero.len * sizeof(u32_t));
|
||||
|
@ -76,12 +76,13 @@ static struct user_table_entry *get_user(const char *username)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < LWIP_ARRAYSIZE(user_table); i++) {
|
||||
if (strnlen(username, 32) != strnlen(user_table[i].username, 32))
|
||||
if (strnlen(username, 32) != strnlen(user_table[i].username, 32)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(username, user_table[i].username, strnlen(username, 32)) == 0) {
|
||||
if (memcmp(username, user_table[i].username, strnlen(username, 32)) == 0) {
|
||||
return &user_table[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -226,7 +226,7 @@ error:
|
||||
void
|
||||
snmpv3_password_to_key_md5(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
size_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength,/* IN - length of snmpEngineID */
|
||||
u8_t *key) /* OUT - pointer to caller 16-octet buffer */
|
||||
@ -279,7 +279,7 @@ snmpv3_password_to_key_md5(
|
||||
void
|
||||
snmpv3_password_to_key_sha(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
size_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength,/* IN - length of snmpEngineID */
|
||||
u8_t *key) /* OUT - pointer to caller 20-octet buffer */
|
||||
|
@ -286,8 +286,8 @@ struct snmp_next_oid_state
|
||||
void snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
const u32_t *start_oid, u8_t start_oid_len,
|
||||
u32_t *next_oid_buf, u8_t next_oid_max_len);
|
||||
u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len);
|
||||
u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference);
|
||||
u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, u8_t oid_len);
|
||||
u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, u8_t oid_len, void* reference);
|
||||
|
||||
void snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
void snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len);
|
||||
|
@ -87,14 +87,14 @@ void snmpv3_engine_id_changed(void);
|
||||
|
||||
void snmpv3_password_to_key_md5(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
size_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength, /* IN - length of snmpEngineID */
|
||||
u8_t *key); /* OUT - pointer to caller 16-octet buffer */
|
||||
|
||||
void snmpv3_password_to_key_sha(
|
||||
const u8_t *password, /* IN */
|
||||
u8_t passwordlen, /* IN */
|
||||
size_t passwordlen, /* IN */
|
||||
const u8_t *engineID, /* IN - pointer to snmpEngineID */
|
||||
u8_t engineLength, /* IN - length of snmpEngineID */
|
||||
u8_t *key); /* OUT - pointer to caller 20-octet buffer */
|
||||
|
Loading…
x
Reference in New Issue
Block a user