Use #if not #ifdef for all STATS options. They are turned on off by defining them to 1 or 0. Make use of XXX_STATS_INC macros for udp, ip, tcp, ip_frag, link and icmp. Add IPFRAG_STATS option

This commit is contained in:
jani 2003-10-28 11:44:43 +00:00
parent 09b0d716d2
commit 21a4b68fec
17 changed files with 188 additions and 196 deletions

View File

@ -54,9 +54,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
struct ip_addr tmpaddr; struct ip_addr tmpaddr;
u16_t hlen; u16_t hlen;
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.recv);
++lwip_stats.icmp.recv;
#endif /* ICMP_STATS */
snmp_inc_icmpinmsgs(); snmp_inc_icmpinmsgs();
@ -65,9 +63,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) { if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.lenerr);
++lwip_stats.icmp.lenerr;
#endif /* ICMP_STATS */
snmp_inc_icmpinerrors(); snmp_inc_icmpinerrors();
return; return;
} }
@ -79,9 +75,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
if (ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) || if (ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||
ip_addr_ismulticast(&iphdr->dest)) { ip_addr_ismulticast(&iphdr->dest)) {
LWIP_DEBUGF(ICMP_DEBUG, ("Smurf.\n")); LWIP_DEBUGF(ICMP_DEBUG, ("Smurf.\n"));
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.err);
++lwip_stats.icmp.err;
#endif /* ICMP_STATS */
pbuf_free(p); pbuf_free(p);
return; return;
} }
@ -90,9 +84,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
if (p->tot_len < sizeof(struct icmp_echo_hdr)) { if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.lenerr);
++lwip_stats.icmp.lenerr;
#endif /* ICMP_STATS */
snmp_inc_icmpinerrors(); snmp_inc_icmpinerrors();
return; return;
@ -101,9 +93,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
if (inet_chksum_pbuf(p) != 0) { if (inet_chksum_pbuf(p) != 0) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.chkerr);
++lwip_stats.icmp.chkerr;
#endif /* ICMP_STATS */
snmp_inc_icmpinerrors(); snmp_inc_icmpinerrors();
return; return;
} }
@ -117,9 +107,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
} else { } else {
iecho->chksum += htons(ICMP_ECHO << 8); iecho->chksum += htons(ICMP_ECHO << 8);
} }
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.xmit);
++lwip_stats.icmp.xmit;
#endif /* ICMP_STATS */
/* increase number of messages attempted to send */ /* increase number of messages attempted to send */
snmp_inc_icmpoutmsgs(); snmp_inc_icmpoutmsgs();
/* increase number of echo replies attempted to send */ /* increase number of echo replies attempted to send */
@ -131,10 +119,8 @@ icmp_input(struct pbuf *p, struct netif *inp)
break; break;
default: default:
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code));
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.proterr);
++lwip_stats.icmp.proterr; ICMP_STATS_INC(icmp.drop);
++lwip_stats.icmp.drop;
#endif /* ICMP_STATS */
} }
pbuf_free(p); pbuf_free(p);
} }
@ -160,9 +146,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
/* calculate checksum */ /* calculate checksum */
idur->chksum = 0; idur->chksum = 0;
idur->chksum = inet_chksum(idur, q->len); idur->chksum = inet_chksum(idur, q->len);
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.xmit);
++lwip_stats.icmp.xmit;
#endif /* ICMP_STATS */
/* increase number of messages attempted to send */ /* increase number of messages attempted to send */
snmp_inc_icmpoutmsgs(); snmp_inc_icmpoutmsgs();
/* increase number of destination unreachable messages attempted to send */ /* increase number of destination unreachable messages attempted to send */
@ -202,9 +186,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
/* calculate checksum */ /* calculate checksum */
tehdr->chksum = 0; tehdr->chksum = 0;
tehdr->chksum = inet_chksum(tehdr, q->len); tehdr->chksum = inet_chksum(tehdr, q->len);
#ifdef ICMP_STATS ICMP_STATS_INC(icmp.xmit);
++lwip_stats.icmp.xmit;
#endif /* ICMP_STATS */
/* increase number of messages attempted to send */ /* increase number of messages attempted to send */
snmp_inc_icmpoutmsgs(); snmp_inc_icmpoutmsgs();
/* increase number of destination unreachable messages attempted to send */ /* increase number of destination unreachable messages attempted to send */

View File

