mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +00:00
Several compile fixes for Marco's patch
This commit is contained in:
parent
576a8228c2
commit
78cdbff1b3
@ -1036,7 +1036,7 @@ snmp_parse_inbound_frame(struct snmp_request *request)
|
|||||||
|
|
||||||
// 7) if securitylevel specifies authentication, verify engineboots, enginetime and lastenginetime
|
// 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)) {
|
if ((request->msg_authoritative_engine_boots != boots) || (boots == 2147483647UL)) {
|
||||||
snmp_stats.notintimewindows++;
|
snmp_stats.notintimewindows++;
|
||||||
request->msg_flags = SNMP_V3_AUTHNOPRIV; // authnopriv
|
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) {
|
if (request->msg_authoritative_engine_time > time) {
|
||||||
snmp_stats.notintimewindows++;
|
snmp_stats.notintimewindows++;
|
||||||
request->msg_flags = SNMP_V3_AUTHNOPRIV; // authnopriv
|
request->msg_flags = SNMP_V3_AUTHNOPRIV; // authnopriv
|
||||||
|
@ -93,6 +93,8 @@ static snmp_err_t usmusertable_get_instance(const u32_t *column, const u32_t *ro
|
|||||||
{
|
{
|
||||||
const char *engineid;
|
const char *engineid;
|
||||||
u8_t eid_len;
|
u8_t eid_len;
|
||||||
|
|
||||||
|
LWIP_UNUSED_ARG(column);
|
||||||
|
|
||||||
u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
|
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;
|
const char *engineid;
|
||||||
u8_t eid_len;
|
u8_t eid_len;
|
||||||
|
|
||||||
|
LWIP_UNUSED_ARG(column);
|
||||||
|
|
||||||
u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
|
u32_t engineid_oid[SNMP_V3_MAX_ENGINE_ID_LENGTH];
|
||||||
|
|
||||||
u8_t name_len;
|
u8_t name_len;
|
||||||
@ -297,7 +301,7 @@ static s16_t usmusertable_get_value(struct snmp_node_instance *cell_instance, vo
|
|||||||
case 5: /* usmUserAuthProtocol */
|
case 5: /* usmUserAuthProtocol */
|
||||||
{
|
{
|
||||||
const struct snmp_obj_id *auth_algo;
|
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);
|
auth_algo = snmp_auth_algo_to_oid(u8);
|
||||||
MEMCPY(value, auth_algo->id, auth_algo->len * sizeof(u32_t));
|
MEMCPY(value, auth_algo->id, auth_algo->len * sizeof(u32_t));
|
||||||
return 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 */
|
case 8: /* usmUserPrivProtocol */
|
||||||
{
|
{
|
||||||
const struct snmp_obj_id *priv_algo;
|
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);
|
priv_algo = snmp_priv_algo_to_oid(u8);
|
||||||
MEMCPY(value, priv_algo->id, priv_algo->len * sizeof(u32_t));
|
MEMCPY(value, priv_algo->id, priv_algo->len * sizeof(u32_t));
|
||||||
return 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 */
|
/* TODO: Implement usmUserPublic */
|
||||||
return 0;
|
return 0;
|
||||||
case 12: /* usmUserStorageType */
|
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;
|
*(s32_t*)value = u8;
|
||||||
return sizeof(s32_t);
|
return sizeof(s32_t);
|
||||||
case 13: /* usmUserStatus */
|
case 13: /* usmUserStatus */
|
||||||
|
@ -58,7 +58,7 @@ snmpv3_engine_id_changed(void)
|
|||||||
* (re-)initialized itself since snmpEngineID
|
* (re-)initialized itself since snmpEngineID
|
||||||
* was last configured.
|
* was last configured.
|
||||||
*/
|
*/
|
||||||
u32_t
|
s32_t
|
||||||
snmpv3_get_engine_boots_internal(void)
|
snmpv3_get_engine_boots_internal(void)
|
||||||
{
|
{
|
||||||
if (snmpv3_get_engine_boots() == 0 ||
|
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
|
* Once the timer reaches 2147483647 it gets reset to zero and the
|
||||||
* engine boot ups get incremented.
|
* engine boot ups get incremented.
|
||||||
*/
|
*/
|
||||||
u32_t
|
s32_t
|
||||||
snmpv3_get_engine_time_internal(void)
|
snmpv3_get_engine_time_internal(void)
|
||||||
{
|
{
|
||||||
if (snmpv3_get_engine_time() >= SNMP_MAX_TIME_BOOT) {
|
if (snmpv3_get_engine_time() >= SNMP_MAX_TIME_BOOT) {
|
||||||
|
@ -56,8 +56,8 @@ static struct user_table_entry user_table[] = {
|
|||||||
{ "test", SNMP_V3_AUTH_ALGO_INVAL, "" , SNMP_V3_PRIV_ALGO_INVAL, "" }
|
{ "test", SNMP_V3_AUTH_ALGO_INVAL, "" , SNMP_V3_PRIV_ALGO_INVAL, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static char engineid[32];
|
static char snmpv3_engineid[32];
|
||||||
static u8_t engineid_len;
|
static u8_t snmpv3_engineid_len;
|
||||||
|
|
||||||
static u32_t enginetime = 0;
|
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)
|
void tcpip_enginetime_timer(void *arg)
|
||||||
{
|
{
|
||||||
|
LWIP_UNUSED_ARG(arg);
|
||||||
|
|
||||||
enginetime++;
|
enginetime++;
|
||||||
|
|
||||||
/* This handles the engine time reset */
|
/* This handles the engine time reset */
|
||||||
@ -124,7 +126,8 @@ void tcpip_enginetime_timer(void *arg)
|
|||||||
sys_timeout(1000, tcpip_enginetime_timer, NULL);
|
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);
|
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;
|
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);
|
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;
|
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);
|
struct user_table_entry *p = get_user(username);
|
||||||
const char *engineid;
|
const char *engineid;
|
||||||
@ -190,10 +195,10 @@ err_t snmpv3_set_user_auth_key(const char *username, const char *password)
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
#if LWIP_SNMP_V3_CRYPTO
|
#if LWIP_SNMP_V3_CRYPTO
|
||||||
case SNMP_V3_AUTH_ALGO_MD5:
|
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;
|
return ERR_OK;
|
||||||
case SNMP_V3_AUTH_ALGO_SHA:
|
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;
|
return ERR_OK;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@ -205,7 +210,8 @@ err_t snmpv3_set_user_auth_key(const char *username, const char *password)
|
|||||||
return ERR_VAL;
|
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);
|
struct user_table_entry *p = get_user(username);
|
||||||
const char *engineid;
|
const char *engineid;
|
||||||
@ -221,10 +227,10 @@ err_t snmpv3_set_user_priv_key(const char *username, const char *password)
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
#if LWIP_SNMP_V3_CRYPTO
|
#if LWIP_SNMP_V3_CRYPTO
|
||||||
case SNMP_V3_AUTH_ALGO_MD5:
|
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;
|
return ERR_OK;
|
||||||
case SNMP_V3_AUTH_ALGO_SHA:
|
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;
|
return ERR_OK;
|
||||||
#endif
|
#endif
|
||||||
default:
|
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.
|
* @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) {
|
if (get_user(username) != NULL) {
|
||||||
/* Found user in user table
|
/* 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
|
void
|
||||||
snmpv3_get_engine_id(const char **id, u8_t *len)
|
snmpv3_get_engine_id(const char **id, u8_t *len)
|
||||||
{
|
{
|
||||||
*id = engineid;
|
*id = snmpv3_engineid;
|
||||||
*len = engineid_len;
|
*len = snmpv3_engineid_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -317,8 +324,8 @@ snmpv3_get_engine_id(const char **id, u8_t *len)
|
|||||||
err_t
|
err_t
|
||||||
snmpv3_set_engine_id(const char *id, u8_t len)
|
snmpv3_set_engine_id(const char *id, u8_t len)
|
||||||
{
|
{
|
||||||
MEMCPY(engineid, id, len);
|
MEMCPY(snmpv3_engineid, id, len);
|
||||||
engineid_len = len;
|
snmpv3_engineid_len = len;
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@
|
|||||||
#define SNMP_V3_MD5_LEN 16
|
#define SNMP_V3_MD5_LEN 16
|
||||||
#define SNMP_V3_SHA_LEN 20
|
#define SNMP_V3_SHA_LEN 20
|
||||||
|
|
||||||
u32_t snmpv3_get_engine_boots_internal(void);
|
s32_t snmpv3_get_engine_boots_internal(void);
|
||||||
u32_t snmpv3_get_engine_time_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_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,
|
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);
|
const u8_t* priv_param, const u32_t engine_boots, const u32_t engine_time, u8_t algo, u8_t mode);
|
||||||
|
@ -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_user_storagetype(const char *username, u8_t *storagetype);
|
||||||
err_t snmpv3_get_username(char *username, u8_t index);
|
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 */
|
/* The following functions are provided by the SNMPv3 agent */
|
||||||
|
|
||||||
void snmpv3_engine_id_changed(void);
|
void snmpv3_engine_id_changed(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user