Skip to content

Commit

Permalink
gnrc_netif: distinct is_6lo() and is_6ln()
Browse files Browse the repository at this point in the history
The functions now are semantic distinct:

- gnrc_netif_is_6lo(): the interface is a 6Lo interface
- gnrc_netif_is_6ln(): the interface is using Neighbor Discovery
  according to RFC 6775
  • Loading branch information
miri64 committed Oct 20, 2019
1 parent 8c2942e commit 5f53e73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
28 changes: 16 additions & 12 deletions sys/include/net/gnrc/netif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,29 @@ static inline bool gnrc_netif_is_rtr_adv(const gnrc_netif_t *netif)
*
* @attention Requires prior locking
* @note Assumed to be true, when @ref GNRC_NETIF_NUMOF == 1 and
* @ref net_gnrc_sixlowpan module is included (and
* @ref GNRC_IPV6_NIB_CONF_6LN is not 0, otherwise assumed to be
* false).
* @ref net_gnrc_sixlowpan module is included. When the
* @ref net_gnrc_sixlowpan module is not included, it is assumed
* to be false.
*
* @param[in] netif the network interface
*
* @return true, if the interface represents a 6LN
* @return false, if the interface does not represent a 6LN
*/
#define gnrc_netif_is_6lo(netif) gnrc_netif_is_6ln(netif)
#if ((GNRC_NETIF_NUMOF > 1) && defined(MODULE_GNRC_SIXLOWPAN)) || defined(DOXYGEN)
bool gnrc_netif_is_6lo(const gnrc_netif_t *netif);
#elif (GNRC_NETIF_NUMOF == 1) && defined(MODULE_GNRC_SIXLOWPAN)
#define gnrc_netif_is_6lo(netif) (true)
#else
#define gnrc_netif_is_6lo(netif) (false)
#endif

/**
* @brief Checks if the interface represents a 6Lo node (6LN) according to
* RFC 6775
*
* @attention Requires prior locking
* @note Assumed to be true, when @ref GNRC_NETIF_NUMOF == 1 and
* @ref net_gnrc_sixlowpan module is included (and
* @ref GNRC_IPV6_NIB_CONF_6LN is not 0, otherwise assumed to be
* false).
* @note Assumed to be false, when @ref GNRC_IPV6_NIB_CONF_6LN is 0.
*
* @param[in] netif the network interface
*
Expand All @@ -362,10 +365,11 @@ static inline bool gnrc_netif_is_rtr_adv(const gnrc_netif_t *netif)
* @return true, if the interface represents a 6LN
* @return false, if the interface does not represent a 6LN
*/
#if (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN) || defined(DOXYGEN)
bool gnrc_netif_is_6ln(const gnrc_netif_t *netif);
#elif GNRC_IPV6_NIB_CONF_6LN
#define gnrc_netif_is_6ln(netif) (true)
#if GNRC_IPV6_NIB_CONF_6LN || defined(DOXYGEN)
static inline bool gnrc_netif_is_6ln(const gnrc_netif_t *netif)
{
return (netif->flags & GNRC_NETIF_FLAGS_6LN);
}
#else
#define gnrc_netif_is_6ln(netif) (false)
#endif
Expand Down
6 changes: 3 additions & 3 deletions sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ static ipv6_addr_t *_src_addr_selection(gnrc_netif_t *netif,
}
#endif /* MODULE_GNRC_IPV6 */

#if (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN)
bool gnrc_netif_is_6ln(const gnrc_netif_t *netif)
#if (GNRC_NETIF_NUMOF > 1) && defined(MODULE_GNRC_SIXLOWPAN)
bool gnrc_netif_is_6lo(const gnrc_netif_t *netif)
{
switch (netif->device_type) {
#ifdef MODULE_GNRC_SIXLOENC
Expand All @@ -1110,7 +1110,7 @@ bool gnrc_netif_is_6ln(const gnrc_netif_t *netif)
return false;
}
}
#endif /* (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN) */
#endif /* (GNRC_NETIF_NUMOF > 1) && defined(MODULE_GNRC_SIXLOWPAN) */

static void _update_l2addr_from_dev(gnrc_netif_t *netif)
{
Expand Down

0 comments on commit 5f53e73

Please sign in to comment.