]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/blobdiff - src/core/ipv6/ip6.c
Fix bug #37959: ip6_debug_print prints plen, nexth, hoplim in wrong
[pes-rpp/rpp-lwip.git] / src / core / ipv6 / ip6.c
index ef018888ad6c15524b735fb3a1ecca47f7f8eae9..94e423a23007e4a2cb4835e4eeb41afd9eec0164 100644 (file)
@@ -357,7 +357,7 @@ ip6_input(struct pbuf *p, struct netif *inp)
   /* identify the IP header */
   ip6hdr = (struct ip6_hdr *)p->payload;
   if (IP6H_V(ip6hdr) != 6) {
-    LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IPv6 packet dropped due to bad version number %"U16_F"\n",
+    LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IPv6 packet dropped due to bad version number %"U32_F"\n",
         IP6H_V(ip6hdr)));
     pbuf_free(p);
     IP6_STATS_INC(ip6.err);
@@ -411,9 +411,18 @@ ip6_input(struct pbuf *p, struct netif *inp)
     }
 #else /* LWIP_IPV6_MLD */
     else if (ip6_addr_issolicitednode(ip6_current_dest_addr())) {
-      /* Accept all solicited node packets when MLD is not enabled
+      /* Filter solicited node packets when MLD is not enabled
        * (for Neighbor discovery). */
-      netif = inp;
+      netif = NULL;
+      for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
+        if (ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) &&
+            ip6_addr_cmp_solicitednode(ip6_current_dest_addr(), netif_ip6_addr(inp, i))) {
+          netif = inp;
+          LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: solicited node packet accepted on interface %c%c\n",
+              netif->name[0], netif->name[1]));
+          break;
+        }
+      }
     }
 #endif /* LWIP_IPV6_MLD */
     else {
@@ -438,6 +447,11 @@ ip6_input(struct pbuf *p, struct netif *inp)
           }
         }
       }
+      if (ip6_addr_islinklocal(ip6_current_dest_addr())) {
+        /* Do not match link-local addresses to other netifs. */
+        netif = NULL;
+        break;
+      }
       if (first) {
         first = 0;
         netif = netif_list;
@@ -450,7 +464,7 @@ ip6_input(struct pbuf *p, struct netif *inp)
     } while(netif != NULL);
 netif_found:
     LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet accepted on interface %c%c\n",
-        netif->name[0], netif->name[1]));
+        netif ? netif->name[0] : 'X', netif? netif->name[1] : 'X'));
   }
 
   /* "::" packet source address? (used in duplicate address detection) */
@@ -827,6 +841,7 @@ ip6_output(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
           u8_t hl, u8_t tc, u8_t nexth)
 {
   struct netif *netif;
+  struct ip6_hdr *ip6hdr;
   ip6_addr_t src_addr, dest_addr;
 
   /* pbufs passed to IPv6 must have a ref-count of 1 as their payload pointer
@@ -886,6 +901,8 @@ ip6_output_hinted(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
           u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint)
 {
   struct netif *netif;
+  struct ip6_hdr *ip6hdr;
+  ip6_addr_t src_addr, dest_addr;
   err_t err;
 
   /* pbufs passed to IP must have a ref-count of 1 as their payload pointer
@@ -979,9 +996,9 @@ ip6_debug_print(struct pbuf *p)
                     IP6H_FL(ip6hdr)));
   LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n"));
   LWIP_DEBUGF(IP6_DEBUG, ("|     %5"U16_F"     |  %3"U16_F"  |  %3"U16_F"  | (plen, nexth, hopl)\n",
-                    ntohs(IP6H_PLEN(ip6hdr)),
-                    ntohs(IP6H_NEXTH(ip6hdr)),
-                    ntohs(IP6H_HOPLIM(ip6hdr))));
+                    IP6H_PLEN(ip6hdr),
+                    IP6H_NEXTH(ip6hdr),
+                    IP6H_HOPLIM(ip6hdr)));
   LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n"));
   LWIP_DEBUGF(IP6_DEBUG, ("|  %4"X32_F" |  %4"X32_F" |  %4"X32_F" |  %4"X32_F" | (src)\n",
                     IP6_ADDR_BLOCK1(&(ip6hdr->src)),