]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
2004-11-25 Leon Woestenberg <leon.woestenberg@gmx.net>
authorlikewise <likewise>
Thu, 25 Nov 2004 13:33:07 +0000 (13:33 +0000)
committerlikewise <likewise>
Thu, 25 Nov 2004 13:33:07 +0000 (13:33 +0000)
  * ipv4/ip_addr.h: Renamed ip_addr_maskcmp() to _netcmp() as we are
    comparing network addresses (identifiers), not the network masks
    themselves.
  * ipv4/ip_addr.c: ip_addr_isbroadcast() now checks that the given
    IP address actually belongs to the network of the given interface.

src/core/ipv4/ip.c
src/core/ipv4/ip_addr.c
src/core/ipv6/ip6.c
src/core/ipv6/ip6_addr.c
src/include/ipv4/lwip/ip_addr.h
src/include/ipv6/lwip/ip_addr.h

index 1b0ea2661cd0f6df8fff854522dd77306e6d814a..a317ae42362962bf51a3dcef22c65cd8082349bb 100644 (file)
@@ -85,7 +85,7 @@ ip_route(struct ip_addr *dest)
   /* iterate through netifs */
   for(netif = netif_list; netif != NULL; netif = netif->next) {
     /* network mask matches? */
-    if (ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
+    if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
       /* return netif on which to forward IP packet */
       return netif;
     }
@@ -240,7 +240,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
       if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
         /* or broadcast matching this interface network address? */
         (ip_addr_isbroadcast(&(iphdr->dest), netif) &&
-         ip_addr_maskcmp(&(iphdr->dest), &(netif->ip_addr), &(netif->netmask))) ||
+         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",
index 9bf000ba0d60bfb213086b0eccc66b7cbcf01c62..55c9b4f4e300c91306d48b32ffc399c1bd2b3101 100644 (file)
@@ -60,8 +60,10 @@ 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;
-  /* host identifier bits are all ones? => network broadcast address */
-  else if ((addr->addr & ~netif->netmask.addr) ==
+  /*  on the same (sub) network and
+   *  host identifier bits are all ones? => network broadcast address */
+  else if (ip_addr_netcmp(addr->addr, netif->ip_addr.addr, netif->netmask.addr))
+          && ((addr->addr & ~netif->netmask.addr) ==
            (ip_addr_broadcast.addr & ~netif->netmask.addr))
     return 1;
   else
index 403e4de0e277e1b09cef3d59993de0e9772b77e9..abce830cf1088bc924d5e64538c7cfce441540ff 100644 (file)
@@ -77,7 +77,7 @@ ip_route(struct ip_addr *dest)
   struct netif *netif;
 
   for(netif = netif_list; netif != NULL; netif = netif->next) {
-    if (ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
+    if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
       return netif;
     }
   }
index 3e11e07ef4010fca6438088e78a1324b695d5bf6..d1bc358a691564d8a6a12a37565c967c32f858c4 100644 (file)
@@ -35,7 +35,7 @@
 
 
 int
-ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
+ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2,
                 struct ip_addr *mask)
 {
   return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) &&
index 58820bdfdb5edba1a8767878b829f1af26c25fe2..0ef99937b39a878b640bff6f10d5fcff0af1f8c7 100644 (file)
@@ -125,7 +125,7 @@ extern const struct ip_addr ip_addr_broadcast;
  * @arg mask network identifier mask
  * @return !0 if the network identifiers of both address match
  */
-#define ip_addr_maskcmp(addr1, addr2, mask) (((addr1)->addr & \
+#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
                                               (mask)->addr) == \
                                              ((addr2)->addr & \
                                               (mask)->addr))
index 40c698ecc031311667f07d62f4e6e6ca3facc6c5..08e962ddd37eb00cfe4649a475125bc292997a23 100644 (file)
@@ -45,7 +45,7 @@ struct ip_addr {
                                                (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \
                                                (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0)
 
-int ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
+int ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2,
         struct ip_addr *mask);
 int ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2);
 void ip_addr_set(struct ip_addr *dest, struct ip_addr *src);