29#ifndef NET_GNRC_NETIF_H
30#define NET_GNRC_NETIF_H
38#ifdef MODULE_GNRC_NETIF_BUS
46#if IS_USED(MODULE_GNRC_NETIF_LORAWAN)
49#if IS_USED(MODULE_GNRC_NETIF_6LO)
52#if defined(MODULE_GNRC_NETIF_DEDUP) && (GNRC_NETIF_L2ADDR_MAXLEN > 0)
56#if IS_USED(MODULE_GNRC_NETIF_IPV6)
59#if IS_USED(MODULE_GNRC_NETIF_MAC)
62#if IS_USED(MODULE_GNRC_NETIF_PKTQ)
69#ifdef MODULE_NETSTATS_L2
82#define GNRC_NETIF_EVQ_INDEX_PRIO_HIGH (0)
87#if IS_USED(MODULE_BHP_EVENT)
88#define GNRC_NETIF_EVQ_INDEX_PRIO_LOW (GNRC_NETIF_EVQ_INDEX_PRIO_HIGH + 1)
90#define GNRC_NETIF_EVQ_INDEX_PRIO_LOW GNRC_NETIF_EVQ_INDEX_PRIO_HIGH
96#define GNRC_NETIF_EVQ_NUMOF (GNRC_NETIF_EVQ_INDEX_PRIO_LOW + 1)
102#ifdef MODULE_GNRC_IPV6
140#if IS_USED(MODULE_NETSTATS_L2) || defined(DOXYGEN)
143#if IS_USED(MODULE_GNRC_NETIF_LORAWAN) || defined(DOXYGEN)
146#if IS_USED(MODULE_GNRC_NETIF_IPV6) || defined(DOXYGEN)
149#if IS_USED(MODULE_GNRC_NETIF_MAC) || defined(DOXYGEN)
152#if IS_USED(MODULE_GNRC_NETIF_BUS) || DOXYGEN
169#if IS_USED(MODULE_NETDEV_NEW_API) || defined(DOXYGEN)
185#if (GNRC_NETIF_L2ADDR_MAXLEN > 0) || DOXYGEN
200#if defined(MODULE_GNRC_NETIF_DEDUP) || DOXYGEN
209#if IS_USED(MODULE_GNRC_NETIF_6LO) || defined(DOXYGEN)
212#if IS_USED(MODULE_GNRC_NETIF_PKTQ) || defined(DOXYGEN)
246 if (!
IS_USED(MODULE_NETDEV_NEW_API) && !
IS_USED(MODULE_NETDEV_LEGACY_API)) {
253 if (!
IS_USED(MODULE_NETDEV_NEW_API)) {
257 if (!
IS_USED(MODULE_NETDEV_LEGACY_API)) {
419 char priority,
const char *name,
netdev_t *dev,
442 return IS_USED(MODULE_GNRC_NETIF_SINGLE);
523 assert((pfx_len > 0) && (pfx_len <= 128));
525 ((pfx_len << 8U) | flags), addr,
738#if defined(MODULE_GNRC_NETIF_BUS) || DOXYGEN
750 assert(type < GNRC_NETIF_BUS_NUMOF);
751 return &netif->
bus[type];
769 uint32_t timeout_ms);
6LoWPAN definitions for Network interface API
#define assert(cond)
abort the program if assertion is false
Definitions low-level network driver interface.
Flag definitions for Network interface API.
IPv6 definitions for Network interface API.
int16_t kernel_pid_t
Unique process identifier.
netdev_type_t
Driver types for netdev.
static int gnrc_netapi_set(kernel_pid_t pid, netopt_t opt, uint16_t context, const void *data, size_t data_len)
Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SET messages and parsing the returned GNRC_NETAPI_...
static int gnrc_netapi_get(kernel_pid_t pid, netopt_t opt, uint16_t context, void *data, size_t max_len)
Shortcut function for sending GNRC_NETAPI_MSG_TYPE_GET messages and parsing the returned GNRC_NETAPI_...
static int gnrc_netapi_send(kernel_pid_t pid, gnrc_pktsnip_t *pkt)
Shortcut function for sending GNRC_NETAPI_MSG_TYPE_SND messages.
#define GNRC_NETIF_L2ADDR_MAXLEN
Maximum length of the link-layer address.
static int gnrc_netif_ipv6_addrs_get(const gnrc_netif_t *netif, ipv6_addr_t *addrs, size_t max_len)
Gets the (unicast on anycast) IPv6 address of an interface (if IPv6 is supported)
static bool gnrc_netif_netdev_new_api(gnrc_netif_t *netif)
Check if the device belonging to the given netif uses the new netdev API.
static int gnrc_netif_ipv6_group_leave(const gnrc_netif_t *netif, const ipv6_addr_t *group)
Leaves an IPv6 multicast group on an interface (if IPv6 is supported)
static size_t gnrc_netif_addr_from_str(const char *str, uint8_t *out)
Parses a string of colon-separated hexadecimals to a hardware address.
static int gnrc_netif_ipv6_group_join(const gnrc_netif_t *netif, const ipv6_addr_t *group)
Joins an IPv6 multicast group on an interface (if IPv6 is supported)
gnrc_netif_t * gnrc_netif_get_by_type(netdev_type_t type, uint8_t index)
Gets an interface by the netdev type (and index)
gnrc_ipv6_event_t
Event types for GNRC_NETIF_BUS_IPV6 per-interface message bus.
#define GNRC_NETIF_EVQ_NUMOF
Number of event queues.
static bool gnrc_netif_netdev_legacy_api(gnrc_netif_t *netif)
Check if the device belonging to the given netif uses the legacy netdev API.
gnrc_netif_t * gnrc_netif_iter(const gnrc_netif_t *prev)
Iterate over all network interfaces.
int gnrc_netif_set_from_netdev(gnrc_netif_t *netif, const gnrc_netapi_opt_t *opt)
Default operation for gnrc_netif_ops_t::set()
static char * gnrc_netif_addr_to_str(const uint8_t *addr, size_t addr_len, char *out)
Converts a hardware address to a human readable string.
static int gnrc_netif_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Send a GNRC packet via a given gnrc_netif_t interface.
int gnrc_netif_default_init(gnrc_netif_t *netif)
Default operation for gnrc_netif_ops_t::init()
static int gnrc_netif_ipv6_addr_add(const gnrc_netif_t *netif, const ipv6_addr_t *addr, unsigned pfx_len, uint8_t flags)
Adds an (unicast or anycast) IPv6 address to an interface (if IPv6 is supported)
unsigned gnrc_netif_numof(void)
Get number of network interfaces actually allocated.
bool gnrc_netif_ipv6_wait_for_global_address(gnrc_netif_t *netif, uint32_t timeout_ms)
Wait for a global address to become available.
int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority, const char *name, netdev_t *dev, const gnrc_netif_ops_t *ops)
Creates a network interface.
gnrc_netif_bus_t
Per-Interface Event Message Buses.
gnrc_netif_t * gnrc_netif_get_by_pid(kernel_pid_t pid)
Get network interface by PID.
static msg_bus_t * gnrc_netif_get_bus(gnrc_netif_t *netif, gnrc_netif_bus_t type)
Get a message bus of a given gnrc_netif_t interface.
int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
Default operation for gnrc_netif_ops_t::get()
static int gnrc_netif_ipv6_groups_get(const gnrc_netif_t *netif, ipv6_addr_t *groups, size_t max_len)
Gets the IPv6 multicast groups an interface is joined to (if IPv6 is supported)
static int gnrc_netif_ipv6_addr_remove(const gnrc_netif_t *netif, const ipv6_addr_t *addr)
Removes a (unicast or anycast) IPv6 address from an interface (if IPv6 is supported)
static bool gnrc_netif_highlander(void)
Check if there can only be one gnrc_netif_t interface.
void gnrc_netif_init_devs(void)
Initialize all available network interfaces.
@ GNRC_IPV6_EVENT_ADDR_VALID
Address becomes valid.
@ GNRC_NETIF_BUS_IPV6
provides gnrc_ipv6_event_t messages to subscribers
size_t l2util_addr_from_str(const char *str, uint8_t *out)
Parses a string of colon-separated hexadecimals to a hardware address.
char * l2util_addr_to_str(const uint8_t *addr, size_t addr_len, char *out)
Converts a hardware address to a human readable string.
@ NETOPT_IPV6_GROUP
(ipv6_addr_t) get IPv6 multicast groups of an interface as array of ipv6_addr_t or join an IPv6 multi...
@ NETOPT_IPV6_GROUP_LEAVE
(ipv6_addr_t) Leave an IPv6 multicast group on an interface
@ NETOPT_IPV6_ADDR
(ipv6_addr_t[]) get IPv6 addresses of an interface as array of ipv6_addr_t or add an IPv6 address as ...
@ NETOPT_IPV6_ADDR_REMOVE
(ipv6_addr_t) Removes an IPv6 address from an interface
Definition of net statistics.
Definitions for IPv6 addresses.
Link-layer helper function definitions.
#define IS_USED(module)
Checks whether a module is being used or not.
Messaging Bus API for inter process message broadcast.
IPv6 neighbor discovery message type definitions.
General definitions for network packets and their helper functions.
Generic interface to communicate with GNRC modules.
Configuration macros for Network interface API.
#define GNRC_NETIF_MSG_QUEUE_SIZE
Message queue size for network interface threads.
LoRaWAN adaption for Network interface API.
Common MAC module definitions for Network interface API
Common network interface API definitions.
Definition of global configuration options.
Recursive Mutex for thread synchronization.
Scheduler API definition.
Data structure to be send for setting (GNRC_NETAPI_MSG_TYPE_SET) and getting (GNRC_NETAPI_MSG_TYPE_GE...
6Lo component of gnrc_netif_t
Structure to store information on the last broadcast packet received.
IPv6 component for gnrc_netif_t.
GNRC LoRaWAN interface descriptor.
Common MAC module component of gnrc_netif_mac_t
int(* init)(gnrc_netif_t *netif)
Initializes and registers network interface.
int(* set)(gnrc_netif_t *netif, const gnrc_netapi_opt_t *opt)
Sets an option from the network interface.
int(* send)(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Send a packet over the network interface.
void(* msg_handler)(gnrc_netif_t *netif, msg_t *msg)
Message handler for network interface.
int(* get)(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
Gets an option from the network interface.
A packet queue for Network interface API with a de-queue timer.
Representation of a network interface.
gnrc_netif_lorawan_t lorawan
LoRaWAN component.
msg_bus_t bus[GNRC_NETIF_BUS_NUMOF]
Event Message Bus.
rmutex_t mutex
Mutex of the interface.
netstats_t stats
transceiver's statistics
uint32_t flags
Flags for the interface.
const gnrc_netif_ops_t * ops
Operations of the network interface.
uint8_t device_type
Device type.
gnrc_netif_6lo_t sixlo
6Lo component
uint8_t cur_hl
Current hop-limit for out-going packets.
netif_t netif
network interface descriptor
uint8_t l2addr_len
Length in bytes of gnrc_netif_t::l2addr.
kernel_pid_t pid
PID of the network interface's thread.
event_t event_isr
ISR event for the network device.
gnrc_netif_mac_t mac
Common MAC module component
gnrc_netif_dedup_t last_pkt
Last received packet information.
gnrc_netif_ipv6_t ipv6
IPv6 component.
netdev_t * dev
Network device of the network interface.
gnrc_pktsnip_t * tx_pkt
Outgoing frame that is currently transmitted.
event_t event_tx_done
TX done event for the network device.
gnrc_netif_pktq_t send_queue
Packet queue for sending.
Type to represent parts (either headers or payload) of a packet, called snips.
A message bus is just a list of subscribers.
Describes a message object which can be sent between threads.
int(* confirm_send)(netdev_t *dev, void *info)
Fetch the status of a transmission and perform any potential cleanup.
Structure to hold driver state.
const struct netdev_driver * driver
ptr to that driver's interface.
Network interface descriptor.
Global statistics struct.
Send queue for Network interface API type definitions
Data type to represent an IPv6 address.