]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
Support IP_HDRINCL in ip6_output() and ip6_output_hinted(),
authorIvan Delamer <delamer@inicotech.com>
Fri, 2 Mar 2012 16:06:57 +0000 (09:06 -0700)
committerIvan Delamer <delamer@inicotech.com>
Fri, 2 Mar 2012 16:06:57 +0000 (09:06 -0700)
previously only supported in ip6_output_if().

src/core/ipv6/ip6.c

index b5529d08d4afb911e79ed038d63772bc6fa297b6..ef018888ad6c15524b735fb3a1ecca47f7f8eae9 100644 (file)
@@ -827,12 +827,23 @@ 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;
+  ip6_addr_t src_addr, dest_addr;
 
   /* pbufs passed to IPv6 must have a ref-count of 1 as their payload pointer
      gets altered as the packet is passed down the stack */
   LWIP_ASSERT("p->ref == 1", p->ref == 1);
 
-  if ((netif = ip6_route(src, dest)) == NULL) {
+  if (dest != IP_HDRINCL) {
+    netif = ip6_route(src, dest);
+  } else {
+    /* IP header included in p, read addresses. */
+    ip6hdr = (struct ip6_hdr *)p->payload;
+    ip6_addr_copy(src_addr, ip6hdr->src);
+    ip6_addr_copy(dest_addr, ip6hdr->dest);
+    netif = ip6_route(&src_addr, &dest_addr);
+  }
+
+  if (netif == NULL) {
     LWIP_DEBUGF(IP6_DEBUG, ("ip6_output: no route for %"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F"\n",
         IP6_ADDR_BLOCK1(dest),
         IP6_ADDR_BLOCK2(dest),
@@ -881,7 +892,17 @@ ip6_output_hinted(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
      gets altered as the packet is passed down the stack */
   LWIP_ASSERT("p->ref == 1", p->ref == 1);
 
-  if ((netif = ip6_route(src, dest)) == NULL) {
+  if (dest != IP_HDRINCL) {
+    netif = ip6_route(src, dest);
+  } else {
+    /* IP header included in p, read addresses. */
+    ip6hdr = (struct ip6_hdr *)p->payload;
+    ip6_addr_copy(src_addr, ip6hdr->src);
+    ip6_addr_copy(dest_addr, ip6hdr->dest);
+    netif = ip6_route(&src_addr, &dest_addr);
+  }
+
+  if (netif == NULL) {
     LWIP_DEBUGF(IP6_DEBUG, ("ip6_output: no route for %"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F"\n",
         IP6_ADDR_BLOCK1(dest),
         IP6_ADDR_BLOCK2(dest),