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:
goldsimon 2015-09-08 09:47:30 +02:00
parent 1e4f312352
commit 8a0fb03e21
25 changed files with 639 additions and 1035 deletions

View File

@ -6,6 +6,10 @@ HISTORY
++ New features:
2015-09-08: Dirk Ziegelmeier
* snmp: Separate mib2 counter/table callbacks from snmp agent. This both cleans
up the code and should allow integration of a 3rd party agent/mib2.
2015-09-03: Simon Goldschmidt
* opt.h, dns.h/.c: DNS/IPv6: added support for AAAA records
@ -21,7 +25,6 @@ HISTORY
* support IPv4 source based routing: define LWIP_HOOK_IP4_ROUTE_SRC to point
to a routing function
2015-08-05: Simon Goldschmidt
* many files: allow multicast socket options IP_MULTICAST_TTL, IP_MULTICAST_IF
and IP_MULTICAST_LOOP to be used without IGMP

View File

@ -48,7 +48,6 @@
#include "lwip/ip.h"
#include "lwip/def.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include <string.h>
@ -87,7 +86,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
ip4_addr_t* src;
ICMP_STATS_INC(icmp.recv);
snmp_inc_icmpinmsgs();
MIB2_STATS_INC(mib2.icmpinmsgs);
iphdr_in = ip4_current_header();
hlen = IPH_HL(iphdr_in) * 4;
@ -138,7 +137,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
pbuf_free(p);
ICMP_STATS_INC(icmp.chkerr);
snmp_inc_icmpinerrors();
MIB2_STATS_INC(mib2.icmpinerrors);
return;
}
}
@ -223,9 +222,9 @@ icmp_input(struct pbuf *p, struct netif *inp)
ICMP_STATS_INC(icmp.xmit);
/* increase number of messages attempted to send */
snmp_inc_icmpoutmsgs();
MIB2_STATS_INC(mib2.icmpoutmsgs);
/* increase number of echo replies attempted to send */
snmp_inc_icmpoutechoreps();
MIB2_STATS_INC(mib2.icmpoutechoreps);
/* send an ICMP packet */
ret = ip4_output_if(p, src, IP_HDRINCL,
@ -246,13 +245,13 @@ icmp_input(struct pbuf *p, struct netif *inp)
lenerr:
pbuf_free(p);
ICMP_STATS_INC(icmp.lenerr);
snmp_inc_icmpinerrors();
MIB2_STATS_INC(mib2.icmpinerrors);
return;
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN || !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
icmperr:
pbuf_free(p);
ICMP_STATS_INC(icmp.err);
snmp_inc_icmpinerrors();
MIB2_STATS_INC(mib2.icmpinerrors);
return;
#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN || !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */
}
@ -344,9 +343,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
#endif
ICMP_STATS_INC(icmp.xmit);
/* increase number of messages attempted to send */
snmp_inc_icmpoutmsgs();
MIB2_STATS_INC(mib2.icmpoutmsgs);
/* increase number of destination unreachable messages attempted to send */
snmp_inc_icmpouttimeexcds();
MIB2_STATS_INC(mib2.icmpouttimeexcds);
ip4_addr_copy(iphdr_src, iphdr->src);
ip4_output_if(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP, netif);
}

View File

