Enable support for IPv6 loopback

Packets are sent through the loopback path when they are addressed to any
of the valid local IPv6 addresses.
This commit is contained in:
Jay Logue 2013-01-28 17:55:12 -08:00 committed by Simon Goldschmidt
parent 8b63a89267
commit 13e40f754c
2 changed files with 19 additions and 6 deletions

View File

@ -802,10 +802,17 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
ip6_debug_print(p);
#if ENABLE_LOOPBACK
/* TODO implement loopback for v6
if (ip6_addr_cmp(dest, netif_ip6_addr(0))) {
{
int i;
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
ip6_addr_cmp(dest, netif_ip6_addr(netif, i))) {
/* Packet to self, enqueue it for loopback */
LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
return netif_loop_output(netif, p, dest);
}*/
}
}
}
#endif /* ENABLE_LOOPBACK */
#if LWIP_IPV6_FRAG
/* don't fragment if interface has mtu set to 0 [loopif] */
@ -814,7 +821,7 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
}
#endif /* LWIP_IPV6_FRAG */
LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()"));
LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()\n"));
return netif->output_ip6(netif, p, dest);
}

View File

@ -88,6 +88,12 @@ static u8_t netif_num;
static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr);
#endif /* LWIP_IPV6 */
#if LWIP_IPV6
#define ipX_input(in, netif) (IP6H_V((const struct ip6_hdr *)in->payload) == 6) ? ip6_input(in, netif) : ip_input(in, netif)
#else
#define ipX_input(in, netif) ip_input(in, netif)
#endif
#if LWIP_HAVE_LOOPIF
static struct netif loop_netif;
@ -804,7 +810,7 @@ netif_poll(struct netif *netif)
snmp_add_ifinoctets(stats_if, in->tot_len);
snmp_inc_ifinucastpkts(stats_if);
/* loopback packets are always IP packets! */
if (ip_input(in, netif) != ERR_OK) {
if (ipX_input(in, netif) != ERR_OK) {
pbuf_free(in);
}
/* Don't reference the packet any more! */