@ -201,10 +201,8 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n", LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n",
iphdr->dest.addr)); iphdr->dest.addr));
#ifdef IP_STATS IP_STATS_INC(ip.fw);
++lwip_stats.ip.fw; IP_STATS_INC(ip.xmit);
++lwip_stats.ip.xmit;
#endif /* IP_STATS */
snmp_inc_ipforwdatagrams(); snmp_inc_ipforwdatagrams();
PERF_STOP("ip_forward"); PERF_STOP("ip_forward");
@ -230,9 +228,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
static struct netif *netif; static struct netif *netif;
static u16_t iphdrlen; static u16_t iphdrlen;
#ifdef IP_STATS IP_STATS_INC(ip.recv);
++lwip_stats.ip.recv;
#endif /* IP_STATS */
snmp_inc_ipinreceives(); snmp_inc_ipinreceives();
/* identify the IP header */ /* identify the IP header */
@ -243,10 +239,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
pbuf_free(p); pbuf_free(p);
#ifdef IP_STATS IP_STATS_INC(ip.err);
++lwip_stats.ip.err; IP_STATS_INC(ip.drop);
++lwip_stats.ip.drop;
#endif /* IP_STATS */
snmp_inc_ipunknownprotos(); snmp_inc_ipunknownprotos();
return ERR_OK; return ERR_OK;
} }
@ -261,10 +255,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
iphdrlen, p->len)); iphdrlen, p->len));
/* free (drop) packet pbufs */ /* free (drop) packet pbufs */
pbuf_free(p); pbuf_free(p);
#ifdef IP_STATS IP_STATS_INC(ip.lenerr);
++lwip_stats.ip.lenerr; IP_STATS_INC(ip.drop);
++lwip_stats.ip.drop;
#endif /* IP_STATS */
snmp_inc_ipindiscards(); snmp_inc_ipindiscards();
return ERR_OK; return ERR_OK;
} }
@ -277,10 +269,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
pbuf_free(p); pbuf_free(p);
#ifdef IP_STATS IP_STATS_INC(ip.chkerr);
++lwip_stats.ip.chkerr; IP_STATS_INC(ip.drop);
++lwip_stats.ip.drop;
#endif /* IP_STATS */
snmp_inc_ipindiscards(); snmp_inc_ipindiscards();
return ERR_OK; return ERR_OK;
} }
@ -365,10 +355,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
pbuf_free(p); pbuf_free(p);
LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n", LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",
ntohs(IPH_OFFSET(iphdr)))); ntohs(IPH_OFFSET(iphdr))));
#ifdef IP_STATS IP_STATS_INC(ip.opterr);
++lwip_stats.ip.opterr; IP_STATS_INC(ip.drop);
++lwip_stats.ip.drop;
#endif /* IP_STATS */
snmp_inc_ipunknownprotos(); snmp_inc_ipunknownprotos();
return ERR_OK; return ERR_OK;
} }
@ -378,10 +366,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
if (iphdrlen > IP_HLEN) { if (iphdrlen > IP_HLEN) {
LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since there were IP options (while IP_OPTIONS == 0).\n")); LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since there were IP options (while IP_OPTIONS == 0).\n"));
pbuf_free(p); pbuf_free(p);
#ifdef IP_STATS IP_STATS_INC(ip.opterr);
++lwip_stats.ip.opterr; IP_STATS_INC(ip.drop);
++lwip_stats.ip.drop;
#endif /* IP_STATS */
snmp_inc_ipunknownprotos(); snmp_inc_ipunknownprotos();
return ERR_OK; return ERR_OK;
} }
@ -427,10 +413,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %d\n", IPH_PROTO(iphdr))); LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %d\n", IPH_PROTO(iphdr)));
#ifdef IP_STATS IP_STATS_INC(ip.proterr);
++lwip_stats.ip.proterr; IP_STATS_INC(ip.drop);
++lwip_stats.ip.drop;
#endif /* IP_STATS */
snmp_inc_ipunknownprotos(); snmp_inc_ipunknownprotos();
} }
@ -463,9 +447,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
if (pbuf_header(p, IP_HLEN)) { if (pbuf_header(p, IP_HLEN)) {
LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: not enough room for IP header in pbuf\n")); LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: not enough room for IP header in pbuf\n"));
#ifdef IP_STATS IP_STATS_INC(ip.err);
++lwip_stats.ip.err;
#endif /* IP_STATS */
snmp_inc_ipoutdiscards(); snmp_inc_ipoutdiscards();
return ERR_BUF; return ERR_BUF;
} }
@ -502,9 +484,8 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
return ip_frag(p,netif,dest); return ip_frag(p,netif,dest);
#endif #endif
#ifdef IP_STATS IP_STATS_INC(ip.xmit);
lwip_stats.ip.xmit++;
#endif /* IP_STATS */
LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num));
#if IP_DEBUG #if IP_DEBUG
ip_debug_print(p); ip_debug_print(p);
@ -530,9 +511,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
if ((netif = ip_route(dest)) == NULL) { if ((netif = ip_route(dest)) == NULL) {
LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr)); LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr));
#ifdef IP_STATS IP_STATS_INC(ip.rterr);
++lwip_stats.ip.rterr;
#endif /* IP_STATS */
snmp_inc_ipoutdiscards(); snmp_inc_ipoutdiscards();
return ERR_RTE; return ERR_RTE;
} }

View File