@ -53,7 +53,6 @@
#include "lwip/raw.h"
#include "lwip/udp.h"
#include "lwip/tcp_impl.h"
#include "lwip/snmp.h"
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
#include "lwip/stats.h"
@ -188,7 +187,7 @@ ip4_route(const ip4_addr_t *dest)
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest)));
IP_STATS_INC(ip.rterr);
snmp_inc_ipoutnoroutes();
MIB2_STATS_INC(mib2.ipoutnoroutes);
return NULL;
}
@ -302,7 +301,7 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1);
/* send ICMP if TTL == 0 */
if (IPH_TTL(iphdr) == 0) {
snmp_inc_ipinhdrerrors();
MIB2_STATS_INC(mib2.ipinhdrerrors);
#if LWIP_ICMP
/* Don't send ICMP messages in response to ICMP messages */
if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
@ -324,8 +323,8 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
ip4_addr3_16(ip4_current_dest_addr()), ip4_addr4_16(ip4_current_dest_addr())));
IP_STATS_INC(ip.fw);
MIB2_STATS_INC(mib2.ipforwdatagrams);
IP_STATS_INC(ip.xmit);
snmp_inc_ipforwdatagrams();
PERF_STOP("ip_forward");
/* don't fragment if interface has mtu set to 0 [loopif] */
@ -346,7 +345,7 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
netif->output(netif, p, ip4_current_dest_addr());
return;
return_noroute:
snmp_inc_ipoutnoroutes();
MIB2_STATS_INC(mib2.ipoutnoroutes);
}
#endif /* IP_FORWARD */
@ -393,7 +392,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING || LWIP_IGMP */
IP_STATS_INC(ip.recv);
snmp_inc_ipinreceives();
MIB2_STATS_INC(mib2.ipinreceives);
/* identify the IP header */
iphdr = (struct ip_hdr *)p->payload;
@ -403,7 +402,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
pbuf_free(p);
IP_STATS_INC(ip.err);
IP_STATS_INC(ip.drop);
snmp_inc_ipinhdrerrors();
MIB2_STATS_INC(mib2.ipinhdrerrors);
return ERR_OK;
}
@ -442,7 +441,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
pbuf_free(p);
IP_STATS_INC(ip.lenerr);
IP_STATS_INC(ip.drop);
snmp_inc_ipindiscards();
MIB2_STATS_INC(mib2.ipindiscards);
return ERR_OK;
}
@ -457,7 +456,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
pbuf_free(p);
IP_STATS_INC(ip.chkerr);
IP_STATS_INC(ip.drop);
snmp_inc_ipinhdrerrors();
MIB2_STATS_INC(mib2.ipinhdrerrors);
return ERR_OK;
}
}
@ -577,8 +576,8 @@ ip4_input(struct pbuf *p, struct netif *inp)
/* free (drop) packet pbufs */
pbuf_free(p);
IP_STATS_INC(ip.drop);
snmp_inc_ipinaddrerrors();
snmp_inc_ipindiscards();
MIB2_STATS_INC(mib2.ipinaddrerrors);
MIB2_STATS_INC(mib2.ipindiscards);
return ERR_OK;
}
}
@ -595,8 +594,8 @@ ip4_input(struct pbuf *p, struct netif *inp)
} else
#endif /* IP_FORWARD */
{
snmp_inc_ipinaddrerrors();
snmp_inc_ipindiscards();
MIB2_STATS_INC(mib2.ipinaddrerrors);
MIB2_STATS_INC(mib2.ipindiscards);
}
pbuf_free(p);
return ERR_OK;
@ -620,7 +619,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
IP_STATS_INC(ip.opterr);
IP_STATS_INC(ip.drop);
/* unsupported protocol feature */
snmp_inc_ipinunknownprotos();
MIB2_STATS_INC(mib2.ipinunknownprotos);
return ERR_OK;
#endif /* IP_REASSEMBLY */
}
@ -638,7 +637,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
IP_STATS_INC(ip.opterr);
IP_STATS_INC(ip.drop);
/* unsupported protocol feature */
snmp_inc_ipinunknownprotos();
MIB2_STATS_INC(mib2.ipinunknownprotos);
return ERR_OK;
}
#endif /* IP_OPTIONS_ALLOWED == 0 */
@ -666,19 +665,19 @@ ip4_input(struct pbuf *p, struct netif *inp)
#if LWIP_UDPLITE
case IP_PROTO_UDPLITE:
#endif /* LWIP_UDPLITE */
snmp_inc_ipindelivers();
MIB2_STATS_INC(mib2.ipindelivers);
udp_input(p, inp);
break;
#endif /* LWIP_UDP */
#if LWIP_TCP
case IP_PROTO_TCP:
snmp_inc_ipindelivers();
MIB2_STATS_INC(mib2.ipindelivers);
tcp_input(p, inp);
break;
#endif /* LWIP_TCP */
#if LWIP_ICMP
case IP_PROTO_ICMP:
snmp_inc_ipindelivers();
MIB2_STATS_INC(mib2.ipindelivers);
icmp_input(p, inp);
break;
#endif /* LWIP_ICMP */
@ -703,7 +702,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
IP_STATS_INC(ip.proterr);
IP_STATS_INC(ip.drop);
snmp_inc_ipinunknownprotos();
MIB2_STATS_INC(mib2.ipinunknownprotos);
}
}
@ -808,7 +807,7 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);
snmp_inc_ipoutrequests();
MIB2_STATS_INC(mib2.ipoutrequests);
/* Should the IP header be generated or is it already included in p? */
if (dest != IP_HDRINCL) {
@ -826,7 +825,7 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
if (pbuf_header(p, optlen_aligned)) {
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output_if_opt: not enough room for IP options in pbuf\n"));
IP_STATS_INC(ip.err);
snmp_inc_ipoutdiscards();
MIB2_STATS_INC(mib2.ipoutdiscards);
return ERR_BUF;
}
MEMCPY(p->payload, ip_options, optlen);
@ -846,7 +845,7 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output: not enough room for IP header in pbuf\n"));
IP_STATS_INC(ip.err);
snmp_inc_ipoutdiscards();
MIB2_STATS_INC(mib2.ipoutdiscards);
return ERR_BUF;
}

View File

