diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index 1ba58fc4..2f63616d 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -42,6 +42,9 @@ #include "lwip/stats.h" +#if LWIP_SNMP > 0 +# include "snmp.h" +#endif /*-----------------------------------------------------------------------------------*/ void icmp_input(struct pbuf *p, struct netif *inp) @@ -55,6 +58,9 @@ icmp_input(struct pbuf *p, struct netif *inp) #ifdef ICMP_STATS ++stats.icmp.recv; #endif /* ICMP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_icmpinmsgs(); +#endif iphdr = p->payload; @@ -82,6 +88,9 @@ icmp_input(struct pbuf *p, struct netif *inp) #ifdef ICMP_STATS ++stats.icmp.lenerr; #endif /* ICMP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_icmpinerrors(); +#endif return; } @@ -92,6 +101,9 @@ icmp_input(struct pbuf *p, struct netif *inp) #ifdef ICMP_STATS ++stats.icmp.chkerr; #endif /* ICMP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_icmpinerrors(); +#endif return; } tmpaddr.addr = iphdr->src.addr; @@ -107,6 +119,12 @@ icmp_input(struct pbuf *p, struct netif *inp) #ifdef ICMP_STATS ++stats.icmp.xmit; #endif /* ICMP_STATS */ +#if LWIP_SNMP > 0 + /* increase number of messages attempted to send */ + snmp_inc_icmpoutmsgs(); + /* increase number of echo replies attempted to send */ + snmp_inc_icmpoutechoreps(); +#endif pbuf_header(p, hlen); ip_output_if(p, &(iphdr->src), IP_HDRINCL, @@ -146,6 +164,12 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) #ifdef ICMP_STATS ++stats.icmp.xmit; #endif /* ICMP_STATS */ +#if LWIP_SNMP > 0 + /* increase number of messages attempted to send */ + snmp_inc_icmpoutmsgs(); + /* increase number of destination unreachable messages attempted to send */ + snmp_inc_icmpoutdestunreachs(); +#endif ip_output(q, NULL, &(iphdr->src), ICMP_TTL, IP_PROTO_ICMP); @@ -184,6 +208,12 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) #ifdef ICMP_STATS ++stats.icmp.xmit; #endif /* ICMP_STATS */ +#if LWIP_SNMP > 0 + /* increase number of messages attempted to send */ + snmp_inc_icmpoutmsgs(); + /* increase number of destination unreachable messages attempted to send */ + snmp_inc_icmpouttimeexcds(); +#endif ip_output(q, NULL, &(iphdr->src), ICMP_TTL, IP_PROTO_ICMP); pbuf_free(q); diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 55f263ab..40b77943 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -54,6 +54,9 @@ #include "arch/perf.h" +#if LWIP_SNMP > 0 +# include "snmp.h" +#endif #if LWIP_DHCP #include "lwip/dhcp.h" #endif /* LWIP_DHCP */ @@ -163,6 +166,9 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n", iphdr->dest.addr)); +#if LWIP_SNMP > 0 + snmp_inc_ipnoroutes(); +#endif return; } @@ -171,6 +177,9 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) if(netif == inp) { DEBUGF(IP_DEBUG, ("ip_forward: not forward packets back on incoming interface.\n")); +#if LWIP_SNMP > 0 + snmp_inc_ipnoroutes(); +#endif return; } @@ -180,6 +189,9 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) /* Don't send ICMP messages in response to ICMP messages */ if(IPH_PROTO(iphdr) != IP_PROTO_ICMP) { icmp_time_exceeded(p, ICMP_TE_TTL); +#if LWIP_SNMP > 0 + snmp_inc_icmpouttimeexcds(); +#endif } return; } @@ -198,6 +210,9 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) ++stats.ip.fw; ++stats.ip.xmit; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipforwdatagrams(); +#endif PERF_STOP("ip_forward"); @@ -389,6 +404,9 @@ ip_input(struct pbuf *p, struct netif *inp) { #ifdef IP_STATS ++stats.ip.recv; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipinreceives(); +#endif /* identify the IP header */ iphdr = p->payload; @@ -402,6 +420,9 @@ ip_input(struct pbuf *p, struct netif *inp) { ++stats.ip.err; ++stats.ip.drop; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipunknownprotos(); +#endif return ERR_OK; } @@ -415,6 +436,9 @@ ip_input(struct pbuf *p, struct netif *inp) { ++stats.ip.lenerr; ++stats.ip.drop; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipindiscards(); +#endif return ERR_OK; } @@ -430,6 +454,9 @@ ip_input(struct pbuf *p, struct netif *inp) { ++stats.ip.chkerr; ++stats.ip.drop; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipindiscards(); +#endif return ERR_OK; } @@ -475,7 +502,13 @@ ip_input(struct pbuf *p, struct netif *inp) { if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) { ip_forward(p, iphdr, inp); } + else #endif /* IP_FORWARD */ + { +#if LWIP_SNMP > 0 + snmp_inc_ipindiscards(); +#endif + } pbuf_free(p); return ERR_OK; } @@ -497,6 +530,9 @@ ip_input(struct pbuf *p, struct netif *inp) { ++stats.ip.opterr; ++stats.ip.drop; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipunknownprotos(); +#endif return ERR_OK; } #endif /* IP_REASSEMBLY */ @@ -510,6 +546,9 @@ ip_input(struct pbuf *p, struct netif *inp) { ++stats.ip.opterr; ++stats.ip.drop; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipunknownprotos(); +#endif return ERR_OK; } #endif /* IP_OPTIONS == 0 */ @@ -525,15 +564,24 @@ ip_input(struct pbuf *p, struct netif *inp) { switch(IPH_PROTO(iphdr)) { #if LWIP_UDP > 0 case IP_PROTO_UDP: +#if LWIP_SNMP > 0 + snmp_inc_ipindelivers(); +#endif udp_input(p, inp); break; #endif /* LWIP_UDP */ #if LWIP_TCP > 0 case IP_PROTO_TCP: +#if LWIP_SNMP > 0 + snmp_inc_ipindelivers(); +#endif tcp_input(p, inp); break; #endif /* LWIP_TCP */ case IP_PROTO_ICMP: +#if LWIP_SNMP > 0 + snmp_inc_ipindelivers(); +#endif icmp_input(p, inp); break; default: @@ -551,6 +599,9 @@ ip_input(struct pbuf *p, struct netif *inp) { ++stats.ip.proterr; ++stats.ip.drop; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipunknownprotos(); +#endif } return ERR_OK; @@ -574,6 +625,9 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, static u16_t ip_id = 0; +#if LWIP_SNMP > 0 + snmp_inc_ipoutrequests(); +#endif if(dest != IP_HDRINCL) { if(pbuf_header(p, IP_HLEN)) { @@ -582,6 +636,9 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, #ifdef IP_STATS ++stats.ip.err; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipoutdiscards(); +#endif return ERR_BUF; } @@ -619,6 +676,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, ip_debug_print(p); #endif /* IP_DEBUG */ + DEBUGF(IP_DEBUG, ("netif->output()")); return netif->output(netif, p, dest); } @@ -642,6 +700,9 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, #ifdef IP_STATS ++stats.ip.rterr; #endif /* IP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_ipoutdiscards(); +#endif return ERR_RTE; } diff --git a/src/core/udp.c b/src/core/udp.c index 445007ed..47ec0c15 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -28,6 +28,7 @@ * * Author: Adam Dunkels * + * $Id: udp.c,v 1.3 2002/11/21 10:32:19 likewise Exp $ */ /*-----------------------------------------------------------------------------------*/ @@ -49,6 +50,9 @@ #include "lwip/stats.h" #include "arch/perf.h" +#if LWIP_SNMP > 0 +# include "snmp.h" +#endif /*-----------------------------------------------------------------------------------*/ @@ -219,6 +223,9 @@ udp_input(struct pbuf *p, struct netif *inp) ++stats.udp.chkerr; ++stats.udp.drop; #endif /* UDP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_udpinerrors(); +#endif pbuf_free(p); goto end; } @@ -233,6 +240,9 @@ udp_input(struct pbuf *p, struct netif *inp) ++stats.udp.chkerr; ++stats.udp.drop; #endif /* UDP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_udpinerrors(); +#endif pbuf_free(p); goto end; } @@ -240,6 +250,9 @@ udp_input(struct pbuf *p, struct netif *inp) } pbuf_header(p, -UDP_HLEN); if(pcb != NULL) { +#if LWIP_SNMP > 0 + snmp_inc_udpindatagrams(); +#endif pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); } else { DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n")); @@ -262,6 +275,9 @@ udp_input(struct pbuf *p, struct netif *inp) ++stats.udp.proterr; ++stats.udp.drop; #endif /* UDP_STATS */ +#if LWIP_SNMP > 0 + snmp_inc_udpnoports(); +#endif pbuf_free(p); } } else { @@ -281,6 +297,8 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) err_t err; struct pbuf *hdr; + + DEBUGF(UDP_DEBUG, ("udp_send")); /* hdr will point to the UDP header pbuf if an extra header pbuf has to be allocated. */ hdr = NULL; @@ -293,6 +311,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) pbuf_chain(hdr, p); p = hdr; } + DEBUGF(UDP_DEBUG, ("udp_send: got pbuf")); udphdr = p->payload; udphdr->src = htons(pcb->local_port); @@ -316,6 +335,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %d\n", p->tot_len)); if(pcb->flags & UDP_FLAGS_UDPLITE) { + DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u", p->tot_len)); udphdr->len = htons(pcb->chksum_len); /* calculate checksum */ udphdr->chksum = inet_chksum_pseudo(p, src_ip, &(pcb->remote_ip), @@ -324,7 +344,11 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) udphdr->chksum = 0xffff; } err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif); +#if LWIP_SNMP > 0 + snmp_inc_udpoutdatagrams(); +#endif } else { + DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u", p->tot_len)); udphdr->len = htons(p->tot_len); /* calculate checksum */ if((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { @@ -334,6 +358,11 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) udphdr->chksum = 0xffff; } } + DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum %x", udphdr->chksum)); +#if LWIP_SNMP > 0 + snmp_inc_udpoutdatagrams(); +#endif + DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)")); err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif); }