diff --git a/src/api/sockets.c b/src/api/sockets.c index 8fd4225a..818cb692 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -198,11 +198,9 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) newconn->socket = newsock; sys_sem_signal(socksem); -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port)); -#endif sock_set_errno(sock, 0); return newsock; @@ -225,11 +223,9 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen) local_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr; local_port = ((struct sockaddr_in *)name)->sin_port; -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &local_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port))); -#endif err = netconn_bind(sock->conn, &local_addr, ntohs(local_port)); @@ -297,11 +293,9 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen) remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr; remote_port = ((struct sockaddr_in *)name)->sin_port; -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port))); -#endif err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); } @@ -417,11 +411,9 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags, memcpy(from, &sin, *fromlen); -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); -#endif } else { #if SOCKETS_DEBUG > 0 addr = netbuf_fromaddr(buf); @@ -541,11 +533,9 @@ lwip_sendto(int s, void *data, int size, unsigned int flags, remote_addr.addr = ((struct sockaddr_in *)to)->sin_addr.s_addr; remote_port = ((struct sockaddr_in *)to)->sin_port; -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, size=%d, flags=0x%x to=", s, data, size, flags)); ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", ntohs(remote_port))); -#endif netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); @@ -921,11 +911,9 @@ int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen) /* get the IP address and port of the remote host */ netconn_peer(sock->conn, &naddr, &sin.sin_port); -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getpeername(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port)); -#endif sin.sin_port = htons(sin.sin_port); sin.sin_addr.s_addr = naddr.addr; @@ -957,11 +945,9 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen) /* get the IP address and port of the remote host */ netconn_addr(sock->conn, &naddr, &sin.sin_port); -#if SOCKETS_DEBUG LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockname(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port)); -#endif sin.sin_port = htons(sin.sin_port); sin.sin_addr.s_addr = naddr->addr; diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index 767326da..06cc304d 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -168,13 +168,11 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); iphdr = p->payload; -#if ICMP_DEBUG LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); LWIP_DEBUGF(ICMP_DEBUG, (" to ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); -#endif /* ICMP_DEBNUG */ tehdr = q->payload; ICMPH_TYPE_SET(tehdr, ICMP_TE); @@ -196,7 +194,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) pbuf_free(q); } -#endif /* IP_FORWARDING > 0 */ +#endif /* IP_FORWARD */ diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 7198a234..f0514704 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -235,9 +235,7 @@ ip_input(struct pbuf *p, struct netif *inp) { iphdr = p->payload; if (IPH_V(iphdr) != 4) { LWIP_DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %u\n", IPH_V(iphdr))); -#if IP_DEBUG ip_debug_print(p); -#endif /* IP_DEBUG */ pbuf_free(p); IP_STATS_INC(ip.err); IP_STATS_INC(ip.drop); @@ -265,9 +263,7 @@ ip_input(struct pbuf *p, struct netif *inp) { if (inet_chksum(iphdr, iphdrlen) != 0) { LWIP_DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen))); -#if IP_DEBUG ip_debug_print(p); -#endif /* IP_DEBUG */ pbuf_free(p); IP_STATS_INC(ip.chkerr); IP_STATS_INC(ip.drop); @@ -374,11 +370,9 @@ ip_input(struct pbuf *p, struct netif *inp) { #endif /* IP_OPTIONS == 0 */ /* send to upper layers */ -#if IP_DEBUG LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n")); ip_debug_print(p); LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %d p->tot_len %d\n", p->len, p->tot_len)); -#endif /* IP_DEBUG */ #if LWIP_RAW if (!raw_input(p, inp)) { @@ -487,9 +481,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, IP_STATS_INC(ip.xmit); LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num)); -#if IP_DEBUG ip_debug_print(p); -#endif /* IP_DEBUG */ LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); diff --git a/src/core/netif.c b/src/core/netif.c index cb3c5c48..9ea33c2c 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -97,7 +97,6 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask, /* add this netif to the list */ netif->next = netif_list; netif_list = netif; -#if NETIF_DEBUG LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ", netif->name[0], netif->name[1])); ip_addr_debug_print(NETIF_DEBUG, ipaddr); @@ -106,7 +105,6 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask, LWIP_DEBUGF(NETIF_DEBUG, (" gw ")); ip_addr_debug_print(NETIF_DEBUG, gw); LWIP_DEBUGF(NETIF_DEBUG, ("\n")); -#endif /* NETIF_DEBUG */ return netif; } diff --git a/src/core/udp.c b/src/core/udp.c index 7346fb5e..4114db24 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -64,10 +64,6 @@ struct udp_pcb *udp_pcbs = NULL; static struct udp_pcb *pcb_cache = NULL; -#if UDP_DEBUG -int udp_debug_print(struct udp_hdr *udphdr); -#endif /* UDP_DEBUG */ - /*-----------------------------------------------------------------------------------*/ void udp_init(void) @@ -193,9 +189,7 @@ udp_input(struct pbuf *p, struct netif *inp) src = ntohs(udphdr->src); dest = ntohs(udphdr->dest); -#if UDP_DEBUG udp_debug_print(udphdr); -#endif /* UDP_DEBUG */ /* print the UDP source and destination */ LWIP_DEBUGF(UDP_DEBUG, ("udp (%u.%u.%u.%u, %u) <-- (%u.%u.%u.%u, %u)\n", diff --git a/src/include/ipv4/lwip/ip.h b/src/include/ipv4/lwip/ip.h index 1aa8a30b..57f96a28 100644 --- a/src/include/ipv4/lwip/ip.h +++ b/src/include/ipv4/lwip/ip.h @@ -147,6 +147,8 @@ PACK_STRUCT_END #if IP_DEBUG void ip_debug_print(struct pbuf *p); +#else +#define ip_debug_print(p) #endif /* IP_DEBUG */ #endif /* __LWIP_IP_H__ */ diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h index f716f89e..00ac4f0b 100644 --- a/src/include/lwip/udp.h +++ b/src/include/lwip/udp.h @@ -95,7 +95,11 @@ u8_t udp_lookup (struct ip_hdr *iphdr, struct netif *inp); void udp_input (struct pbuf *p, struct netif *inp); void udp_init (void); - +#if UDP_DEBUG +int udp_debug_print(struct udp_hdr *udphdr); +#else +#define udp_debug_print(udphdr) +#endif #endif /* __LWIP_UDP_H__ */