Browse Source

sixlowpan nd: send actually router advertisements

dev/timer
Oleg Hahm 7 years ago
parent
commit
b15660033a
  1. 26
      sys/include/net/gnrc/ndp.h
  2. 6
      sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
  3. 12
      sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
  4. 2
      sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c

26
sys/include/net/gnrc/ndp.h

@ -41,14 +41,24 @@
extern "C" {
#endif
#define GNRC_NDP_MSG_RTR_TIMEOUT (0x0210) /**< Message type for router timeouts */
#define GNRC_NDP_MSG_ADDR_TIMEOUT (0x0211) /**< Message type for address timeouts */
#define GNRC_NDP_MSG_NBR_SOL_RETRANS (0x0212) /**< Message type for multicast
* neighbor solicitation retransmissions */
#define GNRC_NDP_MSG_RTR_ADV_RETRANS (0x0213) /**< Message type for periodic router advertisements */
#define GNRC_NDP_MSG_RTR_ADV_DELAY (0x0214) /**< Message type for delayed router advertisements */
#define GNRC_NDP_MSG_RTR_SOL_RETRANS (0x0215) /**< Message type for periodic router solicitations */
#define GNRC_NDP_MSG_NC_STATE_TIMEOUT (0x0216) /**< Message type for neighbor cache state timeouts */
/** Message type for router timeouts */
#define GNRC_NDP_MSG_RTR_TIMEOUT (0x0210)
/** Message type for address timeouts */
#define GNRC_NDP_MSG_ADDR_TIMEOUT (0x0211)
/** Message type for multicast neighbor solicitation retransmissions */
#define GNRC_NDP_MSG_NBR_SOL_RETRANS (0x0212)
/** Message type for periodic router advertisements */
#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

6
sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c

@ -255,6 +255,12 @@ static void *_event_loop(void *args)
DEBUG("ipv6: address registration timeout received\n");
gnrc_sixlowpan_nd_router_gc_nc((gnrc_ipv6_nc_t *)msg.content.ptr);
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
default:
break;

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

@ -414,6 +414,17 @@ void gnrc_ndp_rtr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
#endif
delay = timex_set(0, genrand_uint32_range(0, ms));
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)) {
/* either multicast, if source unspecified */
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,
GNRC_NDP_MSG_RTR_ADV_DELAY, nc_entry);
}
#endif
}
}
/* otherwise ignore silently */

2
sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c

@ -462,8 +462,10 @@ void gnrc_ndp_internal_send_rtr_adv(kernel_pid_t iface, ipv6_addr_t *src, ipv6_a
pkt = hdr;
}
if (src == NULL) {
mutex_unlock(&ipv6_iface->mutex);
/* get address from source selection algorithm */
src = gnrc_ipv6_netif_find_best_src_addr(iface, dst);
mutex_lock(&ipv6_iface->mutex);
}
/* add SL2A for source address */
if (src != NULL) {

Loading…
Cancel
Save