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

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