From d36b7230564d582a285578ec2f3398e5912fa4de Mon Sep 17 00:00:00 2001 From: jani Date: Fri, 26 Mar 2004 12:40:58 +0000 Subject: [PATCH] fix SO_REUSE ifdef fixes --- src/core/stats.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ src/core/tcp.c | 3 +-- src/core/udp.c | 3 +-- 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/core/stats.c b/src/core/stats.c index 85a55b9e..f479fedc 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -47,5 +47,68 @@ stats_init(void) { memset(&lwip_stats, 0, sizeof(struct stats_)); } + +void +stats_display_proto(struct stats_proto *proto, char *name) +{ + LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); + LWIP_PLATFORM_DIAG(("xmit: %d\n\t", proto->xmit)); + LWIP_PLATFORM_DIAG(("rexmit: %d\n\t", proto->rexmit)); + LWIP_PLATFORM_DIAG(("recv: %d\n\t", proto->recv)); + LWIP_PLATFORM_DIAG(("fw: %d\n\t", proto->fw)); + LWIP_PLATFORM_DIAG(("drop: %d\n\t", proto->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %d\n\t", proto->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %d\n\t", proto->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %d\n\t", proto->memerr)); + LWIP_PLATFORM_DIAG(("rterr: %d\n\t", proto->rterr)); + LWIP_PLATFORM_DIAG(("proterr: %d\n\t", proto->proterr)); + LWIP_PLATFORM_DIAG(("opterr: %d\n\t", proto->opterr)); + LWIP_PLATFORM_DIAG(("err: %d\n\t", proto->err)); + LWIP_PLATFORM_DIAG(("cachehit: %d\n", proto->cachehit)); +} + +void +stats_display_pbuf(struct stats_pbuf *pbuf) +{ + LWIP_PLATFORM_DIAG(("\nPBUF\n\t")); + LWIP_PLATFORM_DIAG(("avail: %d\n\t", pbuf->avail)); + LWIP_PLATFORM_DIAG(("used: %d\n\t", pbuf->used)); + LWIP_PLATFORM_DIAG(("max: %d\n\t", pbuf->max)); + LWIP_PLATFORM_DIAG(("err: %d\n\t", pbuf->err)); + LWIP_PLATFORM_DIAG(("alloc_locked: %d\n\t", pbuf->alloc_locked)); + LWIP_PLATFORM_DIAG(("refresh_locked: %d\n", pbuf->refresh_locked)); +} + +void +stats_display_mem(struct stats_mem *mem, char *name) +{ + LWIP_PLATFORM_DIAG(("\n MEM %s\n\t", name)); + LWIP_PLATFORM_DIAG(("avail: %d\n\t", mem->avail)); + LWIP_PLATFORM_DIAG(("used: %d\n\t", mem->used)); + LWIP_PLATFORM_DIAG(("max: %d\n\t", mem->max)); + LWIP_PLATFORM_DIAG(("err: %d\n", mem->err)); + +} + +void +stats_display(void) +{ + int i; + char * memp_names[] = {"PBUF", "RAW_PCB", "UDP_PCB", "TCP_PCB", "TCP_PCB_LISTEN", + "TCP_SEG", "NETBUF", "NETCONN", "API_MSG", "TCP_MSG", "TIMEOUT"}; + stats_display_proto(&lwip_stats.link, "LINK"); + stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG"); + stats_display_proto(&lwip_stats.ip, "IP"); + stats_display_proto(&lwip_stats.icmp, "ICMP"); + stats_display_proto(&lwip_stats.udp, "UDP"); + stats_display_proto(&lwip_stats.tcp, "TCP"); + stats_display_pbuf(&lwip_stats.pbuf); + stats_display_mem(&lwip_stats.mem, "HEAP"); + for (i = 0; i < MEMP_MAX; i++) { + stats_display_mem(&lwip_stats.memp[i], memp_names[i]); + } + +} + #endif /* LWIP_STATS */ diff --git a/src/core/tcp.c b/src/core/tcp.c index e2d259d6..a2094d4e 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -251,8 +251,7 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) if (port == 0) { port = tcp_new_port(); } -#if SO_REUSE -#else +#if SO_REUSE == 0 /* Check if the address already is in use. */ for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; cpcb != NULL; cpcb = cpcb->next) { diff --git a/src/core/udp.c b/src/core/udp.c index f69af760..2b3bd54b 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -535,8 +535,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) rebind = 1; } -#if SO_REUSE -#else +#if SO_REUSE == 0 /* this code does not allow upper layer to share a UDP port for listening to broadcast or multicast traffic (See SO_REUSE_ADDR and SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR