SNMP functions are now unconditionally called and defined empty if LWIP_SNMP == 0

This removes a lot of #if #endif cluttering the source code.
This commit is contained in:
likewise 2003-02-10 13:47:47 +00:00
parent 32fbec2e48
commit c68ee2b2ed
7 changed files with 46 additions and 86 deletions

View File

@ -42,9 +42,7 @@
#include "lwip/stats.h"
#if LWIP_SNMP > 0
# include "snmp.h"
#endif
#include "snmp.h"
/*-----------------------------------------------------------------------------------*/
void
icmp_input(struct pbuf *p, struct netif *inp)
@ -58,9 +56,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
#ifdef ICMP_STATS
++lwip_stats.icmp.recv;
#endif /* ICMP_STATS */
#if LWIP_SNMP > 0
snmp_inc_icmpinmsgs();
#endif
iphdr = p->payload;
@ -88,9 +84,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
#ifdef ICMP_STATS
++lwip_stats.icmp.lenerr;
#endif /* ICMP_STATS */
#if LWIP_SNMP > 0
snmp_inc_icmpinerrors();
#endif
return;
}
@ -101,9 +95,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
#ifdef ICMP_STATS
++lwip_stats.icmp.chkerr;
#endif /* ICMP_STATS */
#if LWIP_SNMP > 0
snmp_inc_icmpinerrors();
#endif
return;
}
tmpaddr.addr = iphdr->src.addr;
@ -119,12 +111,10 @@ icmp_input(struct pbuf *p, struct netif *inp)
#ifdef ICMP_STATS
++lwip_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,
@ -164,12 +154,10 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
#ifdef ICMP_STATS
++lwip_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);
@ -208,12 +196,10 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
#ifdef ICMP_STATS
++lwip_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);

View File

@ -55,9 +55,7 @@
#include "arch/perf.h"
#if LWIP_SNMP > 0
# include "snmp.h"
#endif
#include "snmp.h"
#if LWIP_DHCP
#include "lwip/dhcp.h"
#endif /* LWIP_DHCP */
@ -169,18 +167,14 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
if(netif == NULL) {
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;
}
/* Do not forward packets onto the same network interface on which
they arrived. */
if(netif == inp) {
DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
#if LWIP_SNMP > 0
snmp_inc_ipnoroutes();
#endif
return;
}
@ -191,9 +185,7 @@ 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;
}
@ -212,9 +204,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
++lwip_stats.ip.fw;
++lwip_stats.ip.xmit;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipforwdatagrams();
#endif
PERF_STOP("ip_forward");
/* transmit pbuf on chosen interface */
@ -242,9 +232,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
#ifdef IP_STATS
++lwip_stats.ip.recv;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipinreceives();
#endif
snmp_inc_ipinreceives();
/* identify the IP header */
iphdr = p->payload;
@ -258,9 +246,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
++lwip_stats.ip.err;
++lwip_stats.ip.drop;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipunknownprotos();
#endif
return ERR_OK;
}
/* obtain IP header length in number of 32-bit words */
@ -278,9 +264,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
++lwip_stats.ip.lenerr;
++lwip_stats.ip.drop;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipindiscards();
#endif
return ERR_OK;
}
@ -296,9 +280,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
++lwip_stats.ip.chkerr;
++lwip_stats.ip.drop;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipindiscards();
#endif
return ERR_OK;
}
@ -361,9 +343,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
else
#endif /* IP_FORWARD */
{
#if LWIP_SNMP > 0
snmp_inc_ipindiscards();
#endif
}
pbuf_free(p);
return ERR_OK;
@ -387,9 +367,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
++lwip_stats.ip.opterr;
++lwip_stats.ip.drop;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipunknownprotos();
#endif
return ERR_OK;
}
#endif /* IP_REASSEMBLY */
@ -402,9 +380,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
++lwip_stats.ip.opterr;
++lwip_stats.ip.drop;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipunknownprotos();
#endif
return ERR_OK;
}
#endif /* IP_OPTIONS == 0 */
@ -419,24 +395,18 @@ 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:
@ -454,9 +424,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
++lwip_stats.ip.proterr;
++lwip_stats.ip.drop;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipunknownprotos();
#endif
}
return ERR_OK;
@ -479,10 +447,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
static struct ip_hdr *iphdr;
static u16_t ip_id = 0;
#if LWIP_SNMP > 0
snmp_inc_ipoutrequests();
#endif
snmp_inc_ipoutrequests();
if(dest != IP_HDRINCL) {
if(pbuf_header(p, IP_HLEN)) {
@ -491,9 +456,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
#ifdef IP_STATS
++lwip_stats.ip.err;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipoutdiscards();
#endif
snmp_inc_ipoutdiscards();
return ERR_BUF;
}
@ -560,9 +523,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
#ifdef IP_STATS
++lwip_stats.ip.rterr;
#endif /* IP_STATS */
#if LWIP_SNMP > 0
snmp_inc_ipoutdiscards();
#endif
return ERR_RTE;
}

View File

