mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #3744 from authmillenon/gnrc_ipv6_nc/enh/6lo-nd
gnrc_ipv6_nc: adapt neighbor cache for different ND implementations
This commit is contained in:
commit
4fa3bb89ea
@ -25,6 +25,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "kernel_types.h"
|
#include "kernel_types.h"
|
||||||
|
#include "net/eui64.h"
|
||||||
#include "net/ipv6/addr.h"
|
#include "net/ipv6/addr.h"
|
||||||
#include "net/gnrc/netif.h"
|
#include "net/gnrc/netif.h"
|
||||||
#include "net/gnrc/pktqueue.h"
|
#include "net/gnrc/pktqueue.h"
|
||||||
@ -118,7 +119,9 @@ extern "C" {
|
|||||||
* </a>.
|
* </a>.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
#ifdef MODULE_GNRC_NDP_NODE
|
||||||
gnrc_pktqueue_t *pkts; /**< Packets waiting for address resolution */
|
gnrc_pktqueue_t *pkts; /**< Packets waiting for address resolution */
|
||||||
|
#endif
|
||||||
ipv6_addr_t ipv6_addr; /**< IPv6 address of the neighbor */
|
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[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 */
|
uint8_t l2_addr_len; /**< Length of gnrc_ipv6_nc_t::l2_addr */
|
||||||
@ -143,6 +146,15 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
vtimer_t nbr_adv_timer;
|
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 */
|
uint8_t probes_remaining; /**< remaining number of unanswered probes */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
@ -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 */
|
/* Otherwise, fill free entry with your fresh information */
|
||||||
free_entry->iface = iface;
|
free_entry->iface = iface;
|
||||||
|
|
||||||
|
#ifdef MODULE_GNRC_NDP_NODE
|
||||||
free_entry->pkts = NULL;
|
free_entry->pkts = NULL;
|
||||||
|
#endif
|
||||||
memcpy(&(free_entry->ipv6_addr), ipv6_addr, sizeof(ipv6_addr_t));
|
memcpy(&(free_entry->ipv6_addr), ipv6_addr, sizeof(ipv6_addr_t));
|
||||||
DEBUG("ipv6_nc: Register %s for interface %" PRIkernel_pid,
|
DEBUG("ipv6_nc: Register %s for interface %" PRIkernel_pid,
|
||||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
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)),
|
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||||
iface);
|
iface);
|
||||||
|
|
||||||
|
#ifdef MODULE_GNRC_NDP_NODE
|
||||||
while (entry->pkts != NULL) {
|
while (entry->pkts != NULL) {
|
||||||
#ifdef MODULE_GNRC_PKTBUF
|
|
||||||
gnrc_pktbuf_release(entry->pkts->pkt);
|
gnrc_pktbuf_release(entry->pkts->pkt);
|
||||||
#endif
|
|
||||||
entry->pkts->pkt = NULL;
|
entry->pkts->pkt = NULL;
|
||||||
gnrc_pktqueue_remove_head(&entry->pkts);
|
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));
|
ipv6_addr_set_unspecified(&(entry->ipv6_addr));
|
||||||
entry->iface = KERNEL_PID_UNDEF;
|
entry->iface = KERNEL_PID_UNDEF;
|
||||||
|
@ -195,8 +195,6 @@ void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
|||||||
|
|
||||||
if (l2tgt_len != -ENOTSUP) {
|
if (l2tgt_len != -ENOTSUP) {
|
||||||
if (gnrc_ipv6_nc_get_state(nc_entry) == GNRC_IPV6_NC_STATE_INCOMPLETE) {
|
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)) {
|
if (_pkt_has_l2addr(netif_hdr) && (l2tgt_len == 0)) {
|
||||||
/* link-layer has addresses, but no TLLAO supplied: discard silently
|
/* link-layer has addresses, but no TLLAO supplied: discard silently
|
||||||
* (see https://tools.ietf.org/html/rfc4861#section-7.2.5) */
|
* (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;
|
nc_entry->flags &= ~GNRC_IPV6_NC_IS_ROUTER;
|
||||||
/* TODO: update state of neighbor as router in FIB? */
|
/* 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) {
|
while ((queued_pkt = gnrc_pktqueue_remove_head(&nc_entry->pkts)) != NULL) {
|
||||||
gnrc_netapi_send(gnrc_ipv6_pid, queued_pkt->pkt);
|
gnrc_netapi_send(gnrc_ipv6_pid, queued_pkt->pkt);
|
||||||
queued_pkt->pkt = NULL;
|
queued_pkt->pkt = NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* first or-term: no link-layer, but nc_entry has l2addr,
|
/* first or-term: no link-layer, but nc_entry has l2addr,
|
||||||
|
Loading…
Reference in New Issue
Block a user