@ -109,9 +109,7 @@ ip_reass(struct pbuf *p)
u16_t offset, len; u16_t offset, len;
u16_t i; u16_t i;
#ifdef IP_STATS IPFRAG_STATS_INC(ip_frag.recv);
++lwip_stats.ip_frag.recv;
#endif /* IP_STATS */
iphdr = (struct ip_hdr *) ip_reassbuf; iphdr = (struct ip_hdr *) ip_reassbuf;
fraghdr = (struct ip_hdr *) p->payload; fraghdr = (struct ip_hdr *) p->payload;
@ -135,9 +133,7 @@ ip_reass(struct pbuf *p)
ip_addr_cmp(&iphdr->dest, &fraghdr->dest) && ip_addr_cmp(&iphdr->dest, &fraghdr->dest) &&
IPH_ID(iphdr) == IPH_ID(fraghdr)) { IPH_ID(iphdr) == IPH_ID(fraghdr)) {
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching old packet\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching old packet\n"));
#ifdef IP_STATS IPFRAG_STATS_INC(ip_frag.cachehit);
++lwip_stats.ip_frag.cachehit;
#endif /* IP_STATS */
/* Find out the offset in the reassembly buffer where we should /* Find out the offset in the reassembly buffer where we should
copy the fragment. */ copy the fragment. */
len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4;
@ -255,13 +251,9 @@ ip_reass(struct pbuf *p)
q->len > ip_reasslen - i ? ip_reasslen - i : q->len); q->len > ip_reasslen - i ? ip_reasslen - i : q->len);
i += q->len; i += q->len;
} }
#ifdef IP_STATS IPFRAG_STATS_INC(ip_frag.fw);
++lwip_stats.ip_frag.fw;
#endif /* IP_STATS */
} else { } else {
#ifdef IP_STATS IPFRAG_STATS_INC(ip_frag.memerr);
++lwip_stats.ip_frag.memerr;
#endif /* IP_STATS */
} }
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p)); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p));
return p; return p;
@ -269,9 +261,7 @@ ip_reass(struct pbuf *p)
} }
nullreturn: nullreturn:
#ifdef IP_STATS IPFRAG_STATS_INC(ip_frag.drop);
++lwip_stats.ip_frag.drop;
#endif /* IP_STATS */
pbuf_free(p); pbuf_free(p);
return NULL; return NULL;
} }
@ -347,9 +337,7 @@ ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest)
header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM);
pbuf_chain(header, rambuf); pbuf_chain(header, rambuf);
netif->output(netif, header, dest); netif->output(netif, header, dest);
#ifdef IP_STATS IPFRAG_STATS_INC(ip_frag.xmit);
++lwip_stats.ip_frag.xmit;
#endif /* IP_STATS */
pbuf_free(header); pbuf_free(header);
left -= cop; left -= cop;

View File

@ -127,7 +127,7 @@ mem_init(void)
lfree = (struct mem *)ram; lfree = (struct mem *)ram;
#ifdef MEM_STATS #if MEM_STATS
lwip_stats.mem.avail = MEM_SIZE; lwip_stats.mem.avail = MEM_SIZE;
#endif /* MEM_STATS */ #endif /* MEM_STATS */
} }
@ -148,7 +148,7 @@ mem_free(void *rmem)
if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) {
LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n")); LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n"));
#ifdef MEM_STATS #if MEM_STATS
++lwip_stats.mem.err; ++lwip_stats.mem.err;
#endif /* MEM_STATS */ #endif /* MEM_STATS */
sys_sem_signal(mem_sem); sys_sem_signal(mem_sem);
@ -164,7 +164,7 @@ mem_free(void *rmem)
lfree = mem; lfree = mem;
} }
#ifdef MEM_STATS #if MEM_STATS
lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram); lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram);
#endif /* MEM_STATS */ #endif /* MEM_STATS */
@ -215,7 +215,7 @@ mem_realloc(void *rmem, mem_size_t newsize)
ptr = (u8_t *)mem - ram; ptr = (u8_t *)mem - ram;
size = mem->next - ptr - SIZEOF_STRUCT_MEM; size = mem->next - ptr - SIZEOF_STRUCT_MEM;
#ifdef MEM_STATS #if MEM_STATS
lwip_stats.mem.used -= (size - newsize); lwip_stats.mem.used -= (size - newsize);
#endif /* MEM_STATS */ #endif /* MEM_STATS */
@ -273,7 +273,7 @@ mem_malloc(mem_size_t size)
mem2->used = 0; mem2->used = 0;
mem->used = 1; mem->used = 1;
#ifdef MEM_STATS #if MEM_STATS
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM); lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
/* if (lwip_stats.mem.max < lwip_stats.mem.used) { /* if (lwip_stats.mem.max < lwip_stats.mem.used) {
lwip_stats.mem.max = lwip_stats.mem.used; lwip_stats.mem.max = lwip_stats.mem.used;
@ -299,7 +299,7 @@ mem_malloc(mem_size_t size)
} }
} }
LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %d bytes\n", (int)size)); LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %d bytes\n", (int)size));
#ifdef MEM_STATS #if MEM_STATS
++lwip_stats.mem.err; ++lwip_stats.mem.err;
#endif /* MEM_STATS */ #endif /* MEM_STATS */
sys_sem_signal(mem_sem); sys_sem_signal(mem_sem);

View File

@ -149,7 +149,7 @@ memp_init(void)
u16_t i, j; u16_t i, j;
u16_t size; u16_t size;
#ifdef MEMP_STATS #if MEMP_STATS
for(i = 0; i < MEMP_MAX; ++i) { for(i = 0; i < MEMP_MAX; ++i) {
lwip_stats.memp[i].used = lwip_stats.memp[i].max = lwip_stats.memp[i].used = lwip_stats.memp[i].max =
lwip_stats.memp[i].err = 0; lwip_stats.memp[i].err = 0;
@ -205,7 +205,7 @@ memp_malloc(memp_t type)
if (memp != NULL) { if (memp != NULL) {
memp_tab[type] = memp->next; memp_tab[type] = memp->next;
memp->next = NULL; memp->next = NULL;
#ifdef MEMP_STATS #if MEMP_STATS
++lwip_stats.memp[type].used; ++lwip_stats.memp[type].used;
if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) { if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) {
lwip_stats.memp[type].max = lwip_stats.memp[type].used; lwip_stats.memp[type].max = lwip_stats.memp[type].used;
@ -225,7 +225,7 @@ memp_malloc(memp_t type)
return mem; return mem;
} else { } else {
LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type)); LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type));
#ifdef MEMP_STATS #if MEMP_STATS
++lwip_stats.memp[type].err; ++lwip_stats.memp[type].err;
#endif /* MEMP_STATS */ #endif /* MEMP_STATS */
#if SYS_LIGHTWEIGHT_PROT #if SYS_LIGHTWEIGHT_PROT
@ -256,7 +256,7 @@ memp_free(memp_t type, void *mem)
sys_sem_wait(mutex); sys_sem_wait(mutex);
#endif /* SYS_LIGHTWEIGHT_PROT */ #endif /* SYS_LIGHTWEIGHT_PROT */
#ifdef MEMP_STATS #if MEMP_STATS
lwip_stats.memp[type].used--; lwip_stats.memp[type].used--;
#endif /* MEMP_STATS */ #endif /* MEMP_STATS */

