mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-30 12:32:37 +00:00
Patch #6215: added ifAdminStatus write support (if explicitly enabled by defining SNMP_SAFE_REQUESTS to 0); added code to check link status for ifOperStatus if LWIP_NETIF_LINK_CALLBACK is defined.
This commit is contained in:
parent
f3dbd986cb
commit
bfe24b138d
@ -19,6 +19,11 @@ HISTORY
|
||||
|
||||
++ New features:
|
||||
|
||||
2007-11-06 Simon Goldschmidt
|
||||
* opt.h, mib2.c: Patch #6215: added ifAdminStatus write support (if explicitly
|
||||
enabled by defining SNMP_SAFE_REQUESTS to 0); added code to check link status
|
||||
for ifOperStatus if LWIP_NETIF_LINK_CALLBACK is defined.
|
||||
|
||||
2007-11-06 Simon Goldschmidt
|
||||
* api.h, api_msg.h and dependent files: Task #7410: Removed the need to include
|
||||
core header files in api.h (ip/tcp/udp/raw.h) to hide the internal
|
||||
|
@ -82,6 +82,10 @@ static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_d
|
||||
static void interfaces_get_value(struct obj_def *od, u16_t len, void *value);
|
||||
static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
|
||||
static void ifentry_get_value(struct obj_def *od, u16_t len, void *value);
|
||||
#if !SNMP_SAFE_REQUESTS
|
||||
static u8_t ifentry_set_test (struct obj_def *od, u16_t len, void *value);
|
||||
static void ifentry_set_value (struct obj_def *od, u16_t len, void *value);
|
||||
#endif /* SNMP_SAFE_REQUESTS */
|
||||
static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
|
||||
static void atentry_get_value(struct obj_def *od, u16_t len, void *value);
|
||||
static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
|
||||
@ -563,8 +567,13 @@ struct mib_ram_array_node at = {
|
||||
struct mib_list_rootnode iflist_root = {
|
||||
&ifentry_get_object_def,
|
||||
&ifentry_get_value,
|
||||
#if SNMP_SAFE_REQUESTS
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
#else /* SNMP_SAFE_REQUESTS */
|
||||
&ifentry_set_test,
|
||||
&ifentry_set_value,
|
||||
#endif /* SNMP_SAFE_REQUESTS */
|
||||
MIB_NODE_LR,
|
||||
0,
|
||||
NULL,
|
||||
@ -2486,6 +2495,27 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
ocstrncpy(value,netif->hwaddr,len);
|
||||
break;
|
||||
case 7: /* ifAdminStatus */
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
{
|
||||
s32_t *sint_ptr = value;
|
||||
if (netif_is_up(netif))
|
||||
{
|
||||
if (netif_is_link_up(netif))
|
||||
{
|
||||
*sint_ptr = 1; // up
|
||||
}
|
||||
else
|
||||
{
|
||||
*sint_ptr = 7; // lowerLayerDown
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*sint_ptr = 2; // down
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 8: /* ifOperStatus */
|
||||
{
|
||||
s32_t *sint_ptr = value;
|
||||
@ -2581,6 +2611,56 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
};
|
||||
}
|
||||
|
||||
#if !SNMP_SAFE_REQUESTS
|
||||
static u8_t
|
||||
ifentry_set_test (struct obj_def *od, u16_t len, void *value)
|
||||
{
|
||||
struct netif *netif;
|
||||
u8_t id, set_ok;
|
||||
|
||||
set_ok = 0;
|
||||
snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
|
||||
id = od->id_inst_ptr[0];
|
||||
switch (id)
|
||||
{
|
||||
case 7: /* ifAdminStatus */
|
||||
{
|
||||
s32_t *sint_ptr = value;
|
||||
if (*sint_ptr == 1 || *sint_ptr == 2)
|
||||
set_ok = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return set_ok;
|
||||
}
|
||||
|
||||
static void
|
||||
ifentry_set_value (struct obj_def *od, u16_t len, void *value)
|
||||
{
|
||||
struct netif *netif;
|
||||
u8_t id;
|
||||
|
||||
snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
|
||||
id = od->id_inst_ptr[0];
|
||||
switch (id)
|
||||
{
|
||||
case 7: /* ifAdminStatus */
|
||||
{
|
||||
s32_t *sint_ptr = value;
|
||||
if (*sint_ptr == 1)
|
||||
{
|
||||
netif_set_up(netif);
|
||||
}
|
||||
else if (*sint_ptr == 2)
|
||||
{
|
||||
netif_set_down(netif);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* SNMP_SAFE_REQUESTS */
|
||||
|
||||
/**
|
||||
* Returns atentry object definitions.
|
||||
*
|
||||
|
@ -525,6 +525,15 @@
|
||||
#define SNMP_PRIVATE_MIB 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only allow SNMP write actions that are 'safe' (e.g. disabeling netifs is not
|
||||
* a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
|
||||
* Unsafe requests are disabled by default!
|
||||
*/
|
||||
#ifndef SNMP_SAFE_REQUESTS
|
||||
#define SNMP_SAFE_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- IGMP options ----------
|
||||
|
Loading…
x
Reference in New Issue
Block a user