@ -46,7 +46,6 @@
#include "lwip/def.h"
#include "lwip/inet_chksum.h"
#include "lwip/netif.h"
#include "lwip/snmp.h"
#include "lwip/stats.h"
#include "lwip/icmp.h"
@ -170,7 +169,7 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p
LWIP_ASSERT("prev->next == ipr", prev->next == ipr);
}
snmp_inc_ipreasmfails();
MIB2_STATS_INC(mib2.ipreasmfails);
#if LWIP_ICMP
iprh = (struct ip_reass_helper *)ipr->p->payload;
if (iprh->start == 0) {
@ -489,8 +488,8 @@ ip4_reass(struct pbuf *p)
u8_t clen;
IPFRAG_STATS_INC(ip_frag.recv);
snmp_inc_ipreasmreqds();
MIB2_STATS_INC(mib2.ipreasmreqds);
fraghdr = (struct ip_hdr*)p->payload;
if ((IPH_HL(fraghdr) * 4) != IP_HLEN) {
@ -853,7 +852,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
pbuf_chain(header, rambuf);
netif->output(netif, header, dest);
IPFRAG_STATS_INC(ip_frag.xmit);
snmp_inc_ipfragcreates();
MIB2_STATS_INC(mib2.ipfragcreates);
pbuf_free(header);
} else {
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc() for header failed\n"));
@ -882,7 +881,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
#if IP_FRAG_USES_STATIC_BUF
pbuf_free(rambuf);
#endif /* IP_FRAG_USES_STATIC_BUF */
snmp_inc_ipfragoks();
MIB2_STATS_INC(mib2.ipfragoks);
return ERR_OK;
}
#endif /* IP_FRAG */

View File

@ -44,10 +44,11 @@
#include "lwip/netif.h"
#include "lwip/tcp_impl.h"
#include "lwip/udp.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/igmp.h"
#include "netif/etharp.h"
#include "lwip/stats.h"
#include "lwip/sys.h"
#if ENABLE_LOOPBACK
#include "lwip/sys.h"
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
@ -117,7 +118,7 @@ netif_loopif_init(struct netif *netif)
/* initialize the snmp variables and counters inside the struct netif
* ifSpeed: no assumption can be made!
*/
NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0);
MIB2_INIT_NETIF(netif, snmp_ifType_softwareLoopback, 0);
netif->name[0] = 'l';
netif->name[1] = 'o';
@ -264,7 +265,7 @@ netif_add(struct netif *netif,
/* add this netif to the list */
netif->next = netif_list;
netif_list = netif;
snmp_inc_iflist();
mib2_netif_added(netif);
#if LWIP_IGMP
/* start IGMP processing */
@ -345,7 +346,7 @@ netif_remove(struct netif *netif)
netif_set_down(netif);
}
snmp_delete_ipaddridx_tree(netif);
mib2_remove_ip4(netif);
/* this netif is default? */
if (netif_default == netif) {
@ -368,7 +369,7 @@ netif_remove(struct netif *netif)
return; /* netif is not on the list */
}
}
snmp_dec_iflist();
mib2_netif_removed(netif);
#if LWIP_NETIF_REMOVE_CALLBACK
if (netif->remove_callback) {
netif->remove_callback(netif);
@ -431,12 +432,12 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
udp_netif_ipv4_addr_changed(netif_ip4_addr(netif), ipaddr);
#endif /* LWIP_UDP */
snmp_delete_ipaddridx_tree(netif);
snmp_delete_iprteidx_tree(0, netif);
mib2_remove_ip4(netif);
mib2_remove_route_ip4(0, netif);
/* set new IP address to netif */
ip4_addr_set(netif_ip4_addr(netif), ipaddr);
snmp_insert_ipaddridx_tree(netif);
snmp_insert_iprteidx_tree(0, netif);
mib2_add_ip4(netif);
mib2_add_route_ip4(0, netif);
netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4);
@ -483,10 +484,10 @@ netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
void
netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
{
snmp_delete_iprteidx_tree(0, netif);
mib2_remove_route_ip4(0, netif);
/* set new netmask to netif */
ip4_addr_set(netif_ip4_netmask(netif), netmask);
snmp_insert_iprteidx_tree(0, netif);
mib2_add_route_ip4(0, netif);
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
netif->name[0], netif->name[1],
ip4_addr1_16(netif_ip4_netmask(netif)),
@ -507,10 +508,10 @@ netif_set_default(struct netif *netif)
{
if (netif == NULL) {
/* remove default route */
snmp_delete_iprteidx_tree(1, netif);
mib2_remove_route_ip4(1, netif);
} else {
/* install default route */
snmp_insert_iprteidx_tree(1, netif);
mib2_add_route_ip4(1, netif);
}
netif_default = netif;
LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
@ -531,9 +532,7 @@ void netif_set_up(struct netif *netif)
if (!(netif->flags & NETIF_FLAG_UP)) {
netif->flags |= NETIF_FLAG_UP;
#if LWIP_SNMP
snmp_get_sysuptime(&netif->ts);
#endif /* LWIP_SNMP */
MIB2_COPY_SYSUPTIME_TO(&netif->ts);
NETIF_STATUS_CALLBACK(netif);
@ -593,9 +592,7 @@ void netif_set_down(struct netif *netif)
{
if (netif->flags & NETIF_FLAG_UP) {
netif->flags &= ~NETIF_FLAG_UP;
#if LWIP_SNMP
snmp_get_sysuptime(&netif->ts);
#endif
a MIB2_COPY_SYSUPTIME_TO(&netif->ts);
#if LWIP_IPV4 && LWIP_ARP
if (netif->flags & NETIF_FLAG_ETHARP) {
@ -706,13 +703,13 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
/* If we have a loopif, SNMP counters are adjusted for it,
* if not they are adjusted for 'netif'. */
#if LWIP_SNMP
#if MIB2_STATS
#if LWIP_HAVE_LOOPIF
struct netif *stats_if = &loop_netif;
#else /* LWIP_HAVE_LOOPIF */
struct netif *stats_if = netif;
#endif /* LWIP_HAVE_LOOPIF */
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
SYS_ARCH_DECL_PROTECT(lev);
/* Allocate a new pbuf */
@ -720,7 +717,7 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
if (r == NULL) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(stats_if);
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
return ERR_MEM;
}
#if LWIP_LOOPBACK_MAX_PBUFS
@ -731,7 +728,7 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
pbuf_free(r);
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(stats_if);
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
return ERR_MEM;
}
netif->loop_cnt_current += clen;
@ -742,7 +739,7 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
pbuf_free(r);
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(stats_if);
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
return err;
}
@ -764,8 +761,8 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
SYS_ARCH_UNPROTECT(lev);
LINK_STATS_INC(link.xmit);
snmp_add_ifoutoctets(stats_if, p->tot_len);
snmp_inc_ifoutucastpkts(stats_if);
MIB2_STATS_NETIF_ADD(stats_if, ifoutoctets, p->tot_len);
MIB2_STATS_NETIF_INC(stats_if, ifoutucastpkts);
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
/* For multithreading environment, schedule a call to netif_poll */
@ -806,13 +803,13 @@ netif_poll(struct netif *netif)
struct pbuf *in;
/* If we have a loopif, SNMP counters are adjusted for it,
* if not they are adjusted for 'netif'. */
#if LWIP_SNMP
#if MIB2_STATS
#if LWIP_HAVE_LOOPIF
struct netif *stats_if = &loop_netif;
#else /* LWIP_HAVE_LOOPIF */
struct netif *stats_if = netif;
#endif /* LWIP_HAVE_LOOPIF */
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
SYS_ARCH_DECL_PROTECT(lev);
do {
@ -854,8 +851,8 @@ netif_poll(struct netif *netif)
if (in != NULL) {
LINK_STATS_INC(link.recv);
snmp_add_ifinoctets(stats_if, in->tot_len);
snmp_inc_ifinucastpkts(stats_if);
MIB2_STATS_NETIF_ADD(stats_if, ifinoctets, in->tot_len);
MIB2_STATS_NETIF_INC(stats_if, ifinucastpkts);
/* loopback packets are always IP packets! */
if (ip_input(in, netif) != ERR_OK) {
pbuf_free(in);

File diff suppressed because it is too large Load Diff

View File

@ -925,7 +925,7 @@ snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
}
/* accepting request */
snmp_inc_snmpinpkts();
mib2_inc_snmpinpkts();
/* record used 'protocol control block' */
msg_ps->pcb = pcb;
/* source address (network order) */
@ -1006,7 +1006,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
(pdu_len != (1 + len_octets + len)) ||
(type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)))
{
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
ofs += (1 + len_octets);
@ -1015,20 +1015,20 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)))
{
/* can't decode or no integer (version) */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &version);
if (derr != ERR_OK)
{
/* can't decode */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
if (version != 0)
{
/* not version 1 */
snmp_inc_snmpinbadversions();
mib2_inc_snmpinbadversions();
return ERR_ARG;
}
m_stat->version = (u8_t)version;
@ -1038,13 +1038,13 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR)))
{
/* can't decode or no octet string (community) */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
derr = snmp_asn1_dec_raw(p, ofs + 1 + len_octets, len, SNMP_COMMUNITY_STR_LEN, m_stat->community);
if (derr != ERR_OK)
{
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
/* add zero terminator */
@ -1060,7 +1060,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if (type == (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_SET_REQ))
{
/* wrong community for SetRequest PDU */
snmp_inc_snmpinbadcommunitynames();
mib2_inc_snmpinbadcommunitynames();
snmp_authfail_trap();
return ERR_ARG;
}
@ -1069,7 +1069,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
#endif /* SNMP_COMMUNITY_EXT */
if (strncmp(snmp_community, (const char*)m_stat->community, SNMP_COMMUNITY_STR_LEN) != 0)
{
snmp_inc_snmpinbadcommunitynames();
mib2_inc_snmpinbadcommunitynames();
snmp_authfail_trap();
return ERR_ARG;
}
@ -1077,38 +1077,38 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
derr = snmp_asn1_dec_length(p, ofs+1, &len_octets, &len);
if (derr != ERR_OK)
{
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
switch(type)
{
case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_REQ):
/* GetRequest PDU */
snmp_inc_snmpingetrequests();
mib2_inc_snmpingetrequests();
derr = ERR_OK;
break;
case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_NEXT_REQ):
/* GetNextRequest PDU */
snmp_inc_snmpingetnexts();
mib2_inc_snmpingetnexts();
derr = ERR_OK;
break;
case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_GET_RESP):
/* GetResponse PDU */
snmp_inc_snmpingetresponses();
mib2_inc_snmpingetresponses();
derr = ERR_ARG;
break;
case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_SET_REQ):
/* SetRequest PDU */
snmp_inc_snmpinsetrequests();
mib2_inc_snmpinsetrequests();
derr = ERR_OK;
break;
case (SNMP_ASN1_CONTXT | SNMP_ASN1_CONSTR | SNMP_ASN1_PDU_TRAP):
/* Trap PDU */
snmp_inc_snmpintraps();
mib2_inc_snmpintraps();
derr = ERR_ARG;
break;
default:
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
derr = ERR_ARG;
break;
}
@ -1122,7 +1122,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if (len != (pdu_len - (ofs - ofs_base)))
{
/* decoded PDU length does not equal actual payload length */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
snmp_asn1_dec_type(p, ofs, &type);
@ -1130,14 +1130,14 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)))
{
/* can't decode or no integer (request ID) */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
derr = snmp_asn1_dec_s32t(p, ofs + 1 + len_octets, len, &m_stat->rid);
if (derr != ERR_OK)
{
/* can't decode */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
ofs += (1 + len_octets + len);
@ -1146,7 +1146,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)))
{
/* can't decode or no integer (error-status) */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
/* must be noError (0) for incoming requests.
@ -1155,7 +1155,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if (derr != ERR_OK)
{
/* can't decode */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
switch (m_stat->error_status)
@ -1164,19 +1164,19 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
/* nothing to do */
break;
case SNMP_ES_TOOBIG:
snmp_inc_snmpintoobigs();
mib2_inc_snmpintoobigs();
break;
case SNMP_ES_NOSUCHNAME:
snmp_inc_snmpinnosuchnames();
mib2_inc_snmpinnosuchnames();
break;
case SNMP_ES_BADVALUE:
snmp_inc_snmpinbadvalues();
mib2_inc_snmpinbadvalues();
break;
case SNMP_ES_READONLY:
snmp_inc_snmpinreadonlys();
mib2_inc_snmpinreadonlys();
break;
case SNMP_ES_GENERROR:
snmp_inc_snmpingenerrs();
mib2_inc_snmpingenerrs();
break;
default:
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_pdu_header_check(): unknown error_status: %d\n", (int)m_stat->error_status));
@ -1188,7 +1188,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG)))
{
/* can't decode or no integer (error-index) */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
/* must be 0 for incoming requests.
@ -1197,7 +1197,7 @@ snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret,
if (derr != ERR_OK)
{
/* can't decode */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
ofs += (1 + len_octets + len);
@ -1219,7 +1219,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
if ((derr != ERR_OK) ||
(type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)))
{
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
return ERR_ARG;
}
ofs += (1 + len_octets);
@ -1240,7 +1240,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
(type != (SNMP_ASN1_UNIV | SNMP_ASN1_CONSTR | SNMP_ASN1_SEQ)) ||
(len == 0) || (len > vb_len))
{
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
/* free varbinds (if available) */
snmp_varbind_list_free(&m_stat->invb);
return ERR_ARG;
@ -1253,7 +1253,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
if ((derr != ERR_OK) || (type != (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID)))
{
/* can't decode object name length */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
/* free varbinds (if available) */
snmp_varbind_list_free(&m_stat->invb);
return ERR_ARG;
@ -1262,7 +1262,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
if (derr != ERR_OK)
{
/* can't decode object name */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
/* free varbinds (if available) */
snmp_varbind_list_free(&m_stat->invb);
return ERR_ARG;
@ -1275,7 +1275,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
if (derr != ERR_OK)
{
/* can't decode object value length */
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
/* free varbinds (if available) */
snmp_varbind_list_free(&m_stat->invb);
return ERR_ARG;
@ -1388,7 +1388,7 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
}
if (derr != ERR_OK)
{
snmp_inc_snmpinasnparseerrs();
mib2_inc_snmpinasnparseerrs();
/* free varbinds (if available) */
snmp_varbind_list_free(&m_stat->invb);
return ERR_ARG;
@ -1399,11 +1399,11 @@ snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_
if (m_stat->rt == SNMP_ASN1_PDU_SET_REQ)
{
snmp_add_snmpintotalsetvars(m_stat->invb.count);
mib2_add_snmpintotalsetvars(m_stat->invb.count);
}
else
{
snmp_add_snmpintotalreqvars(m_stat->invb.count);
mib2_add_snmpintotalreqvars(m_stat->invb.count);
}
*ofs_ret = ofs;

View File

@ -49,8 +49,10 @@
#include "lwip/udp.h"
#include "lwip/netif.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/snmp_asn1.h"
#include "lwip/snmp_msg.h"
#include "lwip/sys.h"
#include <string.h>
@ -159,23 +161,23 @@ snmp_send_response(struct snmp_msg_pstat *m_stat)
/* nothing to do */
break;
case SNMP_ES_TOOBIG:
snmp_inc_snmpouttoobigs();
mib2_inc_snmpouttoobigs();
break;
case SNMP_ES_NOSUCHNAME:
snmp_inc_snmpoutnosuchnames();
mib2_inc_snmpoutnosuchnames();
break;
case SNMP_ES_BADVALUE:
snmp_inc_snmpoutbadvalues();
mib2_inc_snmpoutbadvalues();
break;
case SNMP_ES_GENERROR:
snmp_inc_snmpoutgenerrs();
mib2_inc_snmpoutgenerrs();
break;
default:
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_send_response(): unknown error_status: %d\n", (int)m_stat->error_status));
break;
}
snmp_inc_snmpoutgetresponses();
snmp_inc_snmpoutpkts();
mib2_inc_snmpoutgetresponses();
mib2_inc_snmpoutpkts();
/** @todo do we need separate rx and tx pcbs for threaded case? */
/** connect to the originating source */
@ -256,9 +258,10 @@ snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific
else
{
/* generic (MIB-II) trap */
snmp_get_snmpgrpid_ptr(&trap_msg.enterprise);
mib2_get_snmpgrpid_ptr(&trap_msg.enterprise);
}
snmp_get_sysuptime(&trap_msg.ts);
MIB2_COPY_SYSUPTIME_TO(&trap_msg.ts);
/* pass 0, calculate length fields */
tot_len = snmp_varbind_list_sum(&trap_msg.outvb);
@ -274,8 +277,8 @@ snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific
ofs = snmp_trap_header_enc(&trap_msg, p);
snmp_varbind_list_enc(&trap_msg.outvb, p, ofs);
snmp_inc_snmpouttraps();
snmp_inc_snmpoutpkts();
mib2_inc_snmpouttraps();
mib2_inc_snmpoutpkts();
/** send to the TRAP destination */
udp_sendto(trap_msg.pcb, p, &trap_msg.dip, SNMP_TRAP_PORT);
@ -306,7 +309,7 @@ void
snmp_authfail_trap(void)
{
u8_t enable;
snmp_get_snmpenableauthentraps(&enable);
mib2_get_snmpenableauthentraps(&enable);
if (enable == 1)
{
trap_msg.outvb.head = NULL;

View File

@ -47,7 +47,6 @@
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/snmp.h"
#include "lwip/tcp.h"
#include "lwip/tcp_impl.h"
#include "lwip/debug.h"
@ -231,26 +230,26 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
TCP_PCB_REMOVE_ACTIVE(pcb);
memp_free(MEMP_TCP_PCB, pcb);
pcb = NULL;
snmp_inc_tcpattemptfails();
MIB2_STATS_INC(mib2.tcpattemptfails);
break;
case SYN_RCVD:
err = tcp_send_fin(pcb);
if (err == ERR_OK) {
snmp_inc_tcpattemptfails();
MIB2_STATS_INC(mib2.tcpattemptfails);
pcb->state = FIN_WAIT_1;
}
break;
case ESTABLISHED:
err = tcp_send_fin(pcb);
if (err == ERR_OK) {
snmp_inc_tcpestabresets();
MIB2_STATS_INC(mib2.tcpestabresets);
pcb->state = FIN_WAIT_1;
}
break;
case CLOSE_WAIT:
err = tcp_send_fin(pcb);
if (err == ERR_OK) {
snmp_inc_tcpestabresets();
MIB2_STATS_INC(mib2.tcpestabresets);
pcb->state = LAST_ACK;
}
break;
@ -850,7 +849,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
TCP_RMV(&tcp_bound_pcbs, pcb);
}
TCP_REG_ACTIVE(pcb);
snmp_inc_tcpactiveopens();
MIB2_STATS_INC(mib2.tcpactiveopens);
tcp_output(pcb);
}

View File

@ -53,7 +53,6 @@
#include "lwip/memp.h"
#include "lwip/inet_chksum.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/ip6.h"
#include "lwip/ip6_addr.h"
#include "lwip/inet_chksum.h"
@ -117,7 +116,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
PERF_START;
TCP_STATS_INC(tcp.recv);
snmp_inc_tcpinsegs();
MIB2_STATS_INC(mib2.tcpinsegs);
tcphdr = (struct tcp_hdr *)p->payload;
@ -348,7 +347,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* pcb has been aborted or refused data is still refused and the new
segment contains data */
TCP_STATS_INC(tcp.drop);
snmp_inc_tcpinerrs();
MIB2_STATS_INC(mib2.tcpinerrs);
goto aborted;
}
}
@ -513,7 +512,7 @@ aborted:
return;
dropped:
TCP_STATS_INC(tcp.drop);
snmp_inc_tcpinerrs();
MIB2_STATS_INC(mib2.tcpinerrs);
pbuf_free(p);
}
@ -601,7 +600,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
&npcb->remote_ip, PCB_ISIPV6(npcb));
#endif /* TCP_CALCULATE_EFF_SEND_MSS */
snmp_inc_tcppassiveopens();
MIB2_STATS_INC(mib2.tcppassiveopens);
/* Send a SYN|ACK together with the MSS option. */
rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK);

