Browse Source

gnrc_ipv6_nc: adapt neighbor cache for different ND implementations

dev/timer
Martine Lenders 8 years ago
parent
commit
a65804027f
  1. 12
      sys/include/net/gnrc/ipv6/nc.h
  2. 12
      sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c
  3. 6
      sys/net/gnrc/network_layer/ndp/gnrc_ndp.c

12
sys/include/net/gnrc/ipv6/nc.h

@ -25,6 +25,7 @@
#include <stdint.h>
#include "kernel_types.h"
#include "net/eui64.h"
#include "net/ipv6/addr.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/pktqueue.h"
@ -118,7 +119,9 @@ extern "C" {
* </a>.
*/
typedef struct {
#ifdef MODULE_GNRC_NDP_NODE
gnrc_pktqueue_t *pkts; /**< Packets waiting for address resolution */
#endif
ipv6_addr_t ipv6_addr; /**< IPv6 address of the neighbor */
uint8_t l2_addr[GNRC_IPV6_NC_L2_ADDR_MAX]; /**< Link layer address of the neighbor */
uint8_t l2_addr_len; /**< Length of gnrc_ipv6_nc_t::l2_addr */
@ -143,6 +146,15 @@ typedef struct {
*/
vtimer_t nbr_adv_timer;
#ifdef MODULE_GNRC_SIXLOWPAN_ND
vtimer_t rtr_sol_timer; /**< Retransmission timer for unicast router solicitations */
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
vtimer_t type_timeout; /**< Timer for type transissions */
eui64_t eui64; /**< the unique EUI-64 of the neighbor (might be
* different from L2 address, if l2_addr_len == 2) */
#endif
uint8_t probes_remaining; /**< remaining number of unanswered probes */
/**
* @}

12
sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c

@ -102,7 +102,9 @@ gnrc_ipv6_nc_t *gnrc_ipv6_nc_add(kernel_pid_t iface, const ipv6_addr_t *ipv6_add
/* Otherwise, fill free entry with your fresh information */
free_entry->iface = iface;
#ifdef MODULE_GNRC_NDP_NODE
free_entry->pkts = NULL;
#endif
memcpy(&(free_entry->ipv6_addr), ipv6_addr, sizeof(ipv6_addr_t));
DEBUG("ipv6_nc: Register %s for interface %" PRIkernel_pid,
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
@ -137,13 +139,19 @@ void gnrc_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr)
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
iface);
#ifdef MODULE_GNRC_NDP_NODE
while (entry->pkts != NULL) {
#ifdef MODULE_GNRC_PKTBUF
gnrc_pktbuf_release(entry->pkts->pkt);
#endif
entry->pkts->pkt = NULL;
gnrc_pktqueue_remove_head(&entry->pkts);
}
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_ND
vtimer_remove(&entry->rtr_sol_timer);
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
vtimer_remove(&entry->type_timeout);
#endif
ipv6_addr_set_unspecified(&(entry->ipv6_addr));
entry->iface = KERNEL_PID_UNDEF;

6
sys/net/gnrc/network_layer/ndp/gnrc_ndp.c

@ -195,8 +195,6 @@ void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
if (l2tgt_len != -ENOTSUP) {
if (gnrc_ipv6_nc_get_state(nc_entry) == GNRC_IPV6_NC_STATE_INCOMPLETE) {
gnrc_pktqueue_t *queued_pkt;
if (_pkt_has_l2addr(netif_hdr) && (l2tgt_len == 0)) {
/* link-layer has addresses, but no TLLAO supplied: discard silently
* (see https://tools.ietf.org/html/rfc4861#section-7.2.5) */
@ -221,11 +219,13 @@ void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
nc_entry->flags &= ~GNRC_IPV6_NC_IS_ROUTER;
/* TODO: update state of neighbor as router in FIB? */
}
#ifdef MODULE_GNRC_NDP_NODE
gnrc_pktqueue_t *queued_pkt;
while ((queued_pkt = gnrc_pktqueue_remove_head(&nc_entry->pkts)) != NULL) {
gnrc_netapi_send(gnrc_ipv6_pid, queued_pkt->pkt);
queued_pkt->pkt = NULL;
}
#endif
}
else {
/* first or-term: no link-layer, but nc_entry has l2addr,

Loading…
Cancel
Save