View File

@ -102,7 +102,7 @@ pbuf_init(void)
pbuf_pool = (struct pbuf *)&pbuf_pool_memory[0]; pbuf_pool = (struct pbuf *)&pbuf_pool_memory[0];
LWIP_ASSERT("pbuf_init: pool aligned", (long)pbuf_pool % MEM_ALIGNMENT == 0); LWIP_ASSERT("pbuf_init: pool aligned", (long)pbuf_pool % MEM_ALIGNMENT == 0);
#ifdef PBUF_STATS #if PBUF_STATS
lwip_stats.pbuf.avail = PBUF_POOL_SIZE; lwip_stats.pbuf.avail = PBUF_POOL_SIZE;
#endif /* PBUF_STATS */ #endif /* PBUF_STATS */
@ -144,7 +144,7 @@ pbuf_pool_alloc(void)
/* Next, check the actual pbuf pool, but if the pool is locked, we /* Next, check the actual pbuf pool, but if the pool is locked, we
pretend to be out of buffers and return NULL. */ pretend to be out of buffers and return NULL. */
if (pbuf_pool_free_lock) { if (pbuf_pool_free_lock) {
#ifdef PBUF_STATS #if PBUF_STATS
++lwip_stats.pbuf.alloc_locked; ++lwip_stats.pbuf.alloc_locked;
#endif /* PBUF_STATS */ #endif /* PBUF_STATS */
return NULL; return NULL;
@ -157,7 +157,7 @@ pbuf_pool_alloc(void)
pbuf_pool = p->next; pbuf_pool = p->next;
} }
#if !SYS_LIGHTWEIGHT_PROT #if !SYS_LIGHTWEIGHT_PROT
#ifdef PBUF_STATS #if PBUF_STATS
} else { } else {
++lwip_stats.pbuf.alloc_locked; ++lwip_stats.pbuf.alloc_locked;
#endif /* PBUF_STATS */ #endif /* PBUF_STATS */
@ -165,7 +165,7 @@ pbuf_pool_alloc(void)
pbuf_pool_alloc_lock = 0; pbuf_pool_alloc_lock = 0;
#endif /* SYS_LIGHTWEIGHT_PROT */ #endif /* SYS_LIGHTWEIGHT_PROT */
#ifdef PBUF_STATS #if PBUF_STATS
if (p != NULL) { if (p != NULL) {
++lwip_stats.pbuf.used; ++lwip_stats.pbuf.used;
if (lwip_stats.pbuf.used > lwip_stats.pbuf.max) { if (lwip_stats.pbuf.used > lwip_stats.pbuf.max) {
@ -244,7 +244,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
p = pbuf_pool_alloc(); p = pbuf_pool_alloc();
LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));
if (p == NULL) { if (p == NULL) {
#ifdef PBUF_STATS #if PBUF_STATS
++lwip_stats.pbuf.err; ++lwip_stats.pbuf.err;
#endif /* PBUF_STATS */ #endif /* PBUF_STATS */
return NULL; return NULL;
@ -273,7 +273,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
q = pbuf_pool_alloc(); q = pbuf_pool_alloc();
if (q == NULL) { if (q == NULL) {
LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n")); LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n"));
#ifdef PBUF_STATS #if PBUF_STATS
++lwip_stats.pbuf.err; ++lwip_stats.pbuf.err;
#endif /* PBUF_STATS */ #endif /* PBUF_STATS */
/* free chain so far allocated */ /* free chain so far allocated */
@ -343,7 +343,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
} }
#ifdef PBUF_STATS #if PBUF_STATS
#define DEC_PBUF_STATS do { --lwip_stats.pbuf.used; } while (0) #define DEC_PBUF_STATS do { --lwip_stats.pbuf.used; } while (0)
#else /* PBUF_STATS */ #else /* PBUF_STATS */
#define DEC_PBUF_STATS #define DEC_PBUF_STATS

View File

@ -209,7 +209,7 @@ raw_send_to(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr)
if ((netif = ip_route(ipaddr)) == NULL) { if ((netif = ip_route(ipaddr)) == NULL) {
LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_send_to: No route to 0x%lx\n", ipaddr->addr)); LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_send_to: No route to 0x%lx\n", ipaddr->addr));
#ifdef RAW_STATS #if RAW_STATS
/* ++lwip_stats.raw.rterr;*/ /* ++lwip_stats.raw.rterr;*/
#endif /* RAW_STATS */ #endif /* RAW_STATS */
if (q != p) { if (q != p) {

View File

@ -110,10 +110,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
PERF_START; PERF_START;
TCP_STATS_INC(tcp.recv);
#ifdef TCP_STATS
++lwip_stats.tcp.recv;
#endif /* TCP_STATS */
iphdr = p->payload; iphdr = p->payload;
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4); tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
@ -126,10 +123,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) {
/* drop short packets */ /* drop short packets */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len)); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len));
#ifdef TCP_STATS TCP_STATS_INC(tcp.lenerr);
++lwip_stats.tcp.lenerr; TCP_STATS_INC(tcp.drop);
++lwip_stats.tcp.drop;
#endif /* TCP_STATS */
pbuf_free(p); pbuf_free(p);
return; return;
} }
@ -151,10 +146,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
#if TCP_DEBUG #if TCP_DEBUG
tcp_debug_print(tcphdr); tcp_debug_print(tcphdr);
#endif /* TCP_DEBUG */ #endif /* TCP_DEBUG */
#ifdef TCP_STATS TCP_STATS_INC(tcp.chkerr);
++lwip_stats.tcp.chkerr; TCP_STATS_INC(tcp.drop);
++lwip_stats.tcp.drop;
#endif /* TCP_STATS */
pbuf_free(p); pbuf_free(p);
return; return;
@ -391,10 +384,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
sender. */ sender. */
LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));
if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) { if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) {
#ifdef TCP_STATS TCP_STATS_INC(tcp.proterr);
++lwip_stats.tcp.proterr; TCP_STATS_INC(tcp.drop);
++lwip_stats.tcp.drop;
#endif /* TCP_STATS */
tcp_rst(ackno, seqno + tcplen, tcp_rst(ackno, seqno + tcplen,
&(iphdr->dest), &(iphdr->src), &(iphdr->dest), &(iphdr->src),
tcphdr->dest, tcphdr->src); tcphdr->dest, tcphdr->src);
@ -437,9 +428,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
SYN at a time when we have more memory available. */ SYN at a time when we have more memory available. */
if (npcb == NULL) { if (npcb == NULL) {
LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n"));
#ifdef TCP_STATS TCP_STATS_INC(tcp.memerr);
++lwip_stats.tcp.memerr;
#endif /* TCP_STATS */
return ERR_MEM; return ERR_MEM;
} }
/* Set up the new PCB. */ /* Set up the new PCB. */

View File

@ -234,9 +234,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: no room for TCP header in pbuf.\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: no room for TCP header in pbuf.\n"));
#ifdef TCP_STATS TCP_STATS_INC(tcp.err);
++lwip_stats.tcp.err;
#endif /* TCP_STATS */
goto memerr; goto memerr;
} }
seg->tcphdr = seg->p->payload; seg->tcphdr = seg->p->payload;
@ -332,9 +330,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
return ERR_OK; return ERR_OK;
memerr: memerr:
#ifdef TCP_STATS TCP_STATS_INC(tcp.memerr);
++lwip_stats.tcp.memerr;
#endif /* TCP_STATS */
if (queue != NULL) { if (queue != NULL) {
tcp_segs_free(queue); tcp_segs_free(queue);
@ -524,9 +520,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
&(pcb->local_ip), &(pcb->local_ip),
&(pcb->remote_ip), &(pcb->remote_ip),
IP_PROTO_TCP, seg->p->tot_len); IP_PROTO_TCP, seg->p->tot_len);
#ifdef TCP_STATS TCP_STATS_INC(tcp.xmit);
++lwip_stats.tcp.xmit;
#endif /* TCP_STATS */
ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
IP_PROTO_TCP); IP_PROTO_TCP);
@ -559,9 +553,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip, tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip,
IP_PROTO_TCP, p->tot_len); IP_PROTO_TCP, p->tot_len);
#ifdef TCP_STATS TCP_STATS_INC(tcp.xmit);
++lwip_stats.tcp.xmit;
#endif /* TCP_STATS */
/* Send output with hardcoded TTL since we have no access to the pcb */ /* Send output with hardcoded TTL since we have no access to the pcb */
ip_output(p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP); ip_output(p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP);
pbuf_free(p); pbuf_free(p);
@ -629,9 +621,7 @@ tcp_keepalive(struct tcp_pcb *pcb)
tcphdr->chksum = 0; tcphdr->chksum = 0;
tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, IP_PROTO_TCP, p->tot_len); tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, IP_PROTO_TCP, p->tot_len);
#ifdef TCP_STATS TCP_STATS_INC(tcp.xmit);
++lwip_stats.tcp.xmit;
#endif /* TCP_STATS */
/* Send output to IP */ /* Send output to IP */
ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP);

