From 2c8aa6f6f4ee06ed32f490bb1f695e14d1a02e1d Mon Sep 17 00:00:00 2001 From: kieranm Date: Tue, 23 Mar 2004 19:33:53 +0000 Subject: [PATCH] Kieran Mansley - kjm25@cam.ac.uk - 23rd March 2003 - Changed all #ifdef SO_REUSE into #if SO_REUSE --- src/api/sockets.c | 6 +++--- src/core/tcp.c | 3 ++- src/core/tcp_in.c | 10 +++++----- src/core/udp.c | 19 ++++++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index d4b5b1db..e3ab4df3 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1079,7 +1079,7 @@ int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *opt /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ -#ifdef SO_REUSE +#if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ @@ -1182,7 +1182,7 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_ /* UNIMPL case SO_SNDBUF: */ /* UNIMPL case SO_RCVLOWAT: */ /* UNIMPL case SO_SNDLOWAT: */ -#ifdef SO_REUSE +#if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ @@ -1264,7 +1264,7 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ -#ifdef SO_REUSE +#if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ diff --git a/src/core/tcp.c b/src/core/tcp.c index 654fd08e..e2d259d6 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -251,7 +251,8 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) if (port == 0) { port = tcp_new_port(); } -#ifndef SO_REUSE +#if SO_REUSE +#else /* 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/tcp_in.c b/src/core/tcp_in.c index 7648f7bd..1a3c441b 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -175,7 +175,7 @@ tcp_input(struct pbuf *p, struct netif *inp) for an active connection. */ prev = NULL; -#ifdef SO_REUSE +#if SO_REUSE pcb_temp = tcp_active_pcbs; again_1: @@ -193,7 +193,7 @@ tcp_input(struct pbuf *p, struct netif *inp) ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) && ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) { -#ifdef SO_REUSE +#if SO_REUSE if(pcb->so_options & SOF_REUSEPORT) { if(reuse) { /* We processed one PCB already */ @@ -363,7 +363,7 @@ tcp_input(struct pbuf *p, struct netif *inp) tcp_debug_print_state(pcb->state); #endif /* TCP_DEBUG */ #endif /* TCP_INPUT_DEBUG */ -#ifdef SO_REUSE +#if SO_REUSE /* First socket should receive now */ if(reuse_port) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: searching next PCB.\n")); @@ -375,7 +375,7 @@ tcp_input(struct pbuf *p, struct netif *inp) #endif /* SO_REUSE */ } else { -#ifdef SO_REUSE +#if SO_REUSE if(reuse) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: freeing PBUF with reference counter set to %i\n", p->ref)); pbuf_free(p); @@ -394,7 +394,7 @@ tcp_input(struct pbuf *p, struct netif *inp) } pbuf_free(p); } -#ifdef SO_REUSE +#if SO_REUSE end: #endif /* SO_REUSE */ LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); diff --git a/src/core/udp.c b/src/core/udp.c index 62e1b9f5..f69af760 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -128,7 +128,7 @@ udp_input(struct pbuf *p, struct netif *inp) ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src), ntohs(udphdr->src))); -#ifdef SO_REUSE +#if SO_REUSE pcb_temp = udp_pcbs; again_1: @@ -158,7 +158,7 @@ udp_input(struct pbuf *p, struct netif *inp) (ip_addr_isany(&pcb->local_ip) || /* PCB local IP address matches UDP destination IP address? */ ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { -#ifdef SO_REUSE +#if SO_REUSE if(pcb->so_options & SOF_REUSEPORT) { if(reuse) { /* We processed one PCB already */ @@ -187,7 +187,7 @@ udp_input(struct pbuf *p, struct netif *inp) /* Iterate through the UDP PCB list for a pcb that matches the local address. */ -#ifdef SO_REUSE +#if SO_REUSE pcb_temp = udp_pcbs; again_2: @@ -209,7 +209,7 @@ udp_input(struct pbuf *p, struct netif *inp) (ip_addr_isany(&pcb->local_ip) || /* ...matching interface address? */ ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) { -#ifdef SO_REUSE +#if SO_REUSE if(pcb->so_options & SOF_REUSEPORT) { if(reuse) { /* We processed one PCB already */ @@ -279,7 +279,7 @@ udp_input(struct pbuf *p, struct netif *inp) if (pcb != NULL) { snmp_inc_udpindatagrams(); pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); -#ifdef SO_REUSE +#if SO_REUSE /* First socket should receive now */ if(reuse_port_1 || reuse_port_2) { /* We want to search on next socket after receiving */ @@ -299,7 +299,7 @@ udp_input(struct pbuf *p, struct netif *inp) } #endif /* SO_REUSE */ } else { -#ifdef SO_REUSE +#if SO_REUSE if(reuse) { LWIP_DEBUGF(UDP_DEBUG, ("udp_input: freeing PBUF with reference counter set to %i\n", p->ref)); pbuf_free(p); @@ -517,7 +517,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) { struct udp_pcb *ipcb; u8_t rebind; -#ifdef SO_REUSE +#if SO_REUSE int reuse_port_all_set = 1; #endif /* SO_REUSE */ LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = ")); @@ -535,7 +535,8 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) rebind = 1; } -#ifndef SO_REUSE +#if SO_REUSE +#else /* 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 @@ -589,7 +590,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) } -#ifdef SO_REUSE +#if SO_REUSE /* If SOF_REUSEPORT isn't set in all PCB's bound to specified port and local address specified then {IP, port} can't be reused. */ if(!reuse_port_all_set) {