Browse Source

netif: use xtimer for gnrc_ipv6_netif_t::rtr_adv_timer

cc430
Cenk Gündoğan 7 years ago
parent
commit
a979d0c72c
  1. 3
      sys/include/net/gnrc/ipv6/netif.h
  2. 2
      sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c
  3. 22
      sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
  4. 8
      sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c

3
sys/include/net/gnrc/ipv6/netif.h

@ -342,7 +342,8 @@ typedef struct {
xtimer_t rtr_sol_timer; /**< Timer for periodic router solicitations */
msg_t rtr_sol_msg; /**< msg_t for gnrc_ipv6_netif_t::rtr_sol_timer */
#if defined (MODULE_GNRC_NDP_ROUTER) || defined (MODULE_GNRC_SIXLOWPAN_ND_ROUTER)
vtimer_t rtr_adv_timer; /**< Timer for periodic router advertisements */
xtimer_t rtr_adv_timer; /**< Timer for periodic router advertisements */
msg_t rtr_adv_msg; /**< msg_t for gnrc_ipv6_netif_t::rtr_adv_timer */
#endif
} gnrc_ipv6_netif_t;

2
sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c

@ -236,7 +236,7 @@ void gnrc_ipv6_netif_remove(kernel_pid_t pid)
mutex_lock(&entry->mutex);
xtimer_remove(&entry->rtr_sol_timer);
#ifdef MODULE_GNRC_NDP_ROUTER
vtimer_remove(&entry->rtr_adv_timer);
xtimer_remove(&entry->rtr_adv_timer);
#endif
_reset_addr_from_entry(entry);
DEBUG("ipv6 netif: Remove IPv6 interface %" PRIkernel_pid "\n", pid);

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

@ -422,38 +422,42 @@ void gnrc_ndp_rtr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
_stale_nc(iface, &ipv6->src, l2src, l2src_len);
/* send delayed */
if (if_entry->flags & GNRC_IPV6_NETIF_FLAGS_RTR_ADV) {
timex_t delay;
uint32_t delay;
uint32_t ms = GNRC_NDP_MAX_RTR_ADV_DELAY;
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
if (if_entry->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) {
ms = GNRC_SIXLOWPAN_ND_MAX_RTR_ADV_DELAY;
}
#endif
delay = timex_set(0, genrand_uint32_range(0, ms));
vtimer_remove(&if_entry->rtr_adv_timer);
delay = genrand_uint32_range(0, ms);
xtimer_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);
if_entry->rtr_adv_msg.type = GNRC_NDP_MSG_RTR_ADV_SIXLOWPAN_DELAY;
if_entry->rtr_adv_msg.content.ptr = (char *) nc_entry;
xtimer_set_msg(&if_entry->rtr_adv_timer, delay, &if_entry->rtr_adv_msg,
gnrc_ipv6_pid);
}
}
#elif defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER)
if (ipv6_addr_is_unspecified(&ipv6->src)) {
/* either multicast, if source unspecified */
vtimer_set_msg(&if_entry->rtr_adv_timer, delay, gnrc_ipv6_pid,
GNRC_NDP_MSG_RTR_ADV_RETRANS, if_entry);
if_entry->rtr_adv_msg.type = GNRC_NDP_MSG_RTR_ADV_RETRANS;
if_entry->rtr_adv_msg.content.ptr = (char *) if_entry;
xtimer_set_msg(&if_entry->rtr_adv_timer, delay, &if_entry->rtr_adv_msg,
gnrc_ipv6_pid);
}
else {
/* or unicast, if source is known */
/* XXX: can't just use GNRC_NETAPI_MSG_TYPE_SND, since the next retransmission
* must also be set. */
gnrc_ipv6_nc_t *nc_entry = gnrc_ipv6_nc_get(iface, &ipv6->src);
xtimer_set_msg(&nc_entry->rtr_adv_timer, (uint32_t) timex_uint64(delay),
&nc_entry->rtr_adv_msg, gnrc_ipv6_pid);
xtimer_set_msg(&nc_entry->rtr_adv_timer, delay, &nc_entry->rtr_adv_msg,
gnrc_ipv6_pid);
}
#endif
}

8
sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c

@ -106,9 +106,11 @@ static void _send_rtr_adv(gnrc_ipv6_netif_t *iface, ipv6_addr_t *dst)
}
if (!fin || (iface->rtr_adv_count > 1)) { /* regard for off-by-one-error */
/* reset timer for next router advertisement */
vtimer_remove(&iface->rtr_adv_timer);
vtimer_set_msg(&iface->rtr_adv_timer, timex_set(interval, 0),
gnrc_ipv6_pid, GNRC_NDP_MSG_RTR_ADV_RETRANS, iface);
xtimer_remove(&iface->rtr_adv_timer);
iface->rtr_adv_msg.type = GNRC_NDP_MSG_RTR_ADV_RETRANS;
iface->rtr_adv_msg.content.ptr = (char *) iface;
xtimer_set_msg(&iface->rtr_adv_timer, interval * SEC_IN_USEC, &iface->rtr_adv_msg,
gnrc_ipv6_pid);
}
mutex_unlock(&iface->mutex);
for (int i = 0; i < GNRC_IPV6_NETIF_ADDR_NUMOF; i++) {

Loading…
Cancel
Save