View File

@ -172,19 +172,15 @@ udp_input(struct pbuf *p, struct netif *inp)
PERF_START; PERF_START;
#ifdef UDP_STATS UDP_STATS_INC(udp.recv);
++lwip_stats.udp.recv;
#endif /* UDP_STATS */
iphdr = p->payload; iphdr = p->payload;
if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) { if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) {
/* drop short packets */ /* drop short packets */
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len)); LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len));
#ifdef UDP_STATS UDP_STATS_INC(udp.lenerr);
++lwip_stats.udp.lenerr; UDP_STATS_INC(udp.drop);
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
snmp_inc_udpinerrors(); snmp_inc_udpinerrors();
pbuf_free(p); pbuf_free(p);
goto end; goto end;
@ -330,10 +326,8 @@ udp_input(struct pbuf *p, struct netif *inp)
(struct ip_addr *)&(iphdr->dest), (struct ip_addr *)&(iphdr->dest),
IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) { IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) {
LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n")); LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n"));
#ifdef UDP_STATS UDP_STATS_INC(udp.chkerr);
++lwip_stats.udp.chkerr; UDP_STATS_INC(udp.drop);
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
snmp_inc_udpinerrors(); snmp_inc_udpinerrors();
pbuf_free(p); pbuf_free(p);
goto end; goto end;
@ -345,10 +339,8 @@ udp_input(struct pbuf *p, struct netif *inp)
IP_PROTO_UDP, p->tot_len) != 0) { IP_PROTO_UDP, p->tot_len) != 0) {
LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n")); LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n"));
#ifdef UDP_STATS UDP_STATS_INC(udp.chkerr);
++lwip_stats.udp.chkerr; UDP_STATS_INC(udp.drop);
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
snmp_inc_udpinerrors(); snmp_inc_udpinerrors();
pbuf_free(p); pbuf_free(p);
goto end; goto end;
@ -398,10 +390,8 @@ udp_input(struct pbuf *p, struct netif *inp)
p->payload = iphdr; p->payload = iphdr;
icmp_dest_unreach(p, ICMP_DUR_PORT); icmp_dest_unreach(p, ICMP_DUR_PORT);
} }
#ifdef UDP_STATS UDP_STATS_INC(udp.proterr);
++lwip_stats.udp.proterr; UDP_STATS_INC(udp.drop);
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
snmp_inc_udpnoports(); snmp_inc_udpnoports();
pbuf_free(p); pbuf_free(p);
} }
@ -474,9 +464,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr)); LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
#ifdef UDP_STATS UDP_STATS_INC(udp.rterr);
++lwip_stats.udp.rterr;
#endif /* UDP_STATS */
return ERR_RTE; return ERR_RTE;
} }
/* using IP_ANY_ADDR? */ /* using IP_ANY_ADDR? */
@ -525,9 +513,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
pbuf_free(q); pbuf_free(q);
} }
#ifdef UDP_STATS UDP_STATS_INC(udp.xmit);
++lwip_stats.udp.xmit;
#endif /* UDP_STATS */
return err; return err;
} }
@ -703,9 +689,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr)); LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr));
#ifdef UDP_STATS UDP_STATS_INC(udp.rterr);
++lwip_stats.udp.rterr;
#endif /* UDP_STATS */
return ERR_RTE; return ERR_RTE;
} }
/** TODO: this will bind the udp pcb locally, to the interface which /** TODO: this will bind the udp pcb locally, to the interface which

View File

@ -348,6 +348,10 @@ a lot of data that needs to be copied, this should be set high. */
#define IP_STATS 1 #define IP_STATS 1
#endif #endif
#ifndef IPFRAG_STATS
#define IPFRAG_STATS 1
#endif
#ifndef ICMP_STATS #ifndef ICMP_STATS
#define ICMP_STATS 1 #define ICMP_STATS 1
#endif #endif
@ -376,6 +380,19 @@ a lot of data that needs to be copied, this should be set high. */
#define SYS_STATS 1 #define SYS_STATS 1
#endif #endif
#else
#define LINK_STATS 0
#define IP_STATS 0
#define IPFRAG_STATS 0
#define ICMP_STATS 0
#define UDP_STATS 0
#define TCP_STATS 0
#define MEM_STATS 0
#define MEMP_STATS 0
#define PBUF_STATS 0
#define SYS_STATS 0
#endif /* LWIP_STATS */ #endif /* LWIP_STATS */
/* ---------- PPP options ---------- */ /* ---------- PPP options ---------- */