View File

@ -50,7 +50,6 @@
#include "lwip/netif.h"
#include "lwip/inet_chksum.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/ip6.h"
#include "lwip/ip6_addr.h"
#include "lwip/inet_chksum.h"
@ -1136,7 +1135,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
struct netif *netif;
/** @bug Exclude retransmitted segments from this count. */
snmp_inc_tcpoutsegs();
MIB2_STATS_INC(mib2.tcpoutsegs);
/* The TCP header has already been constructed, but the ackno and
wnd fields remain. */
@ -1322,7 +1321,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
tcphdr->urgp = 0;
TCP_STATS_INC(tcp.xmit);
snmp_inc_tcpoutrsts();
MIB2_STATS_INC(mib2.tcpoutrsts);
netif = ip_route(IP_IS_V6(remote_ip), local_ip, remote_ip);
if (netif != NULL) {
@ -1422,7 +1421,7 @@ tcp_rexmit(struct tcp_pcb *pcb)
pcb->rttest = 0;
/* Do the actual retransmission. */
snmp_inc_tcpretranssegs();
MIB2_STATS_INC(mib2.tcpretranssegs);
/* No need to call tcp_output: we are always called from tcp_input()
and thus tcp_output directly returns. */
}

View File

@ -62,7 +62,7 @@
#include "lwip/icmp.h"
#include "lwip/icmp6.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/dhcp.h"
#include <string.h>
@ -174,7 +174,7 @@ udp_input(struct pbuf *p, struct netif *inp)
("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len));
UDP_STATS_INC(udp.lenerr);
UDP_STATS_INC(udp.drop);
snmp_inc_udpinerrors();
MIB2_STATS_INC(mib2.udpinerrors);
pbuf_free(p);
goto end;
}
@ -363,12 +363,12 @@ udp_input(struct pbuf *p, struct netif *inp)
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
UDP_STATS_INC(udp.drop);
snmp_inc_udpinerrors();
MIB2_STATS_INC(mib2.udpinerrors);
pbuf_free(p);
goto end;
}
if (pcb != NULL) {
snmp_inc_udpindatagrams();
MIB2_STATS_INC(mib2.udpindatagrams);
#if SO_REUSE && SO_REUSE_RXTOALL
if ((broadcast ||
#if LWIP_IPV6
@ -463,7 +463,7 @@ udp_input(struct pbuf *p, struct netif *inp)
#endif /* LWIP_ICMP || LWIP_ICMP6 */
UDP_STATS_INC(udp.proterr);
UDP_STATS_INC(udp.drop);
snmp_inc_udpnoports();
MIB2_STATS_INC(mib2.udpnoports);
pbuf_free(p);
}
} else {
@ -478,7 +478,7 @@ chkerr:
("udp_input: UDP (or UDP Lite) datagram discarded due to failing checksum\n"));
UDP_STATS_INC(udp.chkerr);
UDP_STATS_INC(udp.drop);
snmp_inc_udpinerrors();
MIB2_STATS_INC(mib2.udpinerrors);
pbuf_free(p);
PERF_STOP("udp_input");
#endif /* CHECKSUM_CHECK_UDP */
@ -881,7 +881,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d
NETIF_SET_HWADDRHINT(netif, NULL);
/* TODO: must this be increased even if error occurred? */
snmp_inc_udpoutdatagrams();
MIB2_STATS_INC(mib2.udpoutdatagrams);
/* did we chain a separate header pbuf earlier? */
if (q != p) {
@ -974,7 +974,7 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
}
}
pcb->local_port = port;
snmp_insert_udpidx_tree(pcb);
mib2_udp_bind(pcb);
/* pcb not active yet? */
if (rebind == 0) {
/* place the PCB on the active list if not already there */
@ -1110,7 +1110,7 @@ udp_remove(struct udp_pcb *pcb)
{
struct udp_pcb *pcb2;
snmp_delete_udpidx_tree(pcb);
mib2_udp_unbind(pcb);
/* pcb to be removed is first in list? */
if (udp_pcbs == pcb) {
/* make list start at 2nd pcb */

View File

@ -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. */

View File

@ -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 */

View File

@ -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

View 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 */

View File

@ -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

View File

@ -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);

View File

@ -51,7 +51,7 @@
#include "lwip/def.h"
#include "lwip/ip.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
#include "netif/etharp.h"
@ -184,7 +184,7 @@ static void
etharp_free_entry(int i)
{
/* remove from SNMP ARP index tree */
snmp_delete_arpidx_tree(arp_table[i].netif, &arp_table[i].ipaddr);
mib2_remove_arp_entry(arp_table[i].netif, &arp_table[i].ipaddr);
/* and empty packet queue */
if (arp_table[i].q != NULL) {
/* remove all queued packets */
@ -512,7 +512,7 @@ etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct et
/* record network interface */
arp_table[i].netif = netif;
/* insert in SNMP ARP index tree */
snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr);
mib2_add_arp_entry(netif, &arp_table[i].ipaddr);
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));
/* update address */

View File

@ -51,7 +51,7 @@
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/ethip6.h"
#include "netif/etharp.h"
#include "netif/ppp/pppoe.h"
@ -309,7 +309,7 @@ ethernetif_init(struct netif *netif)
* The last argument should be replaced with your link speed, in units
* of bits per second.
*/
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
netif->state = ethernetif;
netif->name[0] = IFNAME0;

View File

@ -87,7 +87,7 @@
#include "lwip/sys.h"
#include "lwip/tcpip.h"
#include "lwip/api.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/sio.h"
#include "lwip/sys.h"
#include "lwip/ip4.h" /* for ip4_input() */
@ -503,7 +503,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
PPPDEBUG(LOG_WARNING, ("pppos_netif_output[%d]: bad IP packet\n", pcb->netif->num));
LINK_STATS_INC(link.proterr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(pcb->netif);
MIB2_STATS_NETIF_INC(pcb->netif, ifoutdiscards);
return ERR_VAL;
}
}
@ -521,7 +521,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
if ((err = mppe_compress(pcb, &pcb->mppe_comp, &pb, protocol)) != ERR_OK) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(netif);
MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
return err;
}
@ -540,7 +540,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
err_rte_drop:
LINK_STATS_INC(link.rterr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(netif);
MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
return ERR_RTE;
}
@ -727,8 +727,8 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
pbuf_header(pb, -(s16_t)sizeof(protocol));
LINK_STATS_INC(link.recv);
snmp_inc_ifinucastpkts(pcb->netif);
snmp_add_ifinoctets(pcb->netif, pb->tot_len);
MIB2_STATS_NETIF_INC(pcb->netif, ifinucastpkts);
MIB2_STATS_NETIF_ADD(pcb->netif, ifinoctets, pb->tot_len);
/*
* Toss all non-LCP packets unless LCP is OPEN.
@ -908,7 +908,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
drop:
LINK_STATS_INC(link.drop);
snmp_inc_ifindiscards(pcb->netif);
MIB2_STATS_NETIF_INC(pcb->netif, ifindiscards);
out:
pbuf_free(pb);

View File

@ -79,7 +79,7 @@
#include "lwip/timers.h"
#include "lwip/memp.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "netif/ppp/ppp_impl.h"
#include "netif/ppp/lcp.h"
@ -206,11 +206,11 @@ static err_t pppoe_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
struct pppoe_softc *sc = (struct pppoe_softc *)ctx;
struct pbuf *ph; /* Ethernet + PPPoE header */
err_t ret;
#if LWIP_SNMP
#if MIB2_STATS
u16_t tot_len;
#else /* LWIP_SNMP */
#else /* MIB2_STATS */
LWIP_UNUSED_ARG(ppp);
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
/* skip address & flags */
pbuf_header(p, -(s16_t)2);
@ -219,26 +219,26 @@ static err_t pppoe_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
if(!ph) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.proterr);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
pbuf_free(p);
return ERR_MEM;
}
pbuf_header(ph, -(s16_t)PPPOE_HEADERLEN); /* hide PPPoE header */
pbuf_cat(ph, p);
#if LWIP_SNMP
#if MIB2_STATS
tot_len = ph->tot_len;
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
ret = pppoe_xmit(sc, ph);
if (ret != ERR_OK) {
LINK_STATS_INC(link.err);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return ret;
}
snmp_add_ifoutoctets(ppp->netif, (u16_t)tot_len);
snmp_inc_ifoutucastpkts(ppp->netif);
MIB2_STATS_NETIF_ADD(ppp->netif, ifoutoctets, (u16_t)tot_len);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutucastpkts);
LINK_STATS_INC(link.xmit);
return ERR_OK;
}
@ -249,18 +249,18 @@ static err_t pppoe_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_short
struct pbuf *pb;
u8_t *pl;
err_t err;
#if LWIP_SNMP
#if MIB2_STATS
u16_t tot_len;
#else /* LWIP_SNMP */
#else /* MIB2_STATS */
LWIP_UNUSED_ARG(ppp);
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
/* @todo: try to use pbuf_header() here! */
pb = pbuf_alloc(PBUF_LINK, PPPOE_HEADERLEN + sizeof(protocol), PBUF_RAM);
if(!pb) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.proterr);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return ERR_MEM;
}
@ -270,18 +270,18 @@ static err_t pppoe_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_short
PUTSHORT(protocol, pl);
pbuf_chain(pb, p);
#if LWIP_SNMP
#if MIB2_STATS
tot_len = pb->tot_len;
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
if( (err = pppoe_xmit(sc, pb)) != ERR_OK) {
LINK_STATS_INC(link.err);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return err;
}
snmp_add_ifoutoctets(ppp->netif, tot_len);
snmp_inc_ifoutucastpkts(ppp->netif);
MIB2_STATS_NETIF_ADD(ppp->netif, ifoutoctets, tot_len);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutucastpkts);
LINK_STATS_INC(link.xmit);
return ERR_OK;
}