@ -39,7 +39,17 @@
struct netif *netif_list = NULL;
struct netif *netif_default = NULL;
/*-----------------------------------------------------------------------------------*/
/**
* Add a network interface to the list of lwIP netifs.
*
* @param ipaddr IP address for the new netif
* @param netmask network mask for the new netif
* @param gw default gateway IP address for the new netif
* @init callback function that initializes the interface
* @input callback function that...
*
* @return netif, or NULL if failed.
*/
struct netif *
netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
struct ip_addr *gw,

View File

@ -28,7 +28,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: udp.c,v 1.17 2003/02/06 22:18:56 davidhaas Exp $
* $Id: udp.c,v 1.18 2003/02/10 13:47:47 likewise Exp $
*/
/*-----------------------------------------------------------------------------------*/
@ -50,9 +50,7 @@
#include "lwip/stats.h"
#include "arch/perf.h"
#if LWIP_SNMP > 0
# include "snmp.h"
#endif
#include "snmp.h"
/*-----------------------------------------------------------------------------------*/
@ -259,9 +257,7 @@ udp_input(struct pbuf *p, struct netif *inp)
++lwip_stats.udp.chkerr;
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
#if LWIP_SNMP > 0
snmp_inc_udpinerrors();
#endif
snmp_inc_udpinerrors();
pbuf_free(p);
goto end;
}
@ -276,9 +272,7 @@ udp_input(struct pbuf *p, struct netif *inp)
++lwip_stats.udp.chkerr;
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
#if LWIP_SNMP > 0
snmp_inc_udpinerrors();
#endif
pbuf_free(p);
goto end;
}
@ -286,10 +280,8 @@ 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), udphdr->src);
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
} else {
DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n"));
@ -307,9 +299,7 @@ udp_input(struct pbuf *p, struct netif *inp)
++lwip_stats.udp.proterr;
++lwip_stats.udp.drop;
#endif /* UDP_STATS */
#if LWIP_SNMP > 0
snmp_inc_udpnoports();
#endif
pbuf_free(p);
}
} else {
@ -404,9 +394,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
/* output to IP */
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\n", p->tot_len));
udphdr->len = htons(p->tot_len);
@ -417,9 +405,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
}
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum %x\n", udphdr->chksum));
#if LWIP_SNMP > 0
snmp_inc_udpoutdatagrams();
#endif
DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)\n"));
/* output to IP */
err = ip_output_if(p, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);
@ -519,15 +505,15 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
struct udp_pcb *ipcb;
if(pcb->local_port == 0) {
err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
if(err != ERR_OK)
return err;
err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
if(err != ERR_OK)
return err;
}
ip_addr_set(&pcb->remote_ip, ipaddr);
pcb->remote_port = port;
#if 1
pcb->flags |= UDP_FLAGS_CONNECTED;
/* Nail down local IP for netconn_addr()/getsockname() */
if(ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {
struct netif *netif;
@ -535,7 +521,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
if((netif = ip_route(&(pcb->remote_ip))) == NULL) {
DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr));
#ifdef UDP_STATS
++lwip_stats.udp.rterr;
++lwip_stats.udp.rterr;
#endif /* UDP_STATS */
return ERR_RTE;
}
@ -544,7 +530,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
} else if(ip_addr_isany(&pcb->remote_ip)) {
pcb->local_ip.addr = 0;
}
#endif
/* Insert UDP PCB into the list of active UDP PCBs. */
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
if(pcb == ipcb) {

View File

@ -114,8 +114,6 @@ PACK_STRUCT_END
#define IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (HTONS((proto) | (IPH_TTL(hdr) << 8)))
#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
#if IP_DEBUG
void ip_debug_print(struct pbuf *p);
#endif /* IP_DEBUG */

View File

@ -29,6 +29,8 @@
* Author: Adam Dunkels <adam@sics.se>
*
*/
#error this is the original lwIP debug.h file. do not include
#ifndef __LWIP_DEBUG_H__
#define __LWIP_DEBUG_H__

View File

@ -106,6 +106,24 @@ void snmp_inc_udpoutdatagrams(void);
/* define everything to be empty */
#else
/* network interface */
#define snmp_add_ifinoctets()
#define snmp_inc_ifinucastpkts()
#define snmp_inc_ifinnucastpkts()
#define snmp_inc_ifindiscards()
#define snmp_add_ifoutoctets()
#define snmp_inc_ifoutucastpkts()
#define snmp_inc_ifoutnucastpkts()
#define snmp_inc_ifoutdiscards()
/* IP */
#define snmp_inc_ipinreceives()
#define snmp_inc_ipindelivers()
#define snmp_inc_ipindiscards()
#define snmp_inc_ipoutdiscards()
#define snmp_inc_ipoutrequests()
#define snmp_inc_ipunknownprotos()
// ICMP
#define snmp_inc_icmpinmsgs()
#define snmp_inc_icmpinerrors()
@ -133,7 +151,6 @@ void snmp_inc_udpoutdatagrams(void);
#define snmp_inc_icmpouttimestampreps()
#define snmp_inc_icmpoutaddrmasks()
#define snmp_inc_icmpoutaddrmaskreps()
// TCP
#define snmp_inc_tcpactiveopens()
#define snmp_inc_tcppassiveopens()