View File

@ -101,9 +101,49 @@ extern struct stats_ lwip_stats;
void stats_init(void); void stats_init(void);
#define STATS_INC(x) ++lwip_stats.x
#else #else
#define stats_init() #define stats_init()
#define STATS_INC(x)
#endif /* LWIP_STATS */ #endif /* LWIP_STATS */
#if TCP_STATS
#define TCP_STATS_INC(x) STATS_INC(x)
#else
#define TCP_STATS_INC(x)
#endif
#if UDP_STATS
#define UDP_STATS_INC(x) STATS_INC(x)
#else
#define UDP_STATS_INC(x)
#endif
#if ICMP_STATS
#define ICMP_STATS_INC(x) STATS_INC(x)
#else
#define ICMP_STATS_INC(x)
#endif
#if IP_STATS
#define IP_STATS_INC(x) STATS_INC(x)
#else
#define IP_STATS_INC(x)
#endif
#if IPFRAG_STATS
#define IPFRAG_STATS_INC(x) STATS_INC(x)
#else
#define IPFRAG_STATS_INC(x)
#endif
#if LINK_STATS
#define LINK_STATS_INC(x) STATS_INC(x)
#else
#define LINK_STATS_INC(x)
#endif
#endif /* __LWIP_STATS_H__ */ #endif /* __LWIP_STATS_H__ */

View File

@ -535,9 +535,7 @@ etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
/* The pbuf_header() call shouldn't fail, and we'll just bail /* The pbuf_header() call shouldn't fail, and we'll just bail
out if it does.. */ out if it does.. */
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n"));
#ifdef LINK_STATS LINK_STATS_INC(link.lenerr);
++lwip_stats.link.lenerr;
#endif /* LINK_STATS */
return NULL; return NULL;
} }

View File

