Document SNMP MIB2 netif stats counters

This commit is contained in:
Dirk Ziegelmeier 2016-07-31 16:02:22 +02:00
parent d00609257b
commit e76b8b2551
3 changed files with 38 additions and 15 deletions

View File

@ -2083,6 +2083,7 @@ PREDEFINED = __DOXYGEN__=1 \
LWIP_SNMP=1 \
SNMP_USE_NETCONN=1 \
SNMP_USE_RAW=1 \
MIB2_STATS=1 \
MEMP_OVERFLOW_CHECK=0 \
MEMP_SANITY_CHECK=1 \
LWIP_ARP=1 \

View File

@ -47,9 +47,15 @@ extern "C" {
struct udp_pcb;
struct netif;
/**
* @defgroup netif_mib2 MIB2 statistics
* @ingroup netif
*/
/* MIB2 statistics functions */
#if MIB2_STATS /* don't build if not configured for use in lwipopts.h */
/**
* @ingroup netif_mib2
* @see RFC1213, "MIB-II, 6. Definitions"
*/
enum snmp_ifType {
@ -87,18 +93,31 @@ enum snmp_ifType {
snmp_ifType_frame_relay
};
/** This macro has a precision of ~49 days because sys_now returns u32_t. #define your own if you want ~490 days. */
/** This macro has a precision of ~49 days because sys_now returns u32_t. \#define your own if you want ~490 days. */
#ifndef MIB2_COPY_SYSUPTIME_TO
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10))
#endif
/**
* @ingroup netif_mib2
* Increment stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs)
*/
#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0)
/**
* @ingroup netif_mib2
* Add value to stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs)
*/
#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0)
/**
* @ingroup netif_mib2
* Init MIB2 statistic counters in netif
* @param netif Netif to init
* @param type one of enum @ref snmp_ifType
* @param speed your link speed here (units: bits per second)
*/
#define MIB2_INIT_NETIF(netif, type, speed) do { \
/* use "snmp_ifType" enum from snmp_mib2.h for "type", snmp_ifType_ethernet_csmacd by example */ \
(netif)->link_type = (type); \
/* your link speed here (units: bits per second) */ \
(netif)->link_speed = (speed);\
(netif)->ts = 0; \
(netif)->mib2_counters.ifinoctets = 0; \

View File

@ -179,47 +179,50 @@ struct stats_mib2 {
u32_t icmpoutechoreps;
};
/** SNMP MIB2 interface stats */
/**
* @ingroup netif_mib2
* SNMP MIB2 interface stats
*/
struct stats_mib2_netif_ctrs {
/* The total number of octets received on the interface, including framing characters */
/** The total number of octets received on the interface, including framing characters */
u32_t ifinoctets;
/* The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
/** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
* not addressed to a multicast or broadcast address at this sub-layer */
u32_t ifinucastpkts;
/* The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
/** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were
* addressed to a multicast or broadcast address at this sub-layer */
u32_t ifinnucastpkts;
/* The number of inbound packets which were chosen to be discarded even though no errors had
/** The number of inbound packets which were chosen to be discarded even though no errors had
* been detected to prevent their being deliverable to a higher-layer protocol. One possible
* reason for discarding such a packet could be to free up buffer space */
u32_t ifindiscards;
/* For packet-oriented interfaces, the number of inbound packets that contained errors
/** For packet-oriented interfaces, the number of inbound packets that contained errors
* preventing them from being deliverable to a higher-layer protocol. For character-
* oriented or fixed-length interfaces, the number of inbound transmission units that
* contained errors preventing them from being deliverable to a higher-layer protocol. */
u32_t ifinerrors;
/* For packet-oriented interfaces, the number of packets received via the interface which
/** For packet-oriented interfaces, the number of packets received via the interface which
* were discarded because of an unknown or unsupported protocol. For character-oriented
* or fixed-length interfaces that support protocol multiplexing the number of transmission
* units received via the interface which were discarded because of an unknown or unsupported
* protocol. For any interface that does not support protocol multiplexing, this counter will
* always be 0 */
u32_t ifinunknownprotos;
/* The total number of octets transmitted out of the interface, including framing characters. */
/** The total number of octets transmitted out of the interface, including framing characters. */
u32_t ifoutoctets;
/* The total number of packets that higher-level protocols requested be transmitted, and
/** The total number of packets that higher-level protocols requested be transmitted, and
* which were not addressed to a multicast or broadcast address at this sub-layer, including
* those that were discarded or not sent. */
u32_t ifoutucastpkts;
/* The total number of packets that higher-level protocols requested be transmitted, and which
/** The total number of packets that higher-level protocols requested be transmitted, and which
* were addressed to a multicast or broadcast address at this sub-layer, including
* those that were discarded or not sent. */
u32_t ifoutnucastpkts;
/* The number of outbound packets which were chosen to be discarded even though no errors had
/** The number of outbound packets which were chosen to be discarded even though no errors had
* been detected to prevent their being transmitted. One possible reason for discarding
* such a packet could be to free up buffer space. */
u32_t ifoutdiscards;
/* For packet-oriented interfaces, the number of outbound packets that could not be transmitted
/** For packet-oriented interfaces, the number of outbound packets that could not be transmitted
* because of errors. For character-oriented or fixed-length interfaces, the number of outbound
* transmission units that could not be transmitted because of errors. */
u32_t ifouterrors;