diff --git a/net/neighbor/neighbor_add.c b/net/neighbor/neighbor_add.c index 02cf8f6f96..b3fc738c96 100644 --- a/net/neighbor/neighbor_add.c +++ b/net/neighbor/neighbor_add.c @@ -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; diff --git a/net/neighbor/neighbor_findentry.c b/net/neighbor/neighbor_findentry.c index 30b13038cc..782b105157 100644 --- a/net/neighbor/neighbor_findentry.c +++ b/net/neighbor/neighbor_findentry.c @@ -44,6 +44,7 @@ #include #include +#include #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; }