View File

@ -57,7 +57,7 @@
#include "lwip/memp.h"
#include "lwip/netif.h"
#include "lwip/udp.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "netif/ppp/ppp_impl.h"
#include "netif/ppp/lcp.h"
@ -175,36 +175,36 @@ static err_t pppol2tp_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
pppol2tp_pcb *l2tp = (pppol2tp_pcb *)ctx;
struct pbuf *ph; /* UDP + L2TP header */
err_t ret;
#if LWIP_SNMP
#if MIB2_STATS
u16_t tot_len;
#else /* LWIP_SNMP */
#else /* MIB2_STATS */
LWIP_UNUSED_ARG(ppp);
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
ph = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(PPPOL2TP_OUTPUT_DATA_HEADER_LEN), PBUF_RAM);
if(!ph) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.proterr);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
pbuf_free(p);
return ERR_MEM;
}
pbuf_header(ph, -(s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN); /* hide L2TP header */
pbuf_cat(ph, p);
#if LWIP_SNMP
#if MIB2_STATS
tot_len = ph->tot_len;
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
ret = pppol2tp_xmit(l2tp, ph);
if (ret != ERR_OK) {
LINK_STATS_INC(link.err);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return ret;
}
snmp_add_ifoutoctets(ppp->netif, (u16_t)tot_len);
snmp_inc_ifoutucastpkts(ppp->netif);
MIB2_STATS_NETIF_ADD(ppp->netif, ifoutoctets, (u16_t)tot_len);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutucastpkts);
LINK_STATS_INC(link.xmit);
return ERR_OK;
}
@ -215,18 +215,18 @@ static err_t pppol2tp_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_sh
struct pbuf *pb;
u8_t *pl;
err_t err;
#if LWIP_SNMP
#if MIB2_STATS
u16_t tot_len;
#else /* LWIP_SNMP */
#else /* MIB2_STATS */
LWIP_UNUSED_ARG(ppp);
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
/* @todo: try to use pbuf_header() here! */
pb = pbuf_alloc(PBUF_TRANSPORT, PPPOL2TP_OUTPUT_DATA_HEADER_LEN + sizeof(protocol), PBUF_RAM);
if(!pb) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.proterr);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return ERR_MEM;
}
@ -236,18 +236,18 @@ static err_t pppol2tp_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_sh
PUTSHORT(protocol, pl);
pbuf_chain(pb, p);
#if LWIP_SNMP
#if MIB2_STATS
tot_len = pb->tot_len;
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
if( (err = pppol2tp_xmit(l2tp, pb)) != ERR_OK) {
LINK_STATS_INC(link.err);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return err;
}
snmp_add_ifoutoctets(ppp->netif, tot_len);
snmp_inc_ifoutucastpkts(ppp->netif);
MIB2_STATS_NETIF_ADD(ppp->netif, ifoutoctets, tot_len);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutucastpkts);
LINK_STATS_INC(link.xmit);
return ERR_OK;
}

