Several compile fixes for Marco's patch

This commit is contained in:
Dirk Ziegelmeier 2017-03-01 20:17:22 +01:00
parent 576a8228c2
commit 78cdbff1b3
6 changed files with 40 additions and 24 deletions

View File

@ -1036,7 +1036,7 @@ snmp_parse_inbound_frame(struct snmp_request *request)
// 7) if securitylevel specifies authentication, verify engineboots, enginetime and lastenginetime
{
u32_t boots = snmpv3_get_engine_boots_internal();
s32_t boots = snmpv3_get_engine_boots_internal();
if ((request->msg_authoritative_engine_boots != boots) || (boots == 2147483647UL)) {
snmp_stats.notintimewindows++;
request->msg_flags = SNMP_V3_AUTHNOPRIV; // authnopriv
@ -1045,7 +1045,7 @@ snmp_parse_inbound_frame(struct snmp_request *request)
}
}
{
u32_t time = snmpv3_get_engine_time_internal();
s32_t time = snmpv3_get_engine_time_internal();
if (request->msg_authoritative_engine_time > time) {
snmp_stats.notintimewindows++;
request->msg_flags = SNMP_V3_AUTHNOPRIV; // authnopriv

View File

@ -93,6 +93,8 @@ 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];
@ -178,6 +180,8 @@ 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;
@ -297,7 +301,7 @@ static s16_t usmusertable_get_value(struct snmp_node_instance *cell_instance, vo
case 5: /* usmUserAuthProtocol */
{
const struct snmp_obj_id *auth_algo;
snmpv3_get_user(cell_instance->reference.ptr, &u8, NULL, NULL, NULL);
snmpv3_get_user((const char*)cell_instance->reference.ptr, &u8, NULL, NULL, NULL);
auth_algo = snmp_auth_algo_to_oid(u8);
MEMCPY(value, auth_algo->id, auth_algo->len * sizeof(u32_t));
return auth_algo->len * sizeof(u32_t);
@ -309,7 +313,7 @@ static s16_t usmusertable_get_value(struct snmp_node_instance *cell_instance, vo
case 8: /* usmUserPrivProtocol */
{
const struct snmp_obj_id *priv_algo;
snmpv3_get_user(cell_instance->reference.ptr, NULL, NULL, &u8, NULL);
snmpv3_get_user((const char*)cell_instance->reference.ptr, NULL, NULL, &u8, NULL);
priv_algo = snmp_priv_algo_to_oid(u8);
MEMCPY(value, priv_algo->id, priv_algo->len * sizeof(u32_t));
return priv_algo->len * sizeof(u32_t);
@ -322,7 +326,7 @@ static s16_t usmusertable_get_value(struct snmp_node_instance *cell_instance, vo
/* TODO: Implement usmUserPublic */
return 0;
case 12: /* usmUserStorageType */
snmpv3_get_user_storagetype(cell_instance->reference.ptr, &u8);
snmpv3_get_user_storagetype((const char*)cell_instance->reference.ptr, &u8);
*(s32_t*)value = u8;
return sizeof(s32_t);
case 13: /* usmUserStatus */

View File

@ -58,7 +58,7 @@ snmpv3_engine_id_changed(void)
* (re-)initialized itself since snmpEngineID
* was last configured.
*/
u32_t
s32_t
snmpv3_get_engine_boots_internal(void)
{
if (snmpv3_get_engine_boots() == 0 ||
@ -75,7 +75,7 @@ snmpv3_get_engine_boots_internal(void)
* Once the timer reaches 2147483647 it gets reset to zero and the
* engine boot ups get incremented.
*/
u32_t
s32_t
snmpv3_get_engine_time_internal(void)
{
if (snmpv3_get_engine_time() >= SNMP_MAX_TIME_BOOT) {

View File

@ -56,8 +56,8 @@ static struct user_table_entry user_table[] = {
{ "test", SNMP_V3_AUTH_ALGO_INVAL, "" , SNMP_V3_PRIV_ALGO_INVAL, "" }
};
static char engineid[32];
static u8_t engineid_len;
static char snmpv3_engineid[32];
static u8_t snmpv3_engineid_len;
static u32_t enginetime = 0;
@ -115,6 +115,8 @@ err_t snmpv3_get_username(char *username, u8_t index)
*/
void tcpip_enginetime_timer(void *arg)
{
LWIP_UNUSED_ARG(arg);
enginetime++;
/* This handles the engine time reset */
@ -124,7 +126,8 @@ void tcpip_enginetime_timer(void *arg)
sys_timeout(1000, tcpip_enginetime_timer, NULL);
}
err_t snmpv3_set_user_auth_algo(const char *username, u8_t algo)
err_t
snmpv3_set_user_auth_algo(const char *username, u8_t algo)
{
struct user_table_entry *p = get_user(username);
@ -149,7 +152,8 @@ err_t snmpv3_set_user_auth_algo(const char *username, u8_t algo)
return ERR_VAL;
}
err_t snmpv3_set_user_priv_algo(const char *username, u8_t algo)
err_t
snmpv3_set_user_priv_algo(const char *username, u8_t algo)
{
struct user_table_entry *p = get_user(username);
@ -174,7 +178,8 @@ err_t snmpv3_set_user_priv_algo(const char *username, u8_t algo)
return ERR_VAL;
}
err_t snmpv3_set_user_auth_key(const char *username, const char *password)
err_t
snmpv3_set_user_auth_key(const char *username, const char *password)
{
struct user_table_entry *p = get_user(username);
const char *engineid;
@ -190,10 +195,10 @@ err_t snmpv3_set_user_auth_key(const char *username, const char *password)
return ERR_OK;
#if LWIP_SNMP_V3_CRYPTO
case SNMP_V3_AUTH_ALGO_MD5:
snmpv3_password_to_key_md5((u8_t*)password, strlen(password), (u8_t*)engineid, engineid_len, p->auth_key);
snmpv3_password_to_key_md5((const u8_t*)password, strlen(password), (const u8_t*)engineid, engineid_len, p->auth_key);
return ERR_OK;
case SNMP_V3_AUTH_ALGO_SHA:
snmpv3_password_to_key_sha((u8_t*)password, strlen(password), (u8_t*)engineid, engineid_len, p->auth_key);
snmpv3_password_to_key_sha((const u8_t*)password, strlen(password), (const u8_t*)engineid, engineid_len, p->auth_key);
return ERR_OK;
#endif
default:
@ -205,7 +210,8 @@ err_t snmpv3_set_user_auth_key(const char *username, const char *password)
return ERR_VAL;
}
err_t snmpv3_set_user_priv_key(const char *username, const char *password)
err_t
snmpv3_set_user_priv_key(const char *username, const char *password)
{
struct user_table_entry *p = get_user(username);
const char *engineid;
@ -221,10 +227,10 @@ err_t snmpv3_set_user_priv_key(const char *username, const char *password)
return ERR_OK;
#if LWIP_SNMP_V3_CRYPTO
case SNMP_V3_AUTH_ALGO_MD5:
snmpv3_password_to_key_md5((u8_t*)password, strlen(password), (u8_t*)engineid, engineid_len, p->priv_key);
snmpv3_password_to_key_md5((const u8_t*)password, strlen(password), (const u8_t*)engineid, engineid_len, p->priv_key);
return ERR_OK;
case SNMP_V3_AUTH_ALGO_SHA:
snmpv3_password_to_key_sha((u8_t*)password, strlen(password), (u8_t*)engineid, engineid_len, p->priv_key);
snmpv3_password_to_key_sha((const u8_t*)password, strlen(password), (const u8_t*)engineid, engineid_len, p->priv_key);
return ERR_OK;
#endif
default:
@ -244,7 +250,8 @@ err_t snmpv3_set_user_priv_key(const char *username, const char *password)
*
* @return ERR_OK if the user was found, ERR_VAL if not.
*/
err_t snmpv3_get_user_storagetype(const char *username, u8_t *type)
err_t
snmpv3_get_user_storagetype(const char *username, u8_t *type)
{
if (get_user(username) != NULL) {
/* Found user in user table
@ -305,8 +312,8 @@ snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *pri
void
snmpv3_get_engine_id(const char **id, u8_t *len)
{
*id = engineid;
*len = engineid_len;
*id = snmpv3_engineid;
*len = snmpv3_engineid_len;
}
/**
@ -317,8 +324,8 @@ snmpv3_get_engine_id(const char **id, u8_t *len)
err_t
snmpv3_set_engine_id(const char *id, u8_t len)
{
MEMCPY(engineid, id, len);
engineid_len = len;
MEMCPY(snmpv3_engineid, id, len);
snmpv3_engineid_len = len;
return ERR_OK;
}

View File

@ -59,8 +59,8 @@
#define SNMP_V3_MD5_LEN 16
#define SNMP_V3_SHA_LEN 20
u32_t snmpv3_get_engine_boots_internal(void);
u32_t snmpv3_get_engine_time_internal(void);
s32_t snmpv3_get_engine_boots_internal(void);
s32_t snmpv3_get_engine_time_internal(void);
err_t snmpv3_auth(struct snmp_pbuf_stream* stream, u16_t length, const u8_t* key, u8_t algo, u8_t* hmac_out);
err_t snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, const u8_t* key,
const u8_t* priv_param, const u32_t engine_boots, const u32_t engine_time, u8_t algo, u8_t mode);

View File

@ -76,6 +76,11 @@ u8_t snmpv3_get_amount_of_users(void);
err_t snmpv3_get_user_storagetype(const char *username, u8_t *storagetype);
err_t snmpv3_get_username(char *username, u8_t index);
err_t snmpv3_set_user_auth_algo(const char *username, u8_t algo);
err_t snmpv3_set_user_priv_algo(const char *username, u8_t algo);
err_t snmpv3_set_user_auth_key(const char *username, const char *password);
err_t snmpv3_set_user_priv_key(const char *username, const char *password);
/* The following functions are provided by the SNMPv3 agent */
void snmpv3_engine_id_changed(void);