Added IPv6 loopback address to loopback-netif, fixed last commit

This commit is contained in:
Simon Goldschmidt 2014-01-17 21:55:46 +01:00
parent 13e40f754c
commit 1e65eb4936
5 changed files with 41 additions and 12 deletions

View File

@ -80,6 +80,9 @@ HISTORY
++ Bugfixes:
2014-01-17: Grant Erickson, Jay Logue, Simon Goldschmidt
* ipv6.c, netif.c: patch #7913 Enable Support for IPv6 Loopback
2014-01-16: Stathis Voukelatos
* netif.c: patch #7902 Fixed netif_poll() operation when LWIP_LOOPBACK_MAX_PBUFS > 0

View File

@ -772,11 +772,11 @@ err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
if (ip_addr_cmp(dest, &netif->ip_addr)) {
/* Packet to self, enqueue it for loopback */
LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()"));
return netif_loop_output(netif, p, dest);
return netif_loop_output(netif, p);
}
#if LWIP_IGMP
if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) {
netif_loop_output(netif, p, dest);
netif_loop_output(netif, p);
}
#endif /* LWIP_IGMP */
#endif /* ENABLE_LOOPBACK */

View File

@ -803,13 +803,13 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
#if ENABLE_LOOPBACK
{
int i;
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);
/* Packet to self, enqueue it for loopback */
LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
return netif_loop_output(netif, p);
}
}
}

View File

@ -95,6 +95,10 @@ static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr
#endif
#if LWIP_HAVE_LOOPIF
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr);
static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr);
static struct netif loop_netif;
/**
@ -114,7 +118,8 @@ netif_loopif_init(struct netif *netif)
netif->name[0] = 'l';
netif->name[1] = 'o';
netif->output = netif_loop_output;
netif->output = netif_loop_output_ipv4;
netif->output_ip6 = netif_loop_output_ipv6;
return ERR_OK;
}
#endif /* LWIP_HAVE_LOOPIF */
@ -133,6 +138,15 @@ netif_init(void)
#else /* NO_SYS */
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input);
#endif /* NO_SYS */
#if LWIP_IPV6
loop_netif.ip6_addr[0].addr[0] = 0;
loop_netif.ip6_addr[0].addr[1] = 0;
loop_netif.ip6_addr[0].addr[2] = 0;
loop_netif.ip6_addr[0].addr[3] = PP_HTONL(0x00000001UL);
loop_netif.ip6_addr_state[0] = IP6_ADDR_VALID;
#endif /* LWIP_IPV6 */
netif_set_up(&loop_netif);
#endif /* LWIP_HAVE_LOOPIF */
@ -661,13 +675,11 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_
*
* @param netif the lwip network interface structure
* @param p the (IP) packet to 'send'
* @param ipaddr the ip address to send the packet to (not used)
* @return ERR_OK if the packet has been sent
* ERR_MEM if the pbuf used to copy the packet couldn't be allocated
*/
err_t
netif_loop_output(struct netif *netif, struct pbuf *p,
ip_addr_t *ipaddr)
netif_loop_output(struct netif *netif, struct pbuf *p)
{
struct pbuf *r;
err_t err;
@ -685,7 +697,6 @@ netif_loop_output(struct netif *netif, struct pbuf *p,
#endif /* LWIP_HAVE_LOOPIF */
#endif /* LWIP_SNMP */
SYS_ARCH_DECL_PROTECT(lev);
LWIP_UNUSED_ARG(ipaddr);
/* Allocate a new pbuf */
r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
@ -747,6 +758,21 @@ netif_loop_output(struct netif *netif, struct pbuf *p,
return ERR_OK;
}
static err_t
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr)
{
LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p);
}
static err_t
netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr)
{
LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p);
}
/**
* Call netif_poll() in the main loop of your application. This is to prevent
* reentering non-reentrant functions like tcp_input(). Packets passed to

View File

@ -359,7 +359,7 @@ void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_
#endif /* LWIP_IGMP */
#if ENABLE_LOOPBACK
err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip);
err_t netif_loop_output(struct netif *netif, struct pbuf *p);
void netif_poll(struct netif *netif);
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
void netif_poll_all(void);