mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-17 11:42:56 +00:00
Added SNMP statistics to struct netif and changed SNMP macro glue.
This commit is contained in:
parent
57a6eaae7b
commit
54bb20b486
@ -57,6 +57,15 @@ Exactly every 10 msec the SNMP uptime timestamp must be updated with
|
||||
snmp_inc_sysuptime(). You should call this from a timer interrupt
|
||||
or a timer signal handler depending on your runtime environment.
|
||||
|
||||
You _must_ create the following support functions for non-volatile storage
|
||||
since lwIP does not have notion of files or other non-volatile memories.
|
||||
|
||||
void snmp_store_syscontact(u8_t* ocstr, u8_t ocstrlen);
|
||||
void snmp_store_sysname(u8_t* ocstr, u8_t ocstrlen);
|
||||
void snmp_store_syslocation(u8_t* ocstr, u8_t ocstrlen);
|
||||
|
||||
|
||||
|
||||
Private MIBs
|
||||
============
|
||||
|
||||
@ -75,8 +84,9 @@ MAINTAINERS!
|
||||
|
||||
If you need to create your own private MIB you'll need
|
||||
to apply for your own enterprise ID with IANA: http://www.iana.org/numbers.html
|
||||
You can supply it in your lwipopts.h #define SNMP_ENTERPRISE_ID your_id
|
||||
|
||||
You can set it by passing a struct snmp_obj_id to the agent
|
||||
using snmp_set_sysobjid(&my_object_id), just before snmp_init().
|
||||
|
||||
Agent internals [advanced use]
|
||||
==============================
|
||||
|
@ -42,9 +42,13 @@
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/tcp.h"
|
||||
#if LWIP_SNMP
|
||||
#include "lwip/snmp.h"
|
||||
#endif
|
||||
|
||||
struct netif *netif_list = NULL;
|
||||
struct netif *netif_default = NULL;
|
||||
u16_t netif_cnt = 0;
|
||||
|
||||
/**
|
||||
* Add a network interface to the list of lwIP netifs.
|
||||
@ -88,6 +92,7 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
/* add this netif to the list */
|
||||
netif->next = netif_list;
|
||||
netif_list = netif;
|
||||
netif_cnt++;
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
|
||||
netif->name[0], netif->name[1]));
|
||||
ip_addr_debug_print(NETIF_DEBUG, ipaddr);
|
||||
@ -115,6 +120,7 @@ void netif_remove(struct netif * netif)
|
||||
/* is it the first netif? */
|
||||
if (netif_list == netif) {
|
||||
netif_list = netif->next;
|
||||
netif_cnt--;
|
||||
}
|
||||
else {
|
||||
/* look for netif further down the list */
|
||||
@ -122,8 +128,9 @@ void netif_remove(struct netif * netif)
|
||||
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
|
||||
if (tmpNetif->next == netif) {
|
||||
tmpNetif->next = netif->next;
|
||||
netif_cnt--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tmpNetif == NULL)
|
||||
return; /* we didn't find any netif today */
|
||||
@ -257,6 +264,9 @@ netif_set_default(struct netif *netif)
|
||||
void netif_set_up(struct netif *netif)
|
||||
{
|
||||
netif->flags |= NETIF_FLAG_UP;
|
||||
#if LWIP_SNMP
|
||||
snmp_get_sysuptime(&netif->ts);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,11 +288,15 @@ u8_t netif_is_up(struct netif *netif)
|
||||
void netif_set_down(struct netif *netif)
|
||||
{
|
||||
netif->flags &= ~NETIF_FLAG_UP;
|
||||
#if LWIP_SNMP
|
||||
snmp_get_sysuptime(&netif->ts);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
netif_init(void)
|
||||
{
|
||||
netif_list = netif_default = NULL;
|
||||
netif_cnt = 0;
|
||||
}
|
||||
|
||||
|
@ -105,18 +105,35 @@ struct netif {
|
||||
u16_t mtu;
|
||||
/** flags (see NETIF_FLAG_ above) */
|
||||
u8_t flags;
|
||||
/** link type */
|
||||
u8_t link_type;
|
||||
/** descriptive abbreviation */
|
||||
char name[2];
|
||||
/** number of this interface */
|
||||
u8_t num;
|
||||
#if LWIP_SNMP
|
||||
/** link type (ifType values per RFC1213) */
|
||||
u8_t link_type;
|
||||
/** (estimate) link speed */
|
||||
u32_t link_speed;
|
||||
/** 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;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** The list of network interfaces. */
|
||||
extern struct netif *netif_list;
|
||||
/** The default network interface. */
|
||||
extern struct netif *netif_default;
|
||||
/** Count of network interfaces currently in the netif_list. */
|
||||
extern u16_t netif_cnt;
|
||||
|
||||
/* netif_init() must be called first. */
|
||||
void netif_init(void);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#define __LWIP_SNMP_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
/* SNMP support available? */
|
||||
#if defined(LWIP_SNMP) && (LWIP_SNMP > 0)
|
||||
@ -48,19 +49,29 @@ struct snmp_obj_id
|
||||
};
|
||||
|
||||
/* system */
|
||||
void snmp_set_sysdesr(char* str, u8_t strlen);
|
||||
void snmp_set_sysobjid(struct snmp_obj_id *oid);
|
||||
void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid);
|
||||
void snmp_inc_sysuptime(void);
|
||||
void snmp_get_sysuptime(u32_t *value);
|
||||
void snmp_get_sysobjid(const struct snmp_obj_id **oid);
|
||||
void snmp_set_syscontact(u8_t *ocstr, u8_t ocstrlen);
|
||||
void snmp_set_sysname(u8_t *ocstr, u8_t ocstrlen);
|
||||
void snmp_set_syslocation(u8_t *ocstr, u8_t ocstrlen);
|
||||
/** externally supplied system functions
|
||||
@see lwip/doc/snmp_agent.txt */
|
||||
void snmp_store_syscontact(u8_t* ocstr, u8_t ocstrlen);
|
||||
void snmp_store_sysname(u8_t* ocstr, u8_t ocstrlen);
|
||||
void snmp_store_syslocation(u8_t* ocstr, u8_t ocstrlen);
|
||||
|
||||
/* network interface */
|
||||
void snmp_add_ifinoctets(u32_t value);
|
||||
void snmp_inc_ifinucastpkts(void);
|
||||
void snmp_inc_ifinnucastpkts(void);
|
||||
void snmp_inc_ifindiscards(void);
|
||||
void snmp_add_ifoutoctets(u32_t value);
|
||||
void snmp_inc_ifoutucastpkts(void);
|
||||
void snmp_inc_ifoutnucastpkts(void);
|
||||
void snmp_inc_ifoutdiscards(void);
|
||||
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);
|
||||
|
||||
/* IP */
|
||||
void snmp_inc_ipinreceives(void);
|
||||
@ -146,7 +157,7 @@ void snmp_inc_snmpoutgetnexts(void);
|
||||
void snmp_inc_snmpoutsetrequests(void);
|
||||
void snmp_inc_snmpoutgetresponses(void);
|
||||
void snmp_inc_snmpouttraps(void);
|
||||
void snmp_get_snmpgrpid(const struct snmp_obj_id **oid);
|
||||
void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid);
|
||||
|
||||
/* LWIP_SNMP support not available */
|
||||
/* define everything to be empty */
|
||||
@ -155,17 +166,17 @@ void snmp_get_snmpgrpid(const struct snmp_obj_id **oid);
|
||||
/* system */
|
||||
#define snmp_inc_sysuptime()
|
||||
#define snmp_get_sysuptime(value)
|
||||
#define snmp_get_sysobjid(oid)
|
||||
#define snmp_get_sysobjid_ptr(oid)
|
||||
|
||||
/* network interface */
|
||||
#define snmp_add_ifinoctets(value)
|
||||
#define snmp_inc_ifinucastpkts()
|
||||
#define snmp_inc_ifinnucastpkts()
|
||||
#define snmp_inc_ifindiscards()
|
||||
#define snmp_add_ifoutoctets(value)
|
||||
#define snmp_inc_ifoutucastpkts()
|
||||
#define snmp_inc_ifoutnucastpkts()
|
||||
#define snmp_inc_ifoutdiscards()
|
||||
#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)
|
||||
|
||||
/* IP */
|
||||
#define snmp_inc_ipinreceives()
|
||||
@ -250,7 +261,7 @@ void snmp_get_snmpgrpid(const struct snmp_obj_id **oid);
|
||||
#define snmp_inc_snmpoutsetrequests()
|
||||
#define snmp_inc_snmpoutgetresponses()
|
||||
#define snmp_inc_snmpouttraps()
|
||||
#define snmp_get_snmpgrpid()
|
||||
#define snmp_get_snmpgrpid_ptr(oid)
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user