Added SNMP counters, moved some defines.

This commit is contained in:
christiaans 2006-08-11 14:12:05 +00:00
parent 19f57bf810
commit 43bf9a8e46
4 changed files with 43 additions and 17 deletions

View File

@ -114,14 +114,14 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
if (netif == NULL) {
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%"X32_F" found\n",
iphdr->dest.addr));
snmp_inc_ipnoroutes();
snmp_inc_ipoutnoroutes();
return (struct netif *)NULL;
}
/* Do not forward packets onto the same network interface on which
* they arrived. */
if (netif == inp) {
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
snmp_inc_ipnoroutes();
snmp_inc_ipoutnoroutes();
return (struct netif *)NULL;
}
@ -129,10 +129,10 @@ ip_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();
/* Don't send ICMP messages in response to ICMP messages */
if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
icmp_time_exceeded(p, ICMP_TE_TTL);
snmp_inc_icmpouttimeexcds();
}
return (struct netif *)NULL;
}
@ -149,7 +149,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
IP_STATS_INC(ip.fw);
IP_STATS_INC(ip.xmit);
snmp_inc_ipforwdatagrams();
snmp_inc_ipforwdatagrams();
PERF_STOP("ip_forward");
/* transmit pbuf on chosen interface */
@ -188,7 +188,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
pbuf_free(p);
IP_STATS_INC(ip.err);
IP_STATS_INC(ip.drop);
snmp_inc_ipunknownprotos();
snmp_inc_ipinhdrerrors();
return ERR_OK;
}
/* obtain IP header length in number of 32-bit words */
@ -217,7 +217,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
pbuf_free(p);
IP_STATS_INC(ip.chkerr);
IP_STATS_INC(ip.drop);
snmp_inc_ipindiscards();
snmp_inc_ipinhdrerrors();
return ERR_OK;
}
#endif
@ -279,6 +279,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
else
#endif /* IP_FORWARD */
{
snmp_inc_ipinaddrerrors();
snmp_inc_ipindiscards();
}
pbuf_free(p);
@ -302,6 +303,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
ntohs(IPH_OFFSET(iphdr))));
IP_STATS_INC(ip.opterr);
IP_STATS_INC(ip.drop);
/* unsupported protocol feature */
snmp_inc_ipunknownprotos();
return ERR_OK;
#endif /* IP_REASSEMBLY */
@ -313,6 +315,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
pbuf_free(p);
IP_STATS_INC(ip.opterr);
IP_STATS_INC(ip.drop);
/* unsupported protocol feature */
snmp_inc_ipunknownprotos();
return ERR_OK;
}
@ -359,7 +362,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
IP_STATS_INC(ip.proterr);
IP_STATS_INC(ip.drop);
snmp_inc_ipunknownprotos();
snmp_inc_ipinunknownprotos();
}
#if LWIP_RAW
} /* LWIP_RAW */
@ -452,7 +455,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%"X32_F"\n", dest->addr));
IP_STATS_INC(ip.rterr);
snmp_inc_ipoutdiscards();
snmp_inc_ipoutnoroutes();
return ERR_RTE;
}

View File

