u8_t nexth;
u16_t hlen; /* the current header length */
u8_t i;
-#if IP_ACCEPT_LINK_LAYER_ADDRESSING
+#if 0 /*IP_ACCEPT_LINK_LAYER_ADDRESSING*/
+ @todo
int check_ip_src=1;
#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
/* 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);
/* current header pointer. */
ip_data.current_ip6_header = ip6hdr;
+ /* In netif, used in case we need to send ICMPv6 packets back. */
+ ip_data.current_netif = inp;
+
/* match packet against an interface, i.e. is this packet for us? */
if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
/* Always joined to multicast if-local and link-local all-nodes group. */
}
#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 {
}
}
}
+ 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;
} 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) */
}
/* current netif pointer. */
- ip_data.current_netif = inp;
+ ip_data.current_netif = netif;
/* Save next header type. */
nexth = IP6H_NEXTH(ip6hdr);
nexth = *((u8_t *)p->payload);
/* Get the header length. */
- hlen = 8 * (1 + *((u8_t *)p->payload) + 1);
+ hlen = 8 * (1 + *((u8_t *)p->payload + 1));
ip_data.current_ip_header_tot_len += hlen;
/* Skip over this header. */
nexth = *((u8_t *)p->payload);
/* Get the header length. */
- hlen = 8 * (1 + *((u8_t *)p->payload) + 1);
+ hlen = 8 * (1 + *((u8_t *)p->payload + 1));
ip_data.current_ip_header_tot_len += hlen;
/* Skip over this header. */
nexth = *((u8_t *)p->payload);
/* Get the header length. */
- hlen = 8 * (1 + *((u8_t *)p->payload) + 1);
+ hlen = 8 * (1 + *((u8_t *)p->payload + 1));
ip_data.current_ip_header_tot_len += hlen;
/* Skip over this header. */
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
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),
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
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),
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)),