mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-20 15:17:05 +08:00
Separate mib2 counter/table callbacks from snmp agent. This both cleans up the code and should allow integration of a 3rd party agent/mib2.
This commit is contained in:
@@ -270,8 +270,8 @@ struct netif {
|
||||
char name[2];
|
||||
/** number of this interface */
|
||||
u8_t num;
|
||||
#if LWIP_SNMP
|
||||
/** link type (from "snmp_ifType" enum from snmp.h) */
|
||||
#if MIB2_STATS
|
||||
/** link type (from "snmp_ifType" enum from snmp_mib2.h) */
|
||||
u8_t link_type;
|
||||
/** (estimate) link speed */
|
||||
u32_t link_speed;
|
||||
@@ -280,13 +280,13 @@ struct netif {
|
||||
/** counters */
|
||||
u32_t ifinoctets;
|
||||
u32_t ifinucastpkts;
|
||||
u32_t ifinnucastpkts;
|
||||
u32_t ifinnucastpkts; /* @todo: never incremented */
|
||||
u32_t ifindiscards;
|
||||
u32_t ifoutoctets;
|
||||
u32_t ifoutucastpkts;
|
||||
u32_t ifoutnucastpkts;
|
||||
u32_t ifoutdiscards;
|
||||
#endif /* LWIP_SNMP */
|
||||
#endif /* MIB2_STATS */
|
||||
#if LWIP_IPV4 && LWIP_IGMP
|
||||
/** This function could be called to add or delete an entry in the multicast
|
||||
filter table of the ethernet MAC.*/
|
||||
@@ -319,26 +319,6 @@ struct netif {
|
||||
#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
|
||||
#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */
|
||||
|
||||
#if LWIP_SNMP
|
||||
#define NETIF_INIT_SNMP(netif, type, speed) do { \
|
||||
/* use "snmp_ifType" enum from snmp.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)->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)
|
||||
#else /* LWIP_SNMP */
|
||||
#define NETIF_INIT_SNMP(netif, type, speed)
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
|
||||
/** The list of network interfaces. */
|
||||
extern struct netif *netif_list;
|
||||
/** The default network interface. */
|
||||
|
||||
@@ -865,13 +865,26 @@
|
||||
----------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP
|
||||
* transport.
|
||||
* LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available
|
||||
* for SNMP transport.
|
||||
* If you want to use your own SNMP agent, leave this disabled.
|
||||
* To integrate MIB2 of an external agent, you need to enable
|
||||
* LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks
|
||||
* and statistics counters you need to get MIB2 working.
|
||||
*/
|
||||
#ifndef LWIP_SNMP
|
||||
#define LWIP_SNMP 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_MIB2_CALLBACKS==1: Turn on SNMP MIB2 callbacks.
|
||||
* Turn this on to get callbacks needed to implement MIB2.
|
||||
* Usually MIB2_STATS should be enabled, too.
|
||||
*/
|
||||
#ifndef LWIP_MIB2_CALLBACKS
|
||||
#define LWIP_MIB2_CALLBACKS LWIP_SNMP
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will
|
||||
* allow. At least one request buffer is required.
|
||||
@@ -1027,9 +1040,8 @@
|
||||
* byte order).
|
||||
*
|
||||
* Instead, you can also use an external function:
|
||||
* #define DNS_LOOKUP_LOCAL_EXTERN(x) extern int my_lookup_function(const char *name, ip_addr_t* result, u8_t reqtype)
|
||||
* that provides the IP address, returns 1 if found or 0 if not found and gets
|
||||
* the type of the requested address passed (see LWIP_DNS_ADDRTYPE_*)
|
||||
* #define DNS_LOOKUP_LOCAL_EXTERN(x) extern u32_t my_lookup_function(const char *name)
|
||||
* that returns the IP address or INADDR_NONE if not found.
|
||||
*/
|
||||
#ifndef DNS_LOCAL_HOSTLIST
|
||||
#define DNS_LOCAL_HOSTLIST 0
|
||||
@@ -1904,6 +1916,13 @@
|
||||
#define ND6_STATS (LWIP_IPV6)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MIB2_STATS==1: Stats for SNMP MIB2.
|
||||
*/
|
||||
#ifndef MIB2_STATS
|
||||
#define MIB2_STATS (LWIP_SNMP)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define LINK_STATS 0
|
||||
@@ -1923,6 +1942,7 @@
|
||||
#define IP6_FRAG_STATS 0
|
||||
#define MLD6_STATS 0
|
||||
#define ND6_STATS 0
|
||||
#define MIB2_STATS 0
|
||||
|
||||
#endif /* LWIP_STATS */
|
||||
|
||||
|
||||
@@ -34,59 +34,14 @@
|
||||
#define LWIP_HDR_SNMP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/snmp_mib2.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
struct udp_pcb;
|
||||
struct netif;
|
||||
|
||||
/**
|
||||
* @see RFC1213, "MIB-II, 6. Definitions"
|
||||
*/
|
||||
enum snmp_ifType {
|
||||
snmp_ifType_other=1, /* none of the following */
|
||||
snmp_ifType_regular1822,
|
||||
snmp_ifType_hdh1822,
|
||||
snmp_ifType_ddn_x25,
|
||||
snmp_ifType_rfc877_x25,
|
||||
snmp_ifType_ethernet_csmacd,
|
||||
snmp_ifType_iso88023_csmacd,
|
||||
snmp_ifType_iso88024_tokenBus,
|
||||
snmp_ifType_iso88025_tokenRing,
|
||||
snmp_ifType_iso88026_man,
|
||||
snmp_ifType_starLan,
|
||||
snmp_ifType_proteon_10Mbit,
|
||||
snmp_ifType_proteon_80Mbit,
|
||||
snmp_ifType_hyperchannel,
|
||||
snmp_ifType_fddi,
|
||||
snmp_ifType_lapb,
|
||||
snmp_ifType_sdlc,
|
||||
snmp_ifType_ds1, /* T-1 */
|
||||
snmp_ifType_e1, /* european equiv. of T-1 */
|
||||
snmp_ifType_basicISDN,
|
||||
snmp_ifType_primaryISDN, /* proprietary serial */
|
||||
snmp_ifType_propPointToPointSerial,
|
||||
snmp_ifType_ppp,
|
||||
snmp_ifType_softwareLoopback,
|
||||
snmp_ifType_eon, /* CLNP over IP [11] */
|
||||
snmp_ifType_ethernet_3Mbit,
|
||||
snmp_ifType_nsip, /* XNS over IP */
|
||||
snmp_ifType_slip, /* generic SLIP */
|
||||
snmp_ifType_ultra, /* ULTRA technologies */
|
||||
snmp_ifType_ds3, /* T-3 */
|
||||
snmp_ifType_sip, /* SMDS */
|
||||
snmp_ifType_frame_relay
|
||||
};
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/** SNMP "sysuptime" Interval */
|
||||
#define SNMP_SYSUPTIME_INTERVAL 10
|
||||
|
||||
/** fixed maximum length for object identifier type */
|
||||
#define LWIP_SNMP_OBJ_ID_LEN 32
|
||||
|
||||
@@ -110,268 +65,22 @@ void snmp_set_community_trap(const char * const community);
|
||||
void snmp_set_sysdescr(const u8_t* str, const u8_t* len);
|
||||
void snmp_set_sysobjid(const struct snmp_obj_id *oid);
|
||||
void snmp_get_sysobjid_ptr(const struct snmp_obj_id **oid);
|
||||
void snmp_inc_sysuptime(void);
|
||||
void snmp_add_sysuptime(u32_t value);
|
||||
void snmp_get_sysuptime(u32_t *value);
|
||||
void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen, u8_t bufsize);
|
||||
void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen, u8_t bufsize);
|
||||
void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen, u8_t bufsize);
|
||||
|
||||
/* network interface */
|
||||
void snmp_add_ifinoctets(struct netif *ni, u32_t value);
|
||||
void snmp_inc_ifinucastpkts(struct netif *ni);
|
||||
void snmp_inc_ifinnucastpkts(struct netif *ni);
|
||||
void snmp_inc_ifindiscards(struct netif *ni);
|
||||
void snmp_add_ifoutoctets(struct netif *ni, u32_t value);
|
||||
void snmp_inc_ifoutucastpkts(struct netif *ni);
|
||||
void snmp_inc_ifoutnucastpkts(struct netif *ni);
|
||||
void snmp_inc_ifoutdiscards(struct netif *ni);
|
||||
void snmp_inc_iflist(void);
|
||||
void snmp_dec_iflist(void);
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ARP
|
||||
/* ARP (for atTable and ipNetToMediaTable) */
|
||||
void snmp_insert_arpidx_tree(struct netif *ni, ip4_addr_t *ip);
|
||||
void snmp_delete_arpidx_tree(struct netif *ni, ip4_addr_t *ip);
|
||||
#else /* LWIP_IPV4 && LWIP_ARP */
|
||||
#define snmp_insert_arpidx_tree(ni,ip)
|
||||
#define snmp_delete_arpidx_tree(ni,ip)
|
||||
#endif /* LWIP_IPV4 && LWIP_ARP */
|
||||
|
||||
/* IP */
|
||||
void snmp_inc_ipinreceives(void);
|
||||
void snmp_inc_ipinhdrerrors(void);
|
||||
void snmp_inc_ipinaddrerrors(void);
|
||||
void snmp_inc_ipforwdatagrams(void);
|
||||
void snmp_inc_ipinunknownprotos(void);
|
||||
void snmp_inc_ipindiscards(void);
|
||||
void snmp_inc_ipindelivers(void);
|
||||
void snmp_inc_ipoutrequests(void);
|
||||
void snmp_inc_ipoutdiscards(void);
|
||||
void snmp_inc_ipoutnoroutes(void);
|
||||
void snmp_inc_ipreasmreqds(void);
|
||||
void snmp_inc_ipreasmoks(void);
|
||||
void snmp_inc_ipreasmfails(void);
|
||||
void snmp_inc_ipfragoks(void);
|
||||
void snmp_inc_ipfragfails(void);
|
||||
void snmp_inc_ipfragcreates(void);
|
||||
void snmp_inc_iproutingdiscards(void);
|
||||
void snmp_insert_ipaddridx_tree(struct netif *ni);
|
||||
void snmp_delete_ipaddridx_tree(struct netif *ni);
|
||||
void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni);
|
||||
void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni);
|
||||
|
||||
/* ICMP */
|
||||
void snmp_inc_icmpinmsgs(void);
|
||||
void snmp_inc_icmpinerrors(void);
|
||||
void snmp_inc_icmpindestunreachs(void);
|
||||
void snmp_inc_icmpintimeexcds(void);
|
||||
void snmp_inc_icmpinparmprobs(void);
|
||||
void snmp_inc_icmpinsrcquenchs(void);
|
||||
void snmp_inc_icmpinredirects(void);
|
||||
void snmp_inc_icmpinechos(void);
|
||||
void snmp_inc_icmpinechoreps(void);
|
||||
void snmp_inc_icmpintimestamps(void);
|
||||
void snmp_inc_icmpintimestampreps(void);
|
||||
void snmp_inc_icmpinaddrmasks(void);
|
||||
void snmp_inc_icmpinaddrmaskreps(void);
|
||||
void snmp_inc_icmpoutmsgs(void);
|
||||
void snmp_inc_icmpouterrors(void);
|
||||
void snmp_inc_icmpoutdestunreachs(void);
|
||||
void snmp_inc_icmpouttimeexcds(void);
|
||||
void snmp_inc_icmpoutparmprobs(void);
|
||||
void snmp_inc_icmpoutsrcquenchs(void);
|
||||
void snmp_inc_icmpoutredirects(void);
|
||||
void snmp_inc_icmpoutechos(void);
|
||||
void snmp_inc_icmpoutechoreps(void);
|
||||
void snmp_inc_icmpouttimestamps(void);
|
||||
void snmp_inc_icmpouttimestampreps(void);
|
||||
void snmp_inc_icmpoutaddrmasks(void);
|
||||
void snmp_inc_icmpoutaddrmaskreps(void);
|
||||
|
||||
/* TCP */
|
||||
void snmp_inc_tcpactiveopens(void);
|
||||
void snmp_inc_tcppassiveopens(void);
|
||||
void snmp_inc_tcpattemptfails(void);
|
||||
void snmp_inc_tcpestabresets(void);
|
||||
void snmp_inc_tcpinsegs(void);
|
||||
void snmp_inc_tcpoutsegs(void);
|
||||
void snmp_inc_tcpretranssegs(void);
|
||||
void snmp_inc_tcpinerrs(void);
|
||||
void snmp_inc_tcpoutrsts(void);
|
||||
|
||||
/* UDP */
|
||||
void snmp_inc_udpindatagrams(void);
|
||||
void snmp_inc_udpnoports(void);
|
||||
void snmp_inc_udpinerrors(void);
|
||||
void snmp_inc_udpoutdatagrams(void);
|
||||
void snmp_insert_udpidx_tree(struct udp_pcb *pcb);
|
||||
void snmp_delete_udpidx_tree(struct udp_pcb *pcb);
|
||||
|
||||
/* SNMP */
|
||||
void snmp_inc_snmpinpkts(void);
|
||||
void snmp_inc_snmpoutpkts(void);
|
||||
void snmp_inc_snmpinbadversions(void);
|
||||
void snmp_inc_snmpinbadcommunitynames(void);
|
||||
void snmp_inc_snmpinbadcommunityuses(void);
|
||||
void snmp_inc_snmpinasnparseerrs(void);
|
||||
void snmp_inc_snmpintoobigs(void);
|
||||
void snmp_inc_snmpinnosuchnames(void);
|
||||
void snmp_inc_snmpinbadvalues(void);
|
||||
void snmp_inc_snmpinreadonlys(void);
|
||||
void snmp_inc_snmpingenerrs(void);
|
||||
void snmp_add_snmpintotalreqvars(u8_t value);
|
||||
void snmp_add_snmpintotalsetvars(u8_t value);
|
||||
void snmp_inc_snmpingetrequests(void);
|
||||
void snmp_inc_snmpingetnexts(void);
|
||||
void snmp_inc_snmpinsetrequests(void);
|
||||
void snmp_inc_snmpingetresponses(void);
|
||||
void snmp_inc_snmpintraps(void);
|
||||
void snmp_inc_snmpouttoobigs(void);
|
||||
void snmp_inc_snmpoutnosuchnames(void);
|
||||
void snmp_inc_snmpoutbadvalues(void);
|
||||
void snmp_inc_snmpoutgenerrs(void);
|
||||
void snmp_inc_snmpoutgetrequests(void);
|
||||
void snmp_inc_snmpoutgetnexts(void);
|
||||
void snmp_inc_snmpoutsetrequests(void);
|
||||
void snmp_inc_snmpoutgetresponses(void);
|
||||
void snmp_inc_snmpouttraps(void);
|
||||
void snmp_get_snmpgrpid_ptr(const struct snmp_obj_id **oid);
|
||||
void snmp_set_snmpenableauthentraps(u8_t *value);
|
||||
void snmp_get_snmpenableauthentraps(u8_t *value);
|
||||
|
||||
#else
|
||||
/* LWIP_SNMP support not available */
|
||||
/* define everything to be empty */
|
||||
#else
|
||||
|
||||
/* system */
|
||||
#define snmp_set_sysdescr(str, len)
|
||||
#define snmp_set_sysobjid(oid);
|
||||
#define snmp_set_sysobjid(oid)
|
||||
#define snmp_get_sysobjid_ptr(oid)
|
||||
#define snmp_inc_sysuptime()
|
||||
#define snmp_add_sysuptime(value)
|
||||
#define snmp_get_sysuptime(value)
|
||||
#define snmp_set_syscontact(ocstr, ocstrlen, bufsize);
|
||||
#define snmp_set_sysname(ocstr, ocstrlen, bufsize);
|
||||
#define snmp_set_syslocation(ocstr, ocstrlen, bufsize);
|
||||
|
||||
/* network interface */
|
||||
#define snmp_add_ifinoctets(ni,value)
|
||||
#define snmp_inc_ifinucastpkts(ni)
|
||||
#define snmp_inc_ifinnucastpkts(ni)
|
||||
#define snmp_inc_ifindiscards(ni)
|
||||
#define snmp_add_ifoutoctets(ni,value)
|
||||
#define snmp_inc_ifoutucastpkts(ni)
|
||||
#define snmp_inc_ifoutnucastpkts(ni)
|
||||
#define snmp_inc_ifoutdiscards(ni)
|
||||
#define snmp_inc_iflist()
|
||||
#define snmp_dec_iflist()
|
||||
|
||||
/* ARP */
|
||||
#define snmp_insert_arpidx_tree(ni,ip)
|
||||
#define snmp_delete_arpidx_tree(ni,ip)
|
||||
|
||||
/* IP */
|
||||
#define snmp_inc_ipinreceives()
|
||||
#define snmp_inc_ipinhdrerrors()
|
||||
#define snmp_inc_ipinaddrerrors()
|
||||
#define snmp_inc_ipforwdatagrams()
|
||||
#define snmp_inc_ipinunknownprotos()
|
||||
#define snmp_inc_ipindiscards()
|
||||
#define snmp_inc_ipindelivers()
|
||||
#define snmp_inc_ipoutrequests()
|
||||
#define snmp_inc_ipoutdiscards()
|
||||
#define snmp_inc_ipoutnoroutes()
|
||||
#define snmp_inc_ipreasmreqds()
|
||||
#define snmp_inc_ipreasmoks()
|
||||
#define snmp_inc_ipreasmfails()
|
||||
#define snmp_inc_ipfragoks()
|
||||
#define snmp_inc_ipfragfails()
|
||||
#define snmp_inc_ipfragcreates()
|
||||
#define snmp_inc_iproutingdiscards()
|
||||
#define snmp_insert_ipaddridx_tree(ni)
|
||||
#define snmp_delete_ipaddridx_tree(ni)
|
||||
#define snmp_insert_iprteidx_tree(dflt, ni)
|
||||
#define snmp_delete_iprteidx_tree(dflt, ni)
|
||||
|
||||
/* ICMP */
|
||||
#define snmp_inc_icmpinmsgs()
|
||||
#define snmp_inc_icmpinerrors()
|
||||
#define snmp_inc_icmpindestunreachs()
|
||||
#define snmp_inc_icmpintimeexcds()
|
||||
#define snmp_inc_icmpinparmprobs()
|
||||
#define snmp_inc_icmpinsrcquenchs()
|
||||
#define snmp_inc_icmpinredirects()
|
||||
#define snmp_inc_icmpinechos()
|
||||
#define snmp_inc_icmpinechoreps()
|
||||
#define snmp_inc_icmpintimestamps()
|
||||
#define snmp_inc_icmpintimestampreps()
|
||||
#define snmp_inc_icmpinaddrmasks()
|
||||
#define snmp_inc_icmpinaddrmaskreps()
|
||||
#define snmp_inc_icmpoutmsgs()
|
||||
#define snmp_inc_icmpouterrors()
|
||||
#define snmp_inc_icmpoutdestunreachs()
|
||||
#define snmp_inc_icmpouttimeexcds()
|
||||
#define snmp_inc_icmpoutparmprobs()
|
||||
#define snmp_inc_icmpoutsrcquenchs()
|
||||
#define snmp_inc_icmpoutredirects()
|
||||
#define snmp_inc_icmpoutechos()
|
||||
#define snmp_inc_icmpoutechoreps()
|
||||
#define snmp_inc_icmpouttimestamps()
|
||||
#define snmp_inc_icmpouttimestampreps()
|
||||
#define snmp_inc_icmpoutaddrmasks()
|
||||
#define snmp_inc_icmpoutaddrmaskreps()
|
||||
/* TCP */
|
||||
#define snmp_inc_tcpactiveopens()
|
||||
#define snmp_inc_tcppassiveopens()
|
||||
#define snmp_inc_tcpattemptfails()
|
||||
#define snmp_inc_tcpestabresets()
|
||||
#define snmp_inc_tcpinsegs()
|
||||
#define snmp_inc_tcpoutsegs()
|
||||
#define snmp_inc_tcpretranssegs()
|
||||
#define snmp_inc_tcpinerrs()
|
||||
#define snmp_inc_tcpoutrsts()
|
||||
|
||||
/* UDP */
|
||||
#define snmp_inc_udpindatagrams()
|
||||
#define snmp_inc_udpnoports()
|
||||
#define snmp_inc_udpinerrors()
|
||||
#define snmp_inc_udpoutdatagrams()
|
||||
#define snmp_insert_udpidx_tree(pcb)
|
||||
#define snmp_delete_udpidx_tree(pcb)
|
||||
|
||||
/* SNMP */
|
||||
#define snmp_inc_snmpinpkts()
|
||||
#define snmp_inc_snmpoutpkts()
|
||||
#define snmp_inc_snmpinbadversions()
|
||||
#define snmp_inc_snmpinbadcommunitynames()
|
||||
#define snmp_inc_snmpinbadcommunityuses()
|
||||
#define snmp_inc_snmpinasnparseerrs()
|
||||
#define snmp_inc_snmpintoobigs()
|
||||
#define snmp_inc_snmpinnosuchnames()
|
||||
#define snmp_inc_snmpinbadvalues()
|
||||
#define snmp_inc_snmpinreadonlys()
|
||||
#define snmp_inc_snmpingenerrs()
|
||||
#define snmp_add_snmpintotalreqvars(value)
|
||||
#define snmp_add_snmpintotalsetvars(value)
|
||||
#define snmp_inc_snmpingetrequests()
|
||||
#define snmp_inc_snmpingetnexts()
|
||||
#define snmp_inc_snmpinsetrequests()
|
||||
#define snmp_inc_snmpingetresponses()
|
||||
#define snmp_inc_snmpintraps()
|
||||
#define snmp_inc_snmpouttoobigs()
|
||||
#define snmp_inc_snmpoutnosuchnames()
|
||||
#define snmp_inc_snmpoutbadvalues()
|
||||
#define snmp_inc_snmpoutgenerrs()
|
||||
#define snmp_inc_snmpoutgetrequests()
|
||||
#define snmp_inc_snmpoutgetnexts()
|
||||
#define snmp_inc_snmpoutsetrequests()
|
||||
#define snmp_inc_snmpoutgetresponses()
|
||||
#define snmp_inc_snmpouttraps()
|
||||
#define snmp_get_snmpgrpid_ptr(oid)
|
||||
#define snmp_set_syscontact(ocstr, ocstrlen, bufsize)
|
||||
#define snmp_set_sysname(ocstr, ocstrlen, bufsize)
|
||||
#define snmp_set_syslocation(ocstr, ocstrlen, bufsize)
|
||||
#define snmp_set_snmpenableauthentraps(value)
|
||||
#define snmp_get_snmpenableauthentraps(value)
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
185
src/include/lwip/snmp_mib2.h
Normal file
185
src/include/lwip/snmp_mib2.h
Normal file
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* @file
|
||||
* MIB2 callback functions called from throughout the stack to integrate a MIB2
|
||||
* into lwIP (together with MIB2_STATS).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier <dziegel@gmx.de>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_SNMP_MIB2_H
|
||||
#define LWIP_HDR_SNMP_MIB2_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct udp_pcb;
|
||||
struct netif;
|
||||
|
||||
/* MIB2 statistics functions */
|
||||
#if MIB2_STATS /* don't build if not configured for use in lwipopts.h */
|
||||
/**
|
||||
* @see RFC1213, "MIB-II, 6. Definitions"
|
||||
*/
|
||||
enum snmp_ifType {
|
||||
snmp_ifType_other=1, /* none of the following */
|
||||
snmp_ifType_regular1822,
|
||||
snmp_ifType_hdh1822,
|
||||
snmp_ifType_ddn_x25,
|
||||
snmp_ifType_rfc877_x25,
|
||||
snmp_ifType_ethernet_csmacd,
|
||||
snmp_ifType_iso88023_csmacd,
|
||||
snmp_ifType_iso88024_tokenBus,
|
||||
snmp_ifType_iso88025_tokenRing,
|
||||
snmp_ifType_iso88026_man,
|
||||
snmp_ifType_starLan,
|
||||
snmp_ifType_proteon_10Mbit,
|
||||
snmp_ifType_proteon_80Mbit,
|
||||
snmp_ifType_hyperchannel,
|
||||
snmp_ifType_fddi,
|
||||
snmp_ifType_lapb,
|
||||
snmp_ifType_sdlc,
|
||||
snmp_ifType_ds1, /* T-1 */
|
||||
snmp_ifType_e1, /* european equiv. of T-1 */
|
||||
snmp_ifType_basicISDN,
|
||||
snmp_ifType_primaryISDN, /* proprietary serial */
|
||||
snmp_ifType_propPointToPointSerial,
|
||||
snmp_ifType_ppp,
|
||||
snmp_ifType_softwareLoopback,
|
||||
snmp_ifType_eon, /* CLNP over IP [11] */
|
||||
snmp_ifType_ethernet_3Mbit,
|
||||
snmp_ifType_nsip, /* XNS over IP */
|
||||
snmp_ifType_slip, /* generic SLIP */
|
||||
snmp_ifType_ultra, /* ULTRA technologies */
|
||||
snmp_ifType_ds3, /* T-3 */
|
||||
snmp_ifType_sip, /* SMDS */
|
||||
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. */
|
||||
#ifndef MIB2_COPY_SYSUPTIME_TO
|
||||
#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_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)->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)
|
||||
#else /* MIB2_STATS */
|
||||
#ifndef MIB2_COPY_SYSUPTIME_TO
|
||||
#define MIB2_COPY_SYSUPTIME_TO(ptrToVal)
|
||||
#endif
|
||||
#define MIB2_INIT_NETIF(netif, type, speed)
|
||||
#define MIB2_STATS_NETIF_INC(n, x)
|
||||
#define MIB2_STATS_NETIF_ADD(n, x, val)
|
||||
#endif /* MIB2_STATS */
|
||||
|
||||
/* LWIP MIB2 callbacks */
|
||||
#if LWIP_MIB2_CALLBACKS /* don't build if not configured for use in lwipopts.h */
|
||||
/* network interface */
|
||||
void mib2_netif_added(struct netif *ni);
|
||||
void mib2_netif_removed(struct netif *ni);
|
||||
|
||||
#if LWIP_IPV4 && LWIP_ARP
|
||||
/* ARP (for atTable and ipNetToMediaTable) */
|
||||
void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip);
|
||||
void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip);
|
||||
#else /* LWIP_IPV4 && LWIP_ARP */
|
||||
#define mib2_add_arp_entry(ni,ip)
|
||||
#define mib2_remove_arp_entry(ni,ip)
|
||||
#endif /* LWIP_IPV4 && LWIP_ARP */
|
||||
|
||||
/* IP */
|
||||
void mib2_add_ip4(struct netif *ni);
|
||||
void mib2_remove_ip4(struct netif *ni);
|
||||
void mib2_add_route_ip4(u8_t dflt, struct netif *ni);
|
||||
void mib2_remove_route_ip4(u8_t dflt, struct netif *ni);
|
||||
|
||||
/* UDP */
|
||||
void mib2_udp_bind(struct udp_pcb *pcb);
|
||||
void mib2_udp_unbind(struct udp_pcb *pcb);
|
||||
|
||||
#else /* LWIP_MIB2_CALLBACKS */
|
||||
/* LWIP_MIB2_CALLBACKS support not available */
|
||||
/* define everything to be empty */
|
||||
|
||||
/* network interface */
|
||||
#define mib2_netif_added(ni)
|
||||
#define mib2_netif_removed(ni)
|
||||
|
||||
/* ARP */
|
||||
#define mib2_add_arp_entry(ni,ip)
|
||||
#define mib2_remove_arp_entry(ni,ip)
|
||||
|
||||
/* IP */
|
||||
#define mib2_add_ip4(ni)
|
||||
#define mib2_remove_ip4(ni)
|
||||
#define mib2_add_route_ip4(dflt, ni)
|
||||
#define mib2_remove_route_ip4(dflt, ni)
|
||||
|
||||
/* UDP */
|
||||
#define mib2_udp_bind(pcb)
|
||||
#define mib2_udp_unbind(pcb)
|
||||
#endif /* LWIP_MIB2_CALLBACKS */
|
||||
|
||||
/* for source-code compatibility reasons only, can be removed (not used internally) */
|
||||
#define NETIF_INIT_SNMP MIB2_INIT_NETIF
|
||||
#define snmp_add_ifinoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifinoctets, value)
|
||||
#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_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)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_SNMP_MIB2_H */
|
||||
@@ -259,6 +259,37 @@ const struct mib_node* snmp_expand_tree(const struct mib_node *node, u8_t ident_
|
||||
u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
|
||||
u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
|
||||
|
||||
/* SNMP stack internal MIB2 statistics */
|
||||
void mib2_inc_snmpinpkts(void);
|
||||
void mib2_inc_snmpoutpkts(void);
|
||||
void mib2_inc_snmpinbadversions(void);
|
||||
void mib2_inc_snmpinbadcommunitynames(void);
|
||||
void mib2_inc_snmpinbadcommunityuses(void);
|
||||
void mib2_inc_snmpinasnparseerrs(void);
|
||||
void mib2_inc_snmpintoobigs(void);
|
||||
void mib2_inc_snmpinnosuchnames(void);
|
||||
void mib2_inc_snmpinbadvalues(void);
|
||||
void mib2_inc_snmpinreadonlys(void);
|
||||
void mib2_inc_snmpingenerrs(void);
|
||||
void mib2_add_snmpintotalreqvars(u8_t value);
|
||||
void mib2_add_snmpintotalsetvars(u8_t value);
|
||||
void mib2_inc_snmpingetrequests(void);
|
||||
void mib2_inc_snmpingetnexts(void);
|
||||
void mib2_inc_snmpinsetrequests(void);
|
||||
void mib2_inc_snmpingetresponses(void);
|
||||
void mib2_inc_snmpintraps(void);
|
||||
void mib2_inc_snmpouttoobigs(void);
|
||||
void mib2_inc_snmpoutnosuchnames(void);
|
||||
void mib2_inc_snmpoutbadvalues(void);
|
||||
void mib2_inc_snmpoutgenerrs(void);
|
||||
void mib2_inc_snmpoutgetrequests(void);
|
||||
void mib2_inc_snmpoutgetnexts(void);
|
||||
void mib2_inc_snmpoutsetrequests(void);
|
||||
void mib2_inc_snmpoutgetresponses(void);
|
||||
void mib2_inc_snmpouttraps(void);
|
||||
void mib2_get_snmpgrpid_ptr(const struct snmp_obj_id **oid);
|
||||
void mib2_get_snmpenableauthentraps(u8_t *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -110,6 +110,72 @@ struct stats_sys {
|
||||
struct stats_syselem mbox;
|
||||
};
|
||||
|
||||
struct stats_mib2 {
|
||||
/* IP */
|
||||
u32_t ipinhdrerrors;
|
||||
u32_t ipinaddrerrors;
|
||||
u32_t ipinunknownprotos;
|
||||
u32_t ipindiscards;
|
||||
u32_t ipindelivers;
|
||||
u32_t ipoutrequests;
|
||||
u32_t ipoutdiscards;
|
||||
u32_t ipoutnoroutes;
|
||||
u32_t ipreasmoks; /* @todo: never incremented */
|
||||
u32_t ipreasmfails;
|
||||
u32_t ipfragoks;
|
||||
u32_t ipfragfails; /* @todo: never incremented */
|
||||
u32_t ipfragcreates;
|
||||
u32_t iproutingdiscards; /* @todo: never incremented */
|
||||
u32_t ipreasmreqds;
|
||||
u32_t ipforwdatagrams;
|
||||
u32_t ipinreceives;
|
||||
|
||||
/* TCP */
|
||||
u32_t tcpactiveopens;
|
||||
u32_t tcppassiveopens;
|
||||
u32_t tcpattemptfails;
|
||||
u32_t tcpestabresets;
|
||||
u32_t tcpoutsegs;
|
||||
u32_t tcpretranssegs;
|
||||
u32_t tcpinsegs;
|
||||
u32_t tcpinerrs;
|
||||
u32_t tcpoutrsts;
|
||||
|
||||
/* UDP */
|
||||
u32_t udpindatagrams;
|
||||
u32_t udpnoports;
|
||||
u32_t udpinerrors;
|
||||
u32_t udpoutdatagrams;
|
||||
|
||||
/* ICMP */
|
||||
u32_t icmpinmsgs;
|
||||
u32_t icmpinerrors;
|
||||
u32_t icmpindestunreachs; /* @todo: never incremented */
|
||||
u32_t icmpintimeexcds; /* @todo: never incremented */
|
||||
u32_t icmpinparmprobs; /* @todo: never incremented */
|
||||
u32_t icmpinsrcquenchs; /* @todo: never incremented */
|
||||
u32_t icmpinredirects; /* @todo: never incremented */
|
||||
u32_t icmpinechos; /* @todo: never incremented */
|
||||
u32_t icmpinechoreps; /* @todo: never incremented */
|
||||
u32_t icmpintimestamps; /* @todo: never incremented */
|
||||
u32_t icmpintimestampreps; /* @todo: never incremented */
|
||||
u32_t icmpinaddrmasks; /* @todo: never incremented */
|
||||
u32_t icmpinaddrmaskreps; /* @todo: never incremented */
|
||||
u32_t icmpoutmsgs;
|
||||
u32_t icmpouterrors; /* @todo: never incremented */
|
||||
u32_t icmpoutdestunreachs; /* @todo: never incremented */
|
||||
u32_t icmpouttimeexcds;
|
||||
u32_t icmpoutparmprobs; /* @todo: never incremented */
|
||||
u32_t icmpoutsrcquenchs; /* @todo: never incremented */
|
||||
u32_t icmpoutredirects; /* @todo: never incremented */
|
||||
u32_t icmpoutechos; /* @todo: never incremented */
|
||||
u32_t icmpoutechoreps;
|
||||
u32_t icmpouttimestamps; /* @todo: never incremented */
|
||||
u32_t icmpouttimestampreps; /* @todo: never incremented */
|
||||
u32_t icmpoutaddrmasks; /* @todo: never incremented */
|
||||
u32_t icmpoutaddrmaskreps; /* @todo: never incremented */
|
||||
};
|
||||
|
||||
struct stats_ {
|
||||
#if LINK_STATS
|
||||
struct stats_proto link;
|
||||
@@ -159,6 +225,9 @@ struct stats_ {
|
||||
#if ND6_STATS
|
||||
struct stats_proto nd6;
|
||||
#endif
|
||||
#if MIB2_STATS
|
||||
struct stats_mib2 mib2;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern struct stats_ lwip_stats;
|
||||
@@ -172,6 +241,7 @@ void stats_init(void);
|
||||
lwip_stats.x.max = lwip_stats.x.used; \
|
||||
} \
|
||||
} while(0)
|
||||
#define STATS_GET(x) lwip_stats.x
|
||||
#else /* LWIP_STATS */
|
||||
#define stats_init()
|
||||
#define STATS_INC(x)
|
||||
@@ -323,6 +393,12 @@ void stats_init(void);
|
||||
#define ND6_STATS_DISPLAY()
|
||||
#endif
|
||||
|
||||
#if MIB2_STATS
|
||||
#define MIB2_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define MIB2_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
/* Display of statistics */
|
||||
#if LWIP_STATS_DISPLAY
|
||||
void stats_display(void);
|
||||
|
||||
Reference in New Issue
Block a user