Merge pull request #3853 from OlegHahm/6lowpan_nd_router_fixes
6lowpan nd router fixes
This commit is contained in:
commit
a19a04c753
@ -41,14 +41,24 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GNRC_NDP_MSG_RTR_TIMEOUT (0x0210) /**< Message type for router timeouts */
|
/** Message type for router timeouts */
|
||||||
#define GNRC_NDP_MSG_ADDR_TIMEOUT (0x0211) /**< Message type for address timeouts */
|
#define GNRC_NDP_MSG_RTR_TIMEOUT (0x0210)
|
||||||
#define GNRC_NDP_MSG_NBR_SOL_RETRANS (0x0212) /**< Message type for multicast
|
/** Message type for address timeouts */
|
||||||
* neighbor solicitation retransmissions */
|
#define GNRC_NDP_MSG_ADDR_TIMEOUT (0x0211)
|
||||||
#define GNRC_NDP_MSG_RTR_ADV_RETRANS (0x0213) /**< Message type for periodic router advertisements */
|
/** Message type for multicast neighbor solicitation retransmissions */
|
||||||
#define GNRC_NDP_MSG_RTR_ADV_DELAY (0x0214) /**< Message type for delayed router advertisements */
|
#define GNRC_NDP_MSG_NBR_SOL_RETRANS (0x0212)
|
||||||
#define GNRC_NDP_MSG_RTR_SOL_RETRANS (0x0215) /**< Message type for periodic router solicitations */
|
/** Message type for periodic router advertisements */
|
||||||
#define GNRC_NDP_MSG_NC_STATE_TIMEOUT (0x0216) /**< Message type for neighbor cache state timeouts */
|
#define GNRC_NDP_MSG_RTR_ADV_RETRANS (0x0213)
|
||||||
|
/** Message type for delayed router advertisements */
|
||||||
|
#define GNRC_NDP_MSG_RTR_ADV_DELAY (0x0214)
|
||||||
|
/** Message type for delayed router advertisements in a 6LoWPAN
|
||||||
|
* 6LoWPAN needs a special handling, because router advertisements are only
|
||||||
|
* sent after a short randomized delay, but not periodically. */
|
||||||
|
#define GNRC_NDP_MSG_RTR_ADV_SIXLOWPAN_DELAY (0x0215)
|
||||||
|
/** Message type for periodic router solicitations */
|
||||||
|
#define GNRC_NDP_MSG_RTR_SOL_RETRANS (0x0216)
|
||||||
|
/** Message type for neighbor cache state timeouts */
|
||||||
|
#define GNRC_NDP_MSG_NC_STATE_TIMEOUT (0x0217)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Host constants
|
* @name Host constants
|
||||||
|
|||||||
@ -255,6 +255,12 @@ static void *_event_loop(void *args)
|
|||||||
DEBUG("ipv6: address registration timeout received\n");
|
DEBUG("ipv6: address registration timeout received\n");
|
||||||
gnrc_sixlowpan_nd_router_gc_nc((gnrc_ipv6_nc_t *)msg.content.ptr);
|
gnrc_sixlowpan_nd_router_gc_nc((gnrc_ipv6_nc_t *)msg.content.ptr);
|
||||||
break;
|
break;
|
||||||
|
case GNRC_NDP_MSG_RTR_ADV_SIXLOWPAN_DELAY:
|
||||||
|
DEBUG("ipv6: Delayed router advertisement event received\n");
|
||||||
|
gnrc_ipv6_nc_t *nc_entry = (gnrc_ipv6_nc_t *)msg.content.ptr;
|
||||||
|
gnrc_ndp_internal_send_rtr_adv(nc_entry->iface, NULL,
|
||||||
|
&(nc_entry->ipv6_addr), false);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -414,6 +414,17 @@ void gnrc_ndp_rtr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
|||||||
#endif
|
#endif
|
||||||
delay = timex_set(0, genrand_uint32_range(0, ms));
|
delay = timex_set(0, genrand_uint32_range(0, ms));
|
||||||
vtimer_remove(&if_entry->rtr_adv_timer);
|
vtimer_remove(&if_entry->rtr_adv_timer);
|
||||||
|
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
|
||||||
|
/* in case of a 6LBR we have to check if the interface is actually
|
||||||
|
* the 6lo interface */
|
||||||
|
if (if_entry->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) {
|
||||||
|
gnrc_ipv6_nc_t *nc_entry = gnrc_ipv6_nc_get(iface, &ipv6->src);
|
||||||
|
if (nc_entry != NULL) {
|
||||||
|
vtimer_set_msg(&if_entry->rtr_adv_timer, delay, gnrc_ipv6_pid,
|
||||||
|
GNRC_NDP_MSG_RTR_ADV_SIXLOWPAN_DELAY, nc_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER)
|
||||||
if (ipv6_addr_is_unspecified(&ipv6->src)) {
|
if (ipv6_addr_is_unspecified(&ipv6->src)) {
|
||||||
/* either multicast, if source unspecified */
|
/* either multicast, if source unspecified */
|
||||||
vtimer_set_msg(&if_entry->rtr_adv_timer, delay, gnrc_ipv6_pid,
|
vtimer_set_msg(&if_entry->rtr_adv_timer, delay, gnrc_ipv6_pid,
|
||||||
@ -427,6 +438,7 @@ void gnrc_ndp_rtr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
|||||||
vtimer_set_msg(&if_entry->rtr_adv_timer, delay, gnrc_ipv6_pid,
|
vtimer_set_msg(&if_entry->rtr_adv_timer, delay, gnrc_ipv6_pid,
|
||||||
GNRC_NDP_MSG_RTR_ADV_DELAY, nc_entry);
|
GNRC_NDP_MSG_RTR_ADV_DELAY, nc_entry);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* otherwise ignore silently */
|
/* otherwise ignore silently */
|
||||||
|
|||||||
@ -462,8 +462,10 @@ void gnrc_ndp_internal_send_rtr_adv(kernel_pid_t iface, ipv6_addr_t *src, ipv6_a
|
|||||||
pkt = hdr;
|
pkt = hdr;
|
||||||
}
|
}
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
|
mutex_unlock(&ipv6_iface->mutex);
|
||||||
/* get address from source selection algorithm */
|
/* get address from source selection algorithm */
|
||||||
src = gnrc_ipv6_netif_find_best_src_addr(iface, dst);
|
src = gnrc_ipv6_netif_find_best_src_addr(iface, dst);
|
||||||
|
mutex_lock(&ipv6_iface->mutex);
|
||||||
}
|
}
|
||||||
/* add SL2A for source address */
|
/* add SL2A for source address */
|
||||||
if (src != NULL) {
|
if (src != NULL) {
|
||||||
|
|||||||
@ -160,9 +160,16 @@ kernel_pid_t gnrc_sixlowpan_nd_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_
|
|||||||
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
|
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
|
||||||
/* next hop determination: https://tools.ietf.org/html/rfc6775#section-6.5.4 */
|
/* next hop determination: https://tools.ietf.org/html/rfc6775#section-6.5.4 */
|
||||||
nc_entry = gnrc_ipv6_nc_get(iface, dst);
|
nc_entry = gnrc_ipv6_nc_get(iface, dst);
|
||||||
if ((nc_entry != NULL) && (gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_REGISTERED)) {
|
/* if NCE found */
|
||||||
|
if (nc_entry != NULL) {
|
||||||
|
gnrc_ipv6_netif_t *ipv6_if = gnrc_ipv6_netif_get(nc_entry->iface);
|
||||||
|
/* and interface is not 6LoWPAN */
|
||||||
|
if (!(ipv6_if->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) ||
|
||||||
|
/* or entry is registered */
|
||||||
|
(gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_REGISTERED)) {
|
||||||
next_hop = dst;
|
next_hop = dst;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* next hop determination according to: https://tools.ietf.org/html/rfc6775#section-5.6 */
|
/* next hop determination according to: https://tools.ietf.org/html/rfc6775#section-5.6 */
|
||||||
if ((next_hop == NULL) && ipv6_addr_is_link_local(dst)) { /* prefix is "on-link" */
|
if ((next_hop == NULL) && ipv6_addr_is_link_local(dst)) { /* prefix is "on-link" */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user