Skip to content

Commit

Permalink
gnrc_netif: introduce 6LN flag
Browse files Browse the repository at this point in the history
This makes it dynamically configurable if an interface actually want's
to use 6Lo ND (according to RFC 6775) or not.
  • Loading branch information
miri64 committed Oct 16, 2019
1 parent bccf52d commit 8c2942e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
7 changes: 7 additions & 0 deletions sys/include/net/gnrc/netif/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ enum {
*/
#define GNRC_NETIF_FLAGS_6LO_BACKBONE (0x00000800U)

/**
* @brief This interface represents a 6Lo node (6LN) according to RFC 6775
*
* @see [RFC 6775, section 2](https://tools.ietf.org/html/rfc6775#section-2)
*/
#define GNRC_NETIF_FLAGS_6LN (0x00001000U)

/**
* @brief Network interface is configured in raw mode
*/
Expand Down
8 changes: 8 additions & 0 deletions sys/include/net/gnrc/netif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,14 @@ static inline int gnrc_netif_get_eui64(gnrc_netif_t *netif, eui64_t *eui64)
return -ENOTSUP;
}

/**
* @brief Initializes an interface as 6LN according to RFC 6775 and according
* to its gnrc_netif_t::device_type
*
* @param[in] netif The network interface to initialize as 6LN
*/
void gnrc_netif_init_6ln(gnrc_netif_t *netif);

#if defined(MODULE_GNRC_IPV6) || defined(DOXYGEN)
/**
* @brief Initialize IPv6 MTU and other packet length related members of
Expand Down
26 changes: 26 additions & 0 deletions sys/net/gnrc/netif/gnrc_netif_device_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ int gnrc_netif_eui64_from_addr(const gnrc_netif_t *netif,
return -ENOTSUP;
}

void gnrc_netif_init_6ln(gnrc_netif_t *netif)
{
switch (netif->device_type) {
case NETDEV_TYPE_IEEE802154: {
/* see https://tools.ietf.org/html/rfc6775#section-5.2 */
uint16_t src_len = IEEE802154_LONG_ADDRESS_LEN;
gnrc_netapi_opt_t opt = { .opt = NETOPT_SRC_LEN,
.data = &src_len,
.data_len = sizeof(src_len) };

/* XXX we are supposed to be in interface context here, so use driver
* directly everything else would deadlock anyway */
netif->ops->set(netif, &opt);
}
/* intentionally falls through */
case NETDEV_TYPE_BLE:
case NETDEV_TYPE_NRFMIN:
#if GNRC_IPV6_NIB_CONF_6LN
netif->flags |= GNRC_NETIF_FLAGS_6LN;
#endif /* GNRC_IPV6_NIB_CONF_6LN */
/* intentionally falls through */
default:
break;
}
}

#ifdef MODULE_GNRC_IPV6
void gnrc_netif_ipv6_init_mtu(gnrc_netif_t *netif)
{
Expand Down
12 changes: 1 addition & 11 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,10 @@ void gnrc_ipv6_nib_init_iface(gnrc_netif_t *netif)
netif->ipv6.aac_mode = GNRC_NETIF_AAC_AUTO;
#endif /* GNRC_IPV6_NIB_CONF_SLAAC || GNRC_IPV6_NIB_CONF_6LN */
_init_iface_router(netif);
gnrc_netif_init_6ln(netif);
#if GNRC_IPV6_NIB_CONF_6LN
netif->ipv6.rs_sent = 0;
#endif /* GNRC_IPV6_NIB_CONF_6LN */
if (netif->device_type == NETDEV_TYPE_IEEE802154) {
/* see https://tools.ietf.org/html/rfc6775#section-5.2 */
uint16_t src_len = IEEE802154_LONG_ADDRESS_LEN;
gnrc_netapi_opt_t opt = { .opt = NETOPT_SRC_LEN,
.data = &src_len,
.data_len = sizeof(src_len) };

/* XXX we are supposed to be in interface context here, so use driver
* directly everything else would deadlock anyway */
netif->ops->set(netif, &opt);
}
netif->ipv6.na_sent = 0;
if (gnrc_netif_ipv6_group_join_internal(netif,
&ipv6_addr_all_nodes_link_local) < 0) {
Expand Down

0 comments on commit 8c2942e

Please sign in to comment.