diff --git a/src/core/raw.c b/src/core/raw.c index 3da0d969..794a3643 100644 --- a/src/core/raw.c +++ b/src/core/raw.c @@ -106,7 +106,7 @@ raw_input(struct pbuf *p, struct netif *inp) /* loop through all raw pcbs until the packet is eaten by one */ /* this allows multiple pcbs to match against the packet by design */ while ((eaten == 0) && (pcb != NULL)) { - if ((pcb->protocol == proto) && (ip_current_is_v6() == IP_IS_V6_VAL(pcb->local_ip)) && + if ((pcb->protocol == proto) && IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ip_current_dest_addr()) && (ip_addr_isany(&pcb->local_ip) || ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr()))) { #if IP_SOF_BROADCAST_RECV diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 0dccad22..c866793d 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -133,11 +133,8 @@ tcp_input(struct pbuf *p, struct netif *inp) } /* Don't even process incoming broadcasts/multicasts. */ - if ( -#if LWIP_IPV4 - (!ip_current_is_v6() && ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif())) || -#endif /* LWIP_IPV4 */ - ip_addr_ismulticast(ip_current_dest_addr())) { + if (ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif()) || + ip_addr_ismulticast(ip_current_dest_addr())) { TCP_STATS_INC(tcp.proterr); goto dropped; } @@ -269,7 +266,7 @@ tcp_input(struct pbuf *p, struct netif *inp) #endif /* SO_REUSE */ } else #endif /* LWIP_IPV4 && LWIP_IPV6 */ - if (ip_current_is_v6() == IP_IS_V6_VAL(lpcb->local_ip)) { + if (IP_ADDR_PCB_VERSION_MATCH_EXACT(lpcb, ip_current_dest_addr())) { if (ip_addr_cmp(&lpcb->local_ip, ip_current_dest_addr())) { /* found an exact match */ break; diff --git a/src/core/udp.c b/src/core/udp.c index 4371583a..fdfb2528 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -147,9 +147,9 @@ again: * @return 1 on match, 0 otherwise */ static u8_t -udp_input_local_match(struct udp_pcb *pcb, struct netif *netif, u8_t broadcast) +udp_input_local_match(struct udp_pcb *pcb, struct netif *inp, u8_t broadcast) { - LWIP_UNUSED_ARG(netif); /* in IPv6 only case */ + LWIP_UNUSED_ARG(inp); /* in IPv6 only case */ LWIP_UNUSED_ARG(broadcast); /* in IPv6 only case */ /* Dual-stack: PCBs listening to any IP type also listen to any IP address */ @@ -163,7 +163,7 @@ udp_input_local_match(struct udp_pcb *pcb, struct netif *netif, u8_t broadcast) } /* Only need to check PCB if incoming IP version matches PCB IP version */ - if(ip_current_is_v6() == IP_IS_V6_VAL(pcb->local_ip)) { + if(IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ip_current_dest_addr())) { LWIP_ASSERT("UDP PCB: inconsistent local/remote IP versions", IP_IS_V6_VAL(pcb->local_ip) == IP_IS_V6_VAL(pcb->remote_ip)); #if LWIP_IPV4 @@ -176,7 +176,7 @@ udp_input_local_match(struct udp_pcb *pcb, struct netif *netif, u8_t broadcast) { if(ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) || ((ip4_current_dest_addr()->addr == IPADDR_BROADCAST)) || - ip4_addr_netcmp(ip_2_ip4(&pcb->local_ip), ip4_current_dest_addr(), netif_ip4_netmask(netif))) { + ip4_addr_netcmp(ip_2_ip4(&pcb->local_ip), ip4_current_dest_addr(), netif_ip4_netmask(inp))) { return 1; } }