mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-14 18:36:27 +00:00
minor: Cleanups in raw/tcp/udp code by using macros and reducing #ifdefs
This commit is contained in:
parent
953b7bdd59
commit
fd891081c4
@ -106,7 +106,7 @@ raw_input(struct pbuf *p, struct netif *inp)
|
|||||||
/* loop through all raw pcbs until the packet is eaten by one */
|
/* loop through all raw pcbs until the packet is eaten by one */
|
||||||
/* this allows multiple pcbs to match against the packet by design */
|
/* this allows multiple pcbs to match against the packet by design */
|
||||||
while ((eaten == 0) && (pcb != NULL)) {
|
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_isany(&pcb->local_ip) ||
|
||||||
ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr()))) {
|
ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr()))) {
|
||||||
#if IP_SOF_BROADCAST_RECV
|
#if IP_SOF_BROADCAST_RECV
|
||||||
|
@ -133,11 +133,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Don't even process incoming broadcasts/multicasts. */
|
/* Don't even process incoming broadcasts/multicasts. */
|
||||||
if (
|
if (ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif()) ||
|
||||||
#if LWIP_IPV4
|
ip_addr_ismulticast(ip_current_dest_addr())) {
|
||||||
(!ip_current_is_v6() && ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif())) ||
|
|
||||||
#endif /* LWIP_IPV4 */
|
|
||||||
ip_addr_ismulticast(ip_current_dest_addr())) {
|
|
||||||
TCP_STATS_INC(tcp.proterr);
|
TCP_STATS_INC(tcp.proterr);
|
||||||
goto dropped;
|
goto dropped;
|
||||||
}
|
}
|
||||||
@ -269,7 +266,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
#endif /* SO_REUSE */
|
#endif /* SO_REUSE */
|
||||||
} else
|
} else
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
#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())) {
|
if (ip_addr_cmp(&lpcb->local_ip, ip_current_dest_addr())) {
|
||||||
/* found an exact match */
|
/* found an exact match */
|
||||||
break;
|
break;
|
||||||
|
@ -147,9 +147,9 @@ again:
|
|||||||
* @return 1 on match, 0 otherwise
|
* @return 1 on match, 0 otherwise
|
||||||
*/
|
*/
|
||||||
static u8_t
|
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 */
|
LWIP_UNUSED_ARG(broadcast); /* in IPv6 only case */
|
||||||
|
|
||||||
/* Dual-stack: PCBs listening to any IP type also listen to any IP address */
|
/* 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 */
|
/* 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));
|
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
|
#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)) ||
|
if(ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) ||
|
||||||
((ip4_current_dest_addr()->addr == IPADDR_BROADCAST)) ||
|
((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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user