mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-12 22:14:25 +00:00
MIB2_STATS: moved netif related mib2 counters into a struct (defined in stats.h), added ifInErrors/ifInUnkownProtos (now handled in etharp.c) and ifOutErrors
This commit is contained in:
parent
dbe703cfb0
commit
94625a8fa8
@ -2141,64 +2141,66 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||
case 10: /* ifInOctets */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifinoctets;
|
||||
*uint_ptr = netif->mib2_counters.ifinoctets;
|
||||
}
|
||||
break;
|
||||
case 11: /* ifInUcastPkts */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifinucastpkts;
|
||||
*uint_ptr = netif->mib2_counters.ifinucastpkts;
|
||||
}
|
||||
break;
|
||||
case 12: /* ifInNUcastPkts */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifinnucastpkts;
|
||||
*uint_ptr = netif->mib2_counters.ifinnucastpkts;
|
||||
}
|
||||
break;
|
||||
case 13: /* ifInDiscarts */
|
||||
case 13: /* ifInDiscards */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifindiscards;
|
||||
*uint_ptr = netif->mib2_counters.ifindiscards;
|
||||
}
|
||||
break;
|
||||
case 14: /* ifInErrors */
|
||||
case 15: /* ifInUnkownProtos */
|
||||
/** @todo add these counters! */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = 0;
|
||||
*uint_ptr = netif->mib2_counters.ifinerrors;
|
||||
}
|
||||
case 15: /* ifInUnkownProtos */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->mib2_counters.ifinunknownprotos;
|
||||
}
|
||||
break;
|
||||
case 16: /* ifOutOctets */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifoutoctets;
|
||||
*uint_ptr = netif->mib2_counters.ifoutoctets;
|
||||
}
|
||||
break;
|
||||
case 17: /* ifOutUcastPkts */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifoutucastpkts;
|
||||
*uint_ptr = netif->mib2_counters.ifoutucastpkts;
|
||||
}
|
||||
break;
|
||||
case 18: /* ifOutNUcastPkts */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifoutnucastpkts;
|
||||
*uint_ptr = netif->mib2_counters.ifoutnucastpkts;
|
||||
}
|
||||
break;
|
||||
case 19: /* ifOutDiscarts */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = netif->ifoutdiscards;
|
||||
*uint_ptr = netif->mib2_counters.ifoutdiscards;
|
||||
}
|
||||
break;
|
||||
case 20: /* ifOutErrors */
|
||||
/** @todo add this counter! */
|
||||
{
|
||||
u32_t *uint_ptr = (u32_t*)value;
|
||||
*uint_ptr = 0;
|
||||
*uint_ptr = netif->mib2_counters.ifouterrors;
|
||||
}
|
||||
break;
|
||||
case 21: /* ifOutQLen */
|
||||
|
@ -42,6 +42,8 @@
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#if LWIP_DHCP
|
||||
struct dhcp;
|
||||
#endif
|
||||
@ -49,7 +51,7 @@ struct dhcp;
|
||||
struct autoip;
|
||||
#endif
|
||||
#if LWIP_IPV6_DHCP6
|
||||
#include "lwip/dhcp6.h"
|
||||
struct dhcp6;
|
||||
#endif /* LWIP_IPV6_DHCP6 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -277,14 +279,7 @@ struct netif {
|
||||
/** timestamp at last change made (up/down) */
|
||||
u32_t ts;
|
||||
/** counters */
|
||||
u32_t ifinoctets;
|
||||
u32_t ifinucastpkts;
|
||||
u32_t ifinnucastpkts;
|
||||
u32_t ifindiscards;
|
||||
u32_t ifoutoctets;
|
||||
u32_t ifoutucastpkts;
|
||||
u32_t ifoutnucastpkts;
|
||||
u32_t ifoutdiscards;
|
||||
struct stats_mib2_netif_ctrs mib2_counters;
|
||||
#endif /* MIB2_STATS */
|
||||
#if LWIP_IPV4 && LWIP_IGMP
|
||||
/** This function could be called to add or delete an entry in the multicast
|
||||
|
@ -93,8 +93,8 @@ enum snmp_ifType {
|
||||
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10))
|
||||
#endif
|
||||
|
||||
#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->x; } while(0)
|
||||
#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->x += val; } while(0)
|
||||
#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0)
|
||||
#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0)
|
||||
|
||||
#define MIB2_INIT_NETIF(netif, type, speed) do { \
|
||||
/* use "snmp_ifType" enum from snmp_mib2.h for "type", snmp_ifType_ethernet_csmacd by example */ \
|
||||
@ -102,14 +102,17 @@ enum snmp_ifType {
|
||||
/* your link speed here (units: bits per second) */ \
|
||||
(netif)->link_speed = (speed);\
|
||||
(netif)->ts = 0; \
|
||||
(netif)->ifinoctets = 0; \
|
||||
(netif)->ifinucastpkts = 0; \
|
||||
(netif)->ifinnucastpkts = 0; \
|
||||
(netif)->ifindiscards = 0; \
|
||||
(netif)->ifoutoctets = 0; \
|
||||
(netif)->ifoutucastpkts = 0; \
|
||||
(netif)->ifoutnucastpkts = 0; \
|
||||
(netif)->ifoutdiscards = 0; } while(0)
|
||||
(netif)->mib2_counters.ifinoctets = 0; \
|
||||
(netif)->mib2_counters.ifinucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifinnucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifindiscards = 0; \
|
||||
(netif)->mib2_counters.ifinerrors = 0; \
|
||||
(netif)->mib2_counters.ifinunknownprotos = 0; \
|
||||
(netif)->mib2_counters.ifoutoctets = 0; \
|
||||
(netif)->mib2_counters.ifoutucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifoutnucastpkts = 0; \
|
||||
(netif)->mib2_counters.ifoutdiscards = 0; \
|
||||
(netif)->mib2_counters.ifouterrors = 0; } while(0)
|
||||
#else /* MIB2_STATS */
|
||||
#ifndef MIB2_COPY_SYSUPTIME_TO
|
||||
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal)
|
||||
@ -173,10 +176,13 @@ void mib2_udp_unbind(struct udp_pcb *pcb);
|
||||
#define snmp_inc_ifinucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinucastpkts)
|
||||
#define snmp_inc_ifinnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinnucastpkts)
|
||||
#define snmp_inc_ifindiscards(ni) MIB2_STATS_NETIF_INC(ni, ifindiscards)
|
||||
#define snmp_inc_ifinerrors(ni) MIB2_STATS_NETIF_INC(ni, ifinerrors)
|
||||
#define snmp_inc_ifinunknownprotos(ni) MIB2_STATS_NETIF_INC(ni, ifinunknownprotos)
|
||||
#define snmp_add_ifoutoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifoutoctets, value)
|
||||
#define snmp_inc_ifoutucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutucastpkts)
|
||||
#define snmp_inc_ifoutnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutnucastpkts)
|
||||
#define snmp_inc_ifoutdiscards(ni) MIB2_STATS_NETIF_INC(ni, ifoutdiscards)
|
||||
#define snmp_inc_ifouterrors(ni) MIB2_STATS_NETIF_INC(ni, ifouterrors)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -176,6 +176,20 @@ struct stats_mib2 {
|
||||
u32_t icmpoutaddrmaskreps; /* @todo: never incremented */
|
||||
};
|
||||
|
||||
struct stats_mib2_netif_ctrs {
|
||||
u32_t ifinoctets;
|
||||
u32_t ifinucastpkts;
|
||||
u32_t ifinnucastpkts;
|
||||
u32_t ifindiscards;
|
||||
u32_t ifinerrors;
|
||||
u32_t ifinunknownprotos;
|
||||
u32_t ifoutoctets;
|
||||
u32_t ifoutucastpkts;
|
||||
u32_t ifoutnucastpkts;
|
||||
u32_t ifoutdiscards;
|
||||
u32_t ifouterrors;
|
||||
};
|
||||
|
||||
struct stats_ {
|
||||
#if LINK_STATS
|
||||
struct stats_proto link;
|
||||
|
@ -1395,6 +1395,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
||||
/* a packet with only an ethernet header (or less) is not valid for us */
|
||||
ETHARP_STATS_INC(etharp.proterr);
|
||||
ETHARP_STATS_INC(etharp.drop);
|
||||
MIB2_STATS_NETIF_INC(netif, ifinerrors);
|
||||
goto free_and_return;
|
||||
}
|
||||
|
||||
@ -1416,6 +1417,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
||||
/* a packet with only an ethernet/vlan header (or less) is not valid for us */
|
||||
ETHARP_STATS_INC(etharp.proterr);
|
||||
ETHARP_STATS_INC(etharp.drop);
|
||||
MIB2_STATS_NETIF_INC(netif, ifinerrors);
|
||||
goto free_and_return;
|
||||
}
|
||||
#if defined(LWIP_HOOK_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) /* if not, allow all VLANs */
|
||||
@ -1514,6 +1516,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
||||
default:
|
||||
ETHARP_STATS_INC(etharp.proterr);
|
||||
ETHARP_STATS_INC(etharp.drop);
|
||||
MIB2_STATS_NETIF_INC(netif, ifinunknownprotos);
|
||||
goto free_and_return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user