From 339e82d7aac4f46b5eb3d1bf96be63b2cd3e5c33 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sun, 21 Feb 2016 19:45:51 +0100 Subject: [PATCH] Eliminate IP_PCB_IPVER_EQ macro --- src/core/tcp.c | 13 +++++-------- src/core/udp.c | 2 +- src/include/lwip/ip.h | 2 -- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index 650c075b..d2c05fa0 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -478,7 +478,7 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) #endif /* SO_REUSE */ { /* @todo: check accept_any_ip_version */ - if (IP_PCB_IPVER_EQ(pcb, cpcb) && + if ((IP_IS_V6(ipaddr) == IP_IS_V6_VAL(cpcb->local_ip)) && (ip_addr_isany(&cpcb->local_ip) || ip_addr_isany(ipaddr) || ip_addr_cmp(&cpcb->local_ip, ipaddr))) { @@ -547,11 +547,9 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) this port is only used once for every local IP. */ for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { if ((lpcb->local_port == pcb->local_port) && - IP_PCB_IPVER_EQ(pcb, lpcb)) { - if (ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) { - /* this address/port is already used */ - return NULL; - } + ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) { + /* this address/port is already used */ + return NULL; } } } @@ -797,7 +795,6 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port, for (cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { if ((cpcb->local_port == pcb->local_port) && (cpcb->remote_port == port) && - IP_PCB_IPVER_EQ(cpcb, pcb) && ip_addr_cmp(&cpcb->local_ip, &pcb->local_ip) && ip_addr_cmp(&cpcb->remote_ip, ipaddr)) { /* linux returns EISCONN here, but ERR_USE should be OK for us */ @@ -1672,7 +1669,7 @@ tcp_pcb_purge(struct tcp_pcb *pcb) tcp_listen_pcbs.listen_pcbs != NULL); for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { if ((lpcb->local_port == pcb->local_port) && - IP_PCB_IPVER_EQ(pcb, lpcb) && + (IP_IS_V6_VAL(pcb->local_ip) == IP_IS_V6_VAL(lpcb->local_ip)) && (ip_addr_isany(&lpcb->local_ip) || ip_addr_cmp(&pcb->local_ip, &lpcb->local_ip))) { /* port and address of the listen pcb match the timed-out pcb */ diff --git a/src/core/udp.c b/src/core/udp.c index f593838f..03d61933 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -967,7 +967,7 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) #endif /* SO_REUSE */ { /* port matches that of PCB in list and REUSEADDR not set -> reject */ - if ((ipcb->local_port == port) && IP_PCB_IPVER_EQ(pcb, ipcb) && + if ((ipcb->local_port == port) && (IP_IS_V6(ipaddr) == IP_IS_V6_VAL(ipcb->local_ip)) && /* IP address matches, or one is IP_ADDR_ANY? */ (ip_addr_isany(&ipcb->local_ip) || ip_addr_isany(ipaddr) || diff --git a/src/include/lwip/ip.h b/src/include/lwip/ip.h index 30fd55cd..6167227c 100644 --- a/src/include/lwip/ip.h +++ b/src/include/lwip/ip.h @@ -77,11 +77,9 @@ extern "C" { #if LWIP_IPV6 && LWIP_IPV4 #define IP_PCB_ISIPV6_MEMBER u8_t isipv6; -#define IP_PCB_IPVER_EQ(pcb1, pcb2) ((pcb1)->isipv6 == (pcb2)->isipv6) #define PCB_ISIPV6(pcb) ((pcb)->isipv6) #else #define IP_PCB_ISIPV6_MEMBER -#define IP_PCB_IPVER_EQ(pcb1, pcb2) 1 #define PCB_ISIPV6(pcb) LWIP_IPV6 #endif /* LWIP_IPV6 */