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:
likewise 2004-11-25 13:57:05 +00:00
parent 90b7e68b4e
commit 37a0c57bed
2 changed files with 5 additions and 7 deletions

View File

@ -238,11 +238,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
{
/* unicast to this interface address? */
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
/* or broadcast matching this interface network address? */
(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)) {
/* or broadcast on this interface network address? */
ip_addr_isbroadcast(&(iphdr->dest), netif)) {
LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
netif->name[0], netif->name[1]));
/* break out of for loop */

View File

@ -60,11 +60,12 @@ u8_t ip_addr_isbroadcast(struct ip_addr *addr, struct netif *netif)
/* address matches network interface address exactly? => no broadcast */
else if (addr->addr == netif->ip_addr.addr)
return 0;
/* on the same (sub) network and
* host identifier bits are all ones? => network broadcast address */
/* on the same (sub) network... */
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) ==
(ip_addr_broadcast.addr & ~netif->netmask.addr))
/* => network broadcast address */
return 1;
else
return 0;