@ -43,11 +43,9 @@
#include "lwip/ip.h"
#include "lwip/ip_frag.h"
#include "lwip/netif.h"
#include "lwip/snmp.h"
#include "lwip/stats.h"
#define IP_REASS_BUFSIZE 5760
#define IP_REASS_MAXAGE 3
static u8_t ip_reassbuf[IP_HLEN + IP_REASS_BUFSIZE];
static u8_t ip_reassbitmap[IP_REASS_BUFSIZE / (8 * 8) + 1];
static const u8_t bitmap_bits[8] = { 0xff, 0x7f, 0x3f, 0x1f,
@ -110,6 +108,10 @@ ip_reass_tmr(void)
if (ip_reasstmr > 0) {
ip_reasstmr--;
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n",(u16_t)ip_reasstmr));
if (ip_reasstmr == 0) {
/* reassembly timed out */
snmp_inc_ipreasmfails();
}
}
}
@ -128,6 +130,7 @@ ip_reass(struct pbuf *p)
u16_t i;
IPFRAG_STATS_INC(ip_frag.recv);
snmp_inc_ipreasmreqds();
iphdr = (struct ip_hdr *) ip_reassbuf;
fraghdr = (struct ip_hdr *) p->payload;
@ -164,6 +167,7 @@ ip_reass(struct pbuf *p)
("ip_reass: fragment outside of buffer (%"S16_F":%"S16_F"/%"S16_F").\n", offset,
offset + len, IP_REASS_BUFSIZE));
ip_reasstmr = 0;
snmp_inc_ipreasmfails();
goto nullreturn;
}
@ -276,10 +280,12 @@ ip_reass(struct pbuf *p)
i += q->len;
}
IPFRAG_STATS_INC(ip_frag.fw);
snmp_inc_ipreasmoks();
} else {
LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: pbuf_alloc(PBUF_LINK, ip_reasslen=%"U16_F", PBUF_POOL) failed\n", ip_reasslen));
IPFRAG_STATS_INC(ip_frag.memerr);
snmp_inc_ipreasmfails();
}
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p));
return p;
@ -368,6 +374,7 @@ ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest)
pbuf_chain(header, rambuf);
netif->output(netif, header, dest);
IPFRAG_STATS_INC(ip_frag.xmit);
snmp_inc_ipfragcreates();
pbuf_free(header);
} else {
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc() for header failed\n"));
@ -377,5 +384,6 @@ ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest)
left -= cop;
}
pbuf_free(rambuf);
snmp_inc_ipfragoks();
return ERR_OK;
}

View File

@ -39,8 +39,17 @@
#include "lwip/netif.h"
#include "lwip/ip_addr.h"
#ifndef IP_REASS_INTERVAL
/* IP reassemly timer interval in milliseconds */
#define IP_REASS_INTERVAL 1000
/* IP reassemly default age in seconds */
#ifndef IP_REASS_MAXAGE
#define IP_REASS_MAXAGE 3
#endif
/* IP reassembly buffer size (minus IP header) */
#ifndef IP_REASS_BUFSIZE
#define IP_REASS_BUFSIZE 5760
#endif
void ip_frag_init(void);

View File

@ -216,10 +216,15 @@ a lot of data that needs to be copied, this should be set high. */
#define IP_FRAG 1
#endif
/** Global default value for Time To Live used by transport layers. */
#ifndef IP_DEFAULT_TTL
#define IP_DEFAULT_TTL 255
#endif
/* ---------- ICMP options ---------- */
#ifndef ICMP_TTL
#define ICMP_TTL 255
#define ICMP_TTL (IP_DEFAULT_TTL)
#endif
/* ---------- RAW options ---------- */
@ -229,7 +234,7 @@ a lot of data that needs to be copied, this should be set high. */
#endif
#ifndef RAW_TTL
#define RAW_TTL 255
#define RAW_TTL (IP_DEFAULT_TTL)
#endif
/* ---------- DHCP options ---------- */
@ -245,7 +250,8 @@ a lot of data that needs to be copied, this should be set high. */
#endif
/* ---------- SNMP options ---------- */
/** @todo SNMP isn't functional yet. */
/** @todo SNMP isn't functional yet.
@note UDP must be available for SNMP transport */
#ifndef LWIP_SNMP
#define LWIP_SNMP 0
#endif
@ -260,7 +266,7 @@ a lot of data that needs to be copied, this should be set high. */
#endif
#ifndef UDP_TTL
#define UDP_TTL 255
#define UDP_TTL (IP_DEFAULT_TTL)
#endif
/* ---------- TCP options ---------- */
@ -269,7 +275,7 @@ a lot of data that needs to be copied, this should be set high. */
#endif
#ifndef TCP_TTL
#define TCP_TTL 255
#define TCP_TTL (IP_DEFAULT_TTL)
#endif
#ifndef TCP_WND