Networking IPv6: Fix and error when adding a neighbor to the table. Comparing wrong address. Add more debug info too

This commit is contained in:
Gregory Nutt 2015-01-21 14:13:57 -06:00
parent 7dd07f7179
commit 4db99c631f
2 changed files with 30 additions and 6 deletions

View file

@ -76,10 +76,17 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, FAR struct neighbor_addr_s *addr)
int oldest_ndx;
int i;
nlldbg("Add neighbor: %02x:%02x:%02x:%02x:%02x:%02x\n",
addr->na_addr.ether_addr_octet[0], addr->na_addr.ether_addr_octet[1],
addr->na_addr.ether_addr_octet[2], addr->na_addr.ether_addr_octet[3],
addr->na_addr.ether_addr_octet[4], addr->na_addr.ether_addr_octet[5]);
nlldbg("Add neighbor: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]),
ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]),
ntohs(ipaddr[6]), ntohs(ipaddr[7]));
nlldbg(" at: %02x:%02x:%02x:%02x:%02x:%02x\n",
addr->na_addr.ether_addr_octet[0],
addr->na_addr.ether_addr_octet[1],
addr->na_addr.ether_addr_octet[2],
addr->na_addr.ether_addr_octet[3],
addr->na_addr.ether_addr_octet[4],
addr->na_addr.ether_addr_octet[5]);
/* Find the first unused entry or the oldest used entry. */
@ -94,7 +101,7 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, FAR struct neighbor_addr_s *addr)
break;
}
if (net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, addr))
if (net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, ipaddr))
{
oldest_ndx = i;
break;

View file

@ -44,6 +44,7 @@
#include <nuttx/config.h>
#include <string.h>
#include <debug.h>
#include "neighbor/neighbor.h"
@ -71,13 +72,29 @@ FAR struct neighbor_entry *neighbor_findentry(net_ipv6addr_t ipaddr)
{
int i;
nlldbg("Find neighbor: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]),
ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]),
ntohs(ipaddr[6]), ntohs(ipaddr[7]));
for (i = 0; i < CONFIG_NET_IPv6_NCONF_ENTRIES; ++i)
{
if (net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, ipaddr))
FAR struct neighbor_entry *neighbor = &g_neighbors[i];
if (net_ipv6addr_cmp(neighbor->ne_ipaddr, ipaddr))
{
nlldbg(" at: %02x:%02x:%02x:%02x:%02x:%02x\n",
neighbor->ne_addr.na_addr.ether_addr_octet[0],
neighbor->ne_addr.na_addr.ether_addr_octet[1],
neighbor->ne_addr.na_addr.ether_addr_octet[2],
neighbor->ne_addr.na_addr.ether_addr_octet[3],
neighbor->ne_addr.na_addr.ether_addr_octet[4],
neighbor->ne_addr.na_addr.ether_addr_octet[5]);
return &g_neighbors[i];
}
}
nlldbg(" Not found\n");
return NULL;
}