View File

@ -41,7 +41,7 @@
#include "lwip/sys.h"
#include "lwip/memp.h"
#include "lwip/netif.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/tcpip.h"
#include "lwip/api.h"
#include "lwip/sio.h"
@ -211,7 +211,7 @@ pppos_write(ppp_pcb *ppp, void *ctx, struct pbuf *p)
PPPDEBUG(LOG_WARNING, ("pppos_write[%d]: alloc fail\n", ppp->netif->num));
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
pbuf_free(p);
return ERR_MEM;
}
@ -257,7 +257,7 @@ pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u16_t protocol)
PPPDEBUG(LOG_WARNING, ("pppos_netif_output[%d]: alloc fail\n", ppp->netif->num));
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
return ERR_MEM;
}
@ -575,7 +575,7 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l)
PPPDEBUG(LOG_ERR, ("pppos_input[%d]: tcpip_callback() failed, dropping packet\n", ppp->netif->num));
pbuf_free(inp);
LINK_STATS_INC(link.drop);
snmp_inc_ifindiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifindiscards);
}
#else /* PPP_INPROC_IRQ_SAFE */
ppp_input(ppp, inp);
@ -736,7 +736,7 @@ static void pppos_input_callback(void *arg) {
drop:
LINK_STATS_INC(link.drop);
snmp_inc_ifindiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifindiscards);
pbuf_free(pb);
}
#endif /* PPP_INPROC_IRQ_SAFE */
@ -838,7 +838,7 @@ pppos_input_drop(pppos_pcb *pppos)
#endif /* VJ_SUPPORT */
LINK_STATS_INC(link.drop);
snmp_inc_ifindiscards(pppos->ppp->netif);
MIB2_STATS_NETIF_INC(pppos->ppp->netif, ifindiscards);
}
/*
@ -884,9 +884,9 @@ pppos_output_append(pppos_pcb *pppos, err_t err, struct pbuf *nb, u8_t c, u8_t a
static err_t
pppos_output_last(pppos_pcb *pppos, err_t err, struct pbuf *nb, u16_t *fcs)
{
#if LWIP_SNMP
#if MIB2_STATS
ppp_pcb *ppp = pppos->ppp;
#endif /* LWIP_SNMP */
#endif /* MIB2_STATS */
/* Add FCS and trailing flag. */
err = pppos_output_append(pppos, err, nb, ~(*fcs) & 0xFF, 1, NULL);
@ -907,8 +907,8 @@ pppos_output_last(pppos_pcb *pppos, err_t err, struct pbuf *nb, u16_t *fcs)
}
pppos->last_xmit = sys_jiffies();
snmp_add_ifoutoctets(ppp->netif, nb->tot_len);
snmp_inc_ifoutucastpkts(ppp->netif);
MIB2_STATS_NETIF_ADD(ppp->netif, ifoutoctets, nb->tot_len);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutucastpkts);
LINK_STATS_INC(link.xmit);
pbuf_free(nb);
return ERR_OK;
@ -917,7 +917,7 @@ failed:
pppos->last_xmit = 0; /* prepend PPP_FLAG to next packet */
LINK_STATS_INC(link.err);
LINK_STATS_INC(link.drop);
snmp_inc_ifoutdiscards(ppp->netif);
MIB2_STATS_NETIF_INC(ppp->netif, ifoutdiscards);
pbuf_free(nb);
return err;
}

View File

@ -63,7 +63,7 @@
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "lwip/snmp_mib2.h"
#include "lwip/sys.h"
#include "lwip/sio.h"
@ -396,7 +396,7 @@ slipif_init(struct netif *netif)
netif->state = priv;
/* initialize the snmp variables and counters inside the struct netif */
NETIF_INIT_SNMP(netif, snmp_ifType_slip, SLIP_SIO_SPEED(priv->sd));
MIB2_INIT_NETIF(netif, snmp_ifType_slip, SLIP_SIO_SPEED(priv->sd));
#if SLIP_USE_RX_THREAD
/* Create a thread to poll the serial line. */