mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc_netif: introduce gnrc_netif_ipv6 pseudo-module for IPv6 members
This aims to reduce circular dependencies in GNRC.
This commit is contained in:
parent
9801a439fc
commit
a48629b395
@ -352,6 +352,7 @@ ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
|
||||
USEMODULE += gnrc_ipv6_hdr
|
||||
USEMODULE += gnrc_ipv6_nib
|
||||
USEMODULE += gnrc_netif
|
||||
USEMODULE += gnrc_netif_ipv6
|
||||
USEMODULE += gnrc_nettype_ipv6
|
||||
endif
|
||||
|
||||
|
@ -34,6 +34,7 @@ PSEUDOMODULES += gnrc_netapi_mbox
|
||||
PSEUDOMODULES += gnrc_netif_events
|
||||
PSEUDOMODULES += gnrc_pktbuf_cmd
|
||||
PSEUDOMODULES += gnrc_netif_6lo
|
||||
PSEUDOMODULES += gnrc_netif_ipv6
|
||||
PSEUDOMODULES += gnrc_netif_cmd_%
|
||||
PSEUDOMODULES += gnrc_netif_dedup
|
||||
PSEUDOMODULES += gnrc_nettype_%
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "net/gnrc/netif/dedup.h"
|
||||
#endif
|
||||
#include "net/gnrc/netif/flags.h"
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
#include "net/gnrc/netif/ipv6.h"
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_MAC
|
||||
@ -83,7 +83,7 @@ typedef struct {
|
||||
#if IS_USED(MODULE_GNRC_NETIF_LORAWAN) || defined(DOXYGEN)
|
||||
gnrc_netif_lorawan_t lorawan; /**< LoRaWAN component */
|
||||
#endif
|
||||
#if defined(MODULE_GNRC_IPV6) || DOXYGEN
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6) || defined(DOXYGEN)
|
||||
gnrc_netif_ipv6_t ipv6; /**< IPv6 component */
|
||||
#endif
|
||||
#if defined(MODULE_GNRC_MAC) || DOXYGEN
|
||||
|
@ -58,7 +58,7 @@ void gnrc_netif_acquire(gnrc_netif_t *netif);
|
||||
*/
|
||||
void gnrc_netif_release(gnrc_netif_t *netif);
|
||||
|
||||
#if defined(MODULE_GNRC_IPV6) || DOXYGEN
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6) || DOXYGEN
|
||||
/**
|
||||
* @brief Adds an IPv6 address to the interface
|
||||
*
|
||||
@ -284,7 +284,7 @@ void gnrc_netif_ipv6_group_leave_internal(gnrc_netif_t *netif,
|
||||
*/
|
||||
int gnrc_netif_ipv6_group_idx(gnrc_netif_t *netif,
|
||||
const ipv6_addr_t *addr);
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) || defined(DOXYGEN) */
|
||||
|
||||
/**
|
||||
* @brief Checks if the interface represents a router according to RFC 4861
|
||||
@ -536,7 +536,7 @@ static inline int gnrc_netif_get_eui64(gnrc_netif_t *netif, eui64_t *eui64)
|
||||
*/
|
||||
void gnrc_netif_init_6ln(gnrc_netif_t *netif);
|
||||
|
||||
#if defined(MODULE_GNRC_IPV6) || defined(DOXYGEN)
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Initialize IPv6 MTU and other packet length related members of
|
||||
* @ref gnrc_netif_t based on gnrc_netif_t::device_type
|
||||
@ -669,13 +669,13 @@ static inline int gnrc_netif_ndp_addr_len_from_l2ao(gnrc_netif_t *netif,
|
||||
assert(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR);
|
||||
return l2util_ndp_addr_len_from_l2ao(netif->device_type, opt);
|
||||
}
|
||||
#else /* defined(MODULE_GNRC_IPV6) || defined(DOXYGEN) */
|
||||
#else /* IS_USED(MODULE_GNRC_NETIF_IPV6) || defined(DOXYGEN) */
|
||||
#define gnrc_netif_ipv6_init_mtu(netif) (void)netif
|
||||
#define gnrc_netif_ipv6_iid_from_addr(netif, addr, addr_len, iid) (-ENOTSUP)
|
||||
#define gnrc_netif_ipv6_iid_to_addr(netif, iid, addr) (-ENOTSUP)
|
||||
#define gnrc_netif_ndp_addr_len_from_l2ao(netif, opt) (-ENOTSUP)
|
||||
#define gnrc_netif_ipv6_get_iid(netif, iid) (-ENOTSUP)
|
||||
#endif /* defined(MODULE_GNRC_IPV6) || defined(DOXYGEN) */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) || defined(DOXYGEN) */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -135,7 +135,7 @@ int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
|
||||
case NETOPT_STATS:
|
||||
/* XXX discussed this with Oleg, it's supposed to be a pointer */
|
||||
switch ((int16_t)opt->context) {
|
||||
#if defined(MODULE_NETSTATS_IPV6) && defined(MODULE_GNRC_IPV6)
|
||||
#if IS_USED(MODULE_NETSTATS_IPV6) && IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
case NETSTATS_IPV6:
|
||||
assert(opt->data_len == sizeof(netstats_t *));
|
||||
*((netstats_t **)opt->data) = &netif->ipv6.stats;
|
||||
@ -154,7 +154,7 @@ int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
case NETOPT_IPV6_ADDR: {
|
||||
assert(opt->data_len >= sizeof(ipv6_addr_t));
|
||||
ipv6_addr_t *tgt = opt->data;
|
||||
@ -233,7 +233,7 @@ int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
|
||||
res = sizeof(netopt_enable_t);
|
||||
break;
|
||||
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
||||
case NETOPT_6LO_IPHC:
|
||||
assert(opt->data_len == sizeof(netopt_enable_t));
|
||||
@ -266,7 +266,7 @@ int gnrc_netif_set_from_netdev(gnrc_netif_t *netif,
|
||||
netif->cur_hl = *((uint8_t *)opt->data);
|
||||
res = sizeof(uint8_t);
|
||||
break;
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
case NETOPT_IPV6_ADDR: {
|
||||
assert(opt->data_len == sizeof(ipv6_addr_t));
|
||||
/* always assume manually added */
|
||||
@ -335,7 +335,7 @@ int gnrc_netif_set_from_netdev(gnrc_netif_t *netif,
|
||||
res = sizeof(netopt_enable_t);
|
||||
break;
|
||||
#endif /* CONFIG_GNRC_IPV6_NIB_ROUTER */
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
||||
case NETOPT_6LO_IPHC:
|
||||
assert(opt->data_len == sizeof(netopt_enable_t));
|
||||
@ -497,7 +497,7 @@ void gnrc_netif_release(gnrc_netif_t *netif)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
static int _addr_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
|
||||
static int _group_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
|
||||
|
||||
@ -1189,7 +1189,7 @@ static ipv6_addr_t *_src_addr_selection(gnrc_netif_t *netif,
|
||||
return &netif->ipv6.addrs[idx];
|
||||
}
|
||||
}
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
|
||||
static void _update_l2addr_from_dev(gnrc_netif_t *netif)
|
||||
{
|
||||
@ -1273,7 +1273,7 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
case NETDEV_TYPE_ESP_NOW:
|
||||
assert(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR);
|
||||
assert(ETHERNET_ADDR_LEN == netif->l2addr_len);
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
switch (netif->device_type) {
|
||||
case NETDEV_TYPE_BLE:
|
||||
assert(netif->ipv6.mtu == IPV6_MIN_MTU);
|
||||
@ -1284,7 +1284,7 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
case NETDEV_TYPE_ESP_NOW:
|
||||
assert(netif->ipv6.mtu <= ETHERNET_DATA_LEN);
|
||||
}
|
||||
#endif /* MODULE GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE GNRC_NETIF_IPV6) */
|
||||
break;
|
||||
case NETDEV_TYPE_IEEE802154:
|
||||
case NETDEV_TYPE_NRFMIN: {
|
||||
@ -1295,7 +1295,7 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
assert(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR);
|
||||
assert((IEEE802154_SHORT_ADDRESS_LEN == netif->l2addr_len) ||
|
||||
(IEEE802154_LONG_ADDRESS_LEN == netif->l2addr_len));
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
#if IS_USED(MODULE_GNRC_NETIF_6LO)
|
||||
assert(netif->ipv6.mtu == IPV6_MIN_MTU);
|
||||
assert(netif->sixlo.max_frag_size > 0);
|
||||
@ -1304,7 +1304,7 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
#else /* IS_USED(MODULE_GNRC_NETIF_6LO) */
|
||||
assert(netif->ipv6.mtu < UINT16_MAX);
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_6LO) */
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN_ND
|
||||
assert((netif->device_type != NETDEV_TYPE_IEEE802154) ||
|
||||
(-ENOTSUP != netif->dev->driver->get(netif->dev,
|
||||
@ -1317,9 +1317,9 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
case NETDEV_TYPE_CC110X:
|
||||
assert(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR);
|
||||
assert(1U == netif->l2addr_len);
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
assert(netif->ipv6.mtu < UINT16_MAX);
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
break;
|
||||
case NETDEV_TYPE_LORA: /* LoRa doesn't provide L2 ADDR */
|
||||
case NETDEV_TYPE_SLIP:
|
||||
@ -1335,11 +1335,11 @@ static void _test_options(gnrc_netif_t *netif)
|
||||
}
|
||||
/* These functions only apply to network devices having link-layers */
|
||||
if (netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR) {
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
assert(-ENOTSUP != gnrc_netif_ipv6_get_iid(netif, (eui64_t *)&tmp64));
|
||||
assert(-ENOTSUP != gnrc_netif_ndp_addr_len_from_l2ao(netif,
|
||||
&dummy_opt));
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
|
||||
assert(-ENOTSUP != gnrc_netif_ipv6_iid_to_addr(netif, (eui64_t *)&tmp64,
|
||||
dummy_addr));
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <kernel_defines.h>
|
||||
|
||||
#include "log.h"
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
#include "net/ipv6.h"
|
||||
#endif
|
||||
#include "net/gnrc/netif.h"
|
||||
@ -121,10 +121,9 @@ void gnrc_netif_init_6ln(gnrc_netif_t *netif)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
#if IS_USED(MODULE_GNRC_NETIF_IPV6)
|
||||
void gnrc_netif_ipv6_init_mtu(gnrc_netif_t *netif)
|
||||
{
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
netdev_t *dev = netif->dev;
|
||||
int res;
|
||||
uint16_t tmp;
|
||||
@ -155,9 +154,7 @@ void gnrc_netif_ipv6_init_mtu(gnrc_netif_t *netif)
|
||||
* defined(MODULE_XBEE) || defined(MODULE_ESP_NOW) */
|
||||
#ifdef MODULE_NETDEV_ETH
|
||||
case NETDEV_TYPE_ETHERNET:
|
||||
#ifdef MODULE_GNRC_IPV6
|
||||
netif->ipv6.mtu = ETHERNET_DATA_LEN;
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_SIXLOENC
|
||||
netif->flags |= GNRC_NETIF_FLAGS_6LO;
|
||||
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
||||
@ -190,7 +187,6 @@ void gnrc_netif_ipv6_init_mtu(gnrc_netif_t *netif)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int gnrc_netif_ipv6_iid_from_addr(const gnrc_netif_t *netif,
|
||||
@ -206,6 +202,6 @@ int gnrc_netif_ipv6_iid_from_addr(const gnrc_netif_t *netif,
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#endif /* MODULE_GNRC_IPV6 */
|
||||
#endif /* IS_USED(MODULE_GNRC_NETIF_IPV6) */
|
||||
|
||||
/** @} */
|
||||
|
Loading…
Reference in New Issue
Block a user