@ -307,7 +307,7 @@ void pppInit(void)
(*protp->init)(i); (*protp->init)(i);
} }
#ifdef LINK_STATS #if LINK_STATS
/* Clear the statistics. */ /* Clear the statistics. */
memset(&lwip_stats.link, 0, sizeof(lwip_stats.link)); memset(&lwip_stats.link, 0, sizeof(lwip_stats.link));
#endif #endif
@ -482,7 +482,7 @@ static void nPut(PPPControl *pc, struct pbuf *nb)
if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) { if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) {
PPPDEBUG((LOG_WARNING, PPPDEBUG((LOG_WARNING,
"PPP nPut: incomplete sio_write(%d,, %u) = %d\n", pc->fd, b->len, c)); "PPP nPut: incomplete sio_write(%d,, %u) = %d\n", pc->fd, b->len, c));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.err++; lwip_stats.link.err++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
pc->lastXMit = 0; /* prepend PPP_FLAG to next packet */ pc->lastXMit = 0; /* prepend PPP_FLAG to next packet */
@ -491,7 +491,7 @@ static void nPut(PPPControl *pc, struct pbuf *nb)
} }
pbuf_free(nb); pbuf_free(nb);
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.xmit++; lwip_stats.link.xmit++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
} }
@ -515,7 +515,7 @@ static struct pbuf *pppAppend(u_char c, struct pbuf *nb, ext_accm *outACCM)
if (tb) { if (tb) {
nb->next = tb; nb->next = tb;
} }
#ifdef LINK_STATS #if LINK_STATS
else { else {
lwip_stats.link.memerr++; lwip_stats.link.memerr++;
} }
@ -552,7 +552,7 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
if (pd < 0 || pd >= NUM_PPP || !pc->openFlag || !pb) { if (pd < 0 || pd >= NUM_PPP || !pc->openFlag || !pb) {
PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: bad parms prot=%d pb=%p\n", PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: bad parms prot=%d pb=%p\n",
pd, protocol, pb)); pd, protocol, pb));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.opterr++; lwip_stats.link.opterr++;
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif #endif
@ -562,7 +562,7 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
/* Check that the link is up. */ /* Check that the link is up. */
if (lcp_phase[pd] == PHASE_DEAD) { if (lcp_phase[pd] == PHASE_DEAD) {
PPPDEBUG((LOG_ERR, "pppifOutput[%d]: link not up\n", pd)); PPPDEBUG((LOG_ERR, "pppifOutput[%d]: link not up\n", pd));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.rterr++; lwip_stats.link.rterr++;
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif #endif
@ -573,7 +573,7 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL);
if (headMB == NULL) { if (headMB == NULL) {
PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: first alloc fail\n", pd)); PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: first alloc fail\n", pd));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.memerr++; lwip_stats.link.memerr++;
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
@ -600,7 +600,7 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
break; break;
default: default:
PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: bad IP packet\n", pd)); PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: bad IP packet\n", pd));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.proterr++; lwip_stats.link.proterr++;
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif #endif
@ -662,7 +662,7 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
"pppifOutput[%d]: Alloc err - dropping proto=%d\n", "pppifOutput[%d]: Alloc err - dropping proto=%d\n",
pd, protocol)); pd, protocol));
pbuf_free(headMB); pbuf_free(headMB);
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.memerr++; lwip_stats.link.memerr++;
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif #endif
@ -751,7 +751,7 @@ int pppWrite(int pd, const u_char *s, int n)
struct pbuf *headMB = NULL, *tailMB; struct pbuf *headMB = NULL, *tailMB;
headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL);
if (headMB == NULL) { if (headMB == NULL) {
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.memerr++; lwip_stats.link.memerr++;
lwip_stats.link.proterr++; lwip_stats.link.proterr++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
@ -791,7 +791,7 @@ int pppWrite(int pd, const u_char *s, int n)
"pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->len)); "pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->len));
/* "pppWrite[%d]: Alloc err - dropping %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ /* "pppWrite[%d]: Alloc err - dropping %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */
pbuf_free(headMB); pbuf_free(headMB);
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.memerr++; lwip_stats.link.memerr++;
lwip_stats.link.proterr++; lwip_stats.link.proterr++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
@ -1298,7 +1298,7 @@ static void pppInput(void *arg)
pbuf_header(nb, -(int)sizeof(struct pppInputHeader)); pbuf_header(nb, -(int)sizeof(struct pppInputHeader));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.recv++; lwip_stats.link.recv++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
@ -1388,7 +1388,7 @@ static void pppInput(void *arg)
} }
drop: drop:
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif #endif
@ -1418,7 +1418,7 @@ static void pppDrop(PPPControl *pc)
vj_uncompress_err(&pc->vjComp); vj_uncompress_err(&pc->vjComp);
#endif #endif
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
} }
@ -1456,7 +1456,7 @@ static void pppInProc(int pd, u_char *s, int l)
PPPDEBUG((LOG_WARNING, PPPDEBUG((LOG_WARNING,
"pppInProc[%d]: Dropping incomplete packet %d\n", "pppInProc[%d]: Dropping incomplete packet %d\n",
pd, pc->inState)); pd, pc->inState));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.lenerr++; lwip_stats.link.lenerr++;
#endif #endif
pppDrop(pc); pppDrop(pc);
@ -1466,7 +1466,7 @@ static void pppInProc(int pd, u_char *s, int l)
PPPDEBUG((LOG_INFO, PPPDEBUG((LOG_INFO,
"pppInProc[%d]: Dropping bad fcs 0x%04X proto=0x%04X\n", "pppInProc[%d]: Dropping bad fcs 0x%04X proto=0x%04X\n",
pd, pc->inFCS, pc->inProtocol)); pd, pc->inFCS, pc->inProtocol));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.chkerr++; lwip_stats.link.chkerr++;
#endif #endif
pppDrop(pc); pppDrop(pc);
@ -1498,7 +1498,7 @@ static void pppInProc(int pd, u_char *s, int l)
PPPDEBUG((LOG_ERR, PPPDEBUG((LOG_ERR,
"pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pd)); "pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pd));
pbuf_free(pc->inHead); pbuf_free(pc->inHead);
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.drop++; lwip_stats.link.drop++;
#endif #endif
} }
@ -1594,7 +1594,7 @@ static void pppInProc(int pd, u_char *s, int l)
* higher layers deal with it. Continue processing * higher layers deal with it. Continue processing
* the received pbuf chain in case a new packet starts. */ * the received pbuf chain in case a new packet starts. */
PPPDEBUG((LOG_ERR, "pppInProc[%d]: NO FREE MBUFS!\n", pd)); PPPDEBUG((LOG_ERR, "pppInProc[%d]: NO FREE MBUFS!\n", pd));
#ifdef LINK_STATS #if LINK_STATS
lwip_stats.link.memerr++; lwip_stats.link.memerr++;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
pppDrop(pc); pppDrop(pc);

