lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Bug in ip_addr.c concerning Broadcast.


From: Rodney Brown
Subject: [lwip-users] Bug in ip_addr.c concerning Broadcast.
Date: Fri, 19 Nov 2004 16:54:34 -0600

I believe I've found a bug in ipp_addr.c and wanted some confirmation before
fixing it.

Snippet from ip_addr_isbroadcast(struct ip_addr *addr, struct netif *netif)
.
.
  /* host identifier bits are all ones? => network broadcast address */
  else if ((addr->addr & ~netif->netmask.addr) ==
           (ip_addr_broadcast.addr & ~netif->netmask.addr))
    return 1;


addr is the destination. netif is the device's information. If the
destination IP is 123.123.123.63, and the local subnet is 255.255.255.192,
the routine will return true, no matter what subnet the address is on.

Should the code read:  ??

  else if (((addr->addr & ~netif->netmask.addr) ==
            (ip_addr_broadcast.addr & ~netif->netmask.addr)) &&
             ((addr->addr & netif->netmask.addr) == 
                (netif->ip_addr.addr & netif->netmask.addr)))

    return 1;

This checks to be sure the device and destination are on the same subnet,
and that the last address on that subnet is the destination.

Thanks,
Rodney





reply via email to

[Prev in Thread] Current Thread [Next in Thread]