mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
2004-11-25 Leon Woestenberg <leon.woestenberg@gmx.net>
* ip.c: Exploit the fact that ip_addr_isbroadcast() now checks that the given IP address actually belongs to the network of the given interface.
This commit is contained in:
parent
90b7e68b4e
commit
37a0c57bed
@ -238,11 +238,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
{
|
{
|
||||||
/* unicast to this interface address? */
|
/* unicast to this interface address? */
|
||||||
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
|
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
|
||||||
/* or broadcast matching this interface network address? */
|
/* or broadcast on this interface network address? */
|
||||||
(ip_addr_isbroadcast(&(iphdr->dest), netif) &&
|
ip_addr_isbroadcast(&(iphdr->dest), netif)) {
|
||||||
ip_addr_netcmp(&(iphdr->dest), &(netif->ip_addr), &(netif->netmask))) ||
|
|
||||||
/* or restricted broadcast? */
|
|
||||||
ip_addr_cmp(&(iphdr->dest), IP_ADDR_BROADCAST)) {
|
|
||||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
|
LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
|
||||||
netif->name[0], netif->name[1]));
|
netif->name[0], netif->name[1]));
|
||||||
/* break out of for loop */
|
/* break out of for loop */
|
||||||
|
@ -60,11 +60,12 @@ u8_t ip_addr_isbroadcast(struct ip_addr *addr, struct netif *netif)
|
|||||||
/* address matches network interface address exactly? => no broadcast */
|
/* address matches network interface address exactly? => no broadcast */
|
||||||
else if (addr->addr == netif->ip_addr.addr)
|
else if (addr->addr == netif->ip_addr.addr)
|
||||||
return 0;
|
return 0;
|
||||||
/* on the same (sub) network and
|
/* on the same (sub) network... */
|
||||||
* host identifier bits are all ones? => network broadcast address */
|
|
||||||
else if (ip_addr_netcmp(addr->addr, netif->ip_addr.addr, netif->netmask.addr))
|
else if (ip_addr_netcmp(addr->addr, netif->ip_addr.addr, netif->netmask.addr))
|
||||||
|
/* ...and host identifier bits are all ones? =>... */
|
||||||
&& ((addr->addr & ~netif->netmask.addr) ==
|
&& ((addr->addr & ~netif->netmask.addr) ==
|
||||||
(ip_addr_broadcast.addr & ~netif->netmask.addr))
|
(ip_addr_broadcast.addr & ~netif->netmask.addr))
|
||||||
|
/* => network broadcast address */
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user