View File

@ -35,7 +35,7 @@
#if VJ_SUPPORT > 0 #if VJ_SUPPORT > 0
#ifdef LINK_STATS #if LINK_STATS
#define INCR(counter) ++comp->stats.counter #define INCR(counter) ++comp->stats.counter
#else #else
#define INCR(counter) #define INCR(counter)
@ -574,6 +574,33 @@ int vj_uncompress_tcp(
/* Remove the compressed header and prepend the uncompressed header. */ /* Remove the compressed header and prepend the uncompressed header. */
pbuf_header(n0, -vjlen); pbuf_header(n0, -vjlen);
if(MEM_ALIGN(n0->payload) != n0->payload) {
struct pbuf *np, *q;
u8_t *bufptr;
np = pbuf_alloc(PBUF_RAW, n0->len + cs->cs_hlen, PBUF_POOL);
if(!np) {
PPPDEBUG((LOG_WARNING, "vj_uncompress_tcp: realign failed\n"));
*nb = NULL;
goto bad;
}
pbuf_header(np, -cs->cs_hlen);
bufptr = n0->payload;
for(q = np; q != NULL; q = q->next) {
memcpy(q->payload, bufptr, q->len);
bufptr += q->len;
}
if(n0->next) {
pbuf_chain(np, n0->next);
pbuf_dechain(n0);
}
pbuf_free(n0);
n0 = np;
}
if(pbuf_header(n0, cs->cs_hlen)) { if(pbuf_header(n0, cs->cs_hlen)) {
struct pbuf *np; struct pbuf *np;
@ -585,8 +612,10 @@ int vj_uncompress_tcp(
goto bad; goto bad;
} }
pbuf_chain(np, n0); pbuf_chain(np, n0);
pbuf_free(n0);
n0 = np; n0 = np;
} }
LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen);
memcpy(n0->payload, &cs->cs_ip, cs->cs_hlen); memcpy(n0->payload, &cs->cs_ip, cs->cs_hlen);
*nb = n0; *nb = n0;

View File

@ -1,7 +1,7 @@
/* /*
* Definitions for tcp compression routines. * Definitions for tcp compression routines.
* *
* $Id: vj.h,v 1.2 2003/06/02 11:12:56 jani Exp $ * $Id: vj.h,v 1.2.6.1 2003/10/28 11:44:45 jani Exp $
* *
* Copyright (c) 1989 Regents of the University of California. * Copyright (c) 1989 Regents of the University of California.
* All rights reserved. * All rights reserved.
@ -136,7 +136,7 @@ struct vjcompress {
u_short flags; u_short flags;
u_char maxSlotIndex; u_char maxSlotIndex;
u_char compressSlot; /* Flag indicating OK to compress slot ID. */ u_char compressSlot; /* Flag indicating OK to compress slot ID. */
#ifdef LINK_STATS #if LINK_STATS
struct vjstat stats; struct vjstat stats;
#endif #endif
struct cstate tstate[MAX_SLOTS]; /* xmit connection states */ struct cstate tstate[MAX_SLOTS]; /* xmit connection states */

View File

@ -115,9 +115,7 @@ slipif_input( struct netif * netif )
/* Received whole packet. */ /* Received whole packet. */
pbuf_realloc(q, recved); pbuf_realloc(q, recved);
#ifdef LINK_STATS LINK_STATS_INC(link.recv);
++lwip_stats.link.recv;
#endif /* LINK_STATS */
LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n")); LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
return q; return q;
@ -141,12 +139,10 @@ slipif_input( struct netif * netif )
LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n")); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n"));
p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL); p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL);
#ifdef LINK_STATS
if (p == NULL) { if (p == NULL) {
++lwip_stats.link.drop; LINK_STATS_INC(link.drop);
LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n")); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n"));
} }
#endif /* LINK_STATS */
if (q != NULL) { if (q != NULL) {
pbuf_chain(q, p); pbuf_chain(q, p);