Abstraction layer for GNRC's network interfaces. More...
Abstraction layer for GNRC's network interfaces.
Network interfaces in the context of GNRC are threads for protocols that are below the network layer.
If you only have one network interface on the board, you can select the gnrc_netif_single
pseudo-module to enable further optimisations.
Modules | |
CC1100/CC1100e/CC1101/CC1200 common code | |
GNRC network interface configurations | |
Generic network interface header | |
Link-layer Broadcast deduplication | |
Deduplicates broadcast link-layer packets best-effort style. | |
Send queue for @ref net_gnrc_netif | |
Files | |
file | gnrc_netif_xbee.h |
XBee adaption for Network interface API. | |
file | 6lo.h |
6LoWPAN definitions for Network interface API | |
file | ethernet.h |
Ethernet adaption for Network interface API. | |
file | flags.h |
Flag definitions for Network interface API. | |
file | ieee802154.h |
IEEE 802.15.4 adaption for Network interface API. | |
file | ipv6.h |
IPv6 definitions for Network interface API. | |
file | lorawan.h |
LoRaWAN adaption for Network interface API. | |
file | lorawan_base.h |
LoRaWAN base Network interface API header. | |
file | mac.h |
Common MAC module definitions for Network interface API | |
file | raw.h |
Raw (i.e. raw IP packets without link-layer information) adaptation for Network interface API. | |
file | netif.h |
Definition for GNRC's network interfaces. | |
Data Structures | |
struct | gnrc_netif_t |
Representation of a network interface. More... | |
struct | gnrc_netif_ops |
Typedefs | |
typedef struct gnrc_netif_ops | gnrc_netif_ops_t |
Operations to an interface. | |
Enumerations | |
enum | gnrc_netif_bus_t { GNRC_NETIF_BUS_IPV6, GNRC_NETIF_BUS_NUMOF } |
Per-Interface Event Message Buses. More... | |
enum | gnrc_ipv6_event_t { GNRC_IPV6_EVENT_ADDR_VALID } |
Event types for GNRC_NETIF_BUS_IPV6 per-interface message bus. More... | |
Functions | |
void | gnrc_netif_init_devs (void) |
Initialize all available network interfaces. More... | |
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. More... | |
unsigned | gnrc_netif_numof (void) |
Get number of network interfaces actually allocated. More... | |
static bool | gnrc_netif_highlander (void) |
Check if there can only be one gnrc_netif_t interface. More... | |
gnrc_netif_t * | gnrc_netif_iter (const gnrc_netif_t *prev) |
Iterate over all network interfaces. More... | |
gnrc_netif_t * | gnrc_netif_get_by_pid (kernel_pid_t pid) |
Get network interface by PID. More... | |
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) More... | |
static int | gnrc_netif_ipv6_addr_add (const gnrc_netif_t *netif, ipv6_addr_t *addr, unsigned pfx_len, uint8_t flags) |
Adds an (unicast or anycast) IPv6 address to an interface (if IPv6 is supported) More... | |
static int | gnrc_netif_ipv6_addr_remove (const gnrc_netif_t *netif, ipv6_addr_t *addr) |
Removes a (unicast or anycast) IPv6 address from an interface (if IPv6 is supported) More... | |
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) More... | |
static int | gnrc_netif_ipv6_group_join (const gnrc_netif_t *netif, ipv6_addr_t *group) |
Joins an IPv6 multicast group on an interface (if IPv6 is supported) More... | |
static int | gnrc_netif_ipv6_group_leave (const gnrc_netif_t *netif, ipv6_addr_t *group) |
Leaves an IPv6 multicast group on an interface (if IPv6 is supported) More... | |
void | gnrc_netif_default_init (gnrc_netif_t *netif) |
Default operation for gnrc_netif_ops_t::init() More... | |
int | gnrc_netif_get_from_netdev (gnrc_netif_t *netif, gnrc_netapi_opt_t *opt) |
Default operation for gnrc_netif_ops_t::get() More... | |
int | gnrc_netif_set_from_netdev (gnrc_netif_t *netif, const gnrc_netapi_opt_t *opt) |
Default operation for gnrc_netif_ops_t::set() More... | |
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. More... | |
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. More... | |
static int | gnrc_netif_send (gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) |
Send a GNRC packet via a given gnrc_netif_t interface. More... | |
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. More... | |
enum gnrc_ipv6_event_t |
Event types for GNRC_NETIF_BUS_IPV6 per-interface message bus.
Enumerator | |
---|---|
GNRC_IPV6_EVENT_ADDR_VALID | Address becomes valid. The event is generated when an address on the interface becomes valid. The message payload contains a pointer to the respective ipv6_addr_t struct.
|
enum gnrc_netif_bus_t |
Per-Interface Event Message Buses.
Enumerator | |
---|---|
GNRC_NETIF_BUS_IPV6 | provides gnrc_ipv6_event_t messages to subscribers |
|
inlinestatic |
Parses a string of colon-separated hexadecimals to a hardware address.
The input format must be like xx:xx:xx:xx
where xx
will be the bytes of addr
in hexadecimal representation.
(out != NULL)
out
MUST have allocated at least GNRC_NETIF_L2ADDR_MAXLEN bytes.[in] | str | A string of colon-separated hexadecimals. |
[out] | out | The resulting hardware address. Must at least have GNRC_NETIF_L2ADDR_MAXLEN bytes allocated. |
out
on success.
|
inlinestatic |
Converts a hardware address to a human readable string.
The format will be like xx:xx:xx:xx
where xx
are the bytes of addr
in hexadecimal representation.
(out != NULL) && ((addr != NULL) || (addr_len == 0))
out
MUST have allocated at least 3 * addr_len
bytes.[in] | addr | A hardware address. |
[in] | addr_len | Length of addr . |
[out] | out | A string to store the output in. Must at least have 3 * addr_len bytes allocated. |
out
. 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.
[out] | netif | The interface. May not be NULL . |
[in] | stack | The stack for the network interface's thread. |
[in] | stacksize | Size of stack . |
[in] | priority | Priority for the network interface's thread. |
[in] | name | Name for the network interface. May be NULL. |
[in] | dev | Device for the interface. |
[in] | ops | Operations for the network interface. |
void gnrc_netif_default_init | ( | gnrc_netif_t * | netif | ) |
Default operation for gnrc_netif_ops_t::init()
[in] | netif | The network interface. |
|
inlinestatic |
Get a message bus of a given gnrc_netif_t interface.
netif | pointer to the interface |
type | GNRC message bus type |
gnrc_netif_t* gnrc_netif_get_by_pid | ( | kernel_pid_t | pid | ) |
Get network interface by PID.
[in] | pid | A PID of a network interface. |
int gnrc_netif_get_from_netdev | ( | gnrc_netif_t * | netif, |
gnrc_netapi_opt_t * | opt | ||
) |
Default operation for gnrc_netif_ops_t::get()
[in] | netif | The network interface. |
[out] | opt | The option parameters. |
netif
.
|
inlinestatic |
Check if there can only be one gnrc_netif_t interface.
There can only be one!
This function is used to allow compile time optimizations for single interface applications
void gnrc_netif_init_devs | ( | void | ) |
Initialize all available network interfaces.
This function is called automatically if the auto_init_gnrc_netif module is used. If only the gnrc_netif_init module is used instead, you can call this function to manually set up the network interfaces at a later time.
|
inlinestatic |
Adds an (unicast or anycast) IPv6 address to an interface (if IPv6 is supported)
netif != NULL
addr != NULL
(pfx_len > 0) && (pfx_len <= 128)
[in] | netif | The interface. May not be NULL . |
[in] | addr | The address to add to netif . May not be NULL . |
[in] | pfx_len | The prefix length of addr . Must be greater than 0 and lesser than or equal to 128. |
[in] | flags | Flags for addr . Set GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID to skip duplicate address detection (when activated). |
netif
to add addr
or its corresponding solicited-nodes multicast address. netif
doesn't support IPv6.
|
inlinestatic |
Removes a (unicast or anycast) IPv6 address from an interface (if IPv6 is supported)
netif != NULL
addr != NULL
[in] | netif | The interface. May not be NULL . |
[in] | addr | The address to remove from netif . May not be NULL . |
netif
doesn't support IPv6.
|
inlinestatic |
Gets the (unicast on anycast) IPv6 address of an interface (if IPv6 is supported)
netif != NULL
addrs != NULL
max_len >= sizeof(ipv6_addr_t)
[in] | netif | The interface. May not be NULL . |
[out] | addrs | Up to the first max_len / sizeof(ipv6_addr_t) addresses assigned to netif . May not be NULL |
[in] | max_len | Number of bytes available in addrs . Must be at least sizeof(ipv6_addr_t) . It is recommended to use CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF `* sizeof(ipv6_addr_t) here (and have addrs of the according length). |
addrs
times sizeof(ipv6_addr_t)
on success (including 0). netif
doesn't support IPv6.
|
inlinestatic |
Joins an IPv6 multicast group on an interface (if IPv6 is supported)
netif != NULL
group != NULL
[in] | netif | The interface. |
[in] | group | The address of the multicast group to join on netif . May not be NULL . |
netif
to add group
. netif
doesn't support IPv6.
|
inlinestatic |
Leaves an IPv6 multicast group on an interface (if IPv6 is supported)
netif != NULL
group != NULL
[in] | netif | The interface. |
[in] | group | The address of the multicast group to leave on netif . May not be NULL . |
netif
doesn't support IPv6.
|
inlinestatic |
Gets the IPv6 multicast groups an interface is joined to (if IPv6 is supported)
netif != NULL
groups != NULL
max_len >= sizeof(ipv6_addr_t)
[in] | netif | The interface. May not be NULL . |
[out] | groups | Up to the first max_len / 8 multicast groups netif is joined to. May not be NULL |
[in] | max_len | Number of bytes available in groups . Must be at least sizeof(ipv6_addr_t) . It is recommended to use GNRC_NETIF_IPV6_GROUPS_NUMOF `* sizeof(ipv6_addr_t) here (and have groups of the according length). |
groups
times sizeof(ipv6_addr_t)
on success (including 0). netif
doesn't support IPv6. gnrc_netif_t* gnrc_netif_iter | ( | const gnrc_netif_t * | prev | ) |
Iterate over all network interfaces.
[in] | prev | previous interface in iteration. NULL to start iteration. |
prev
. prev
was the last network interface. unsigned gnrc_netif_numof | ( | void | ) |
Get number of network interfaces actually allocated.
|
inlinestatic |
Send a GNRC packet via a given gnrc_netif_t interface.
netif | pointer to the interface |
pkt | packet to be sent. |
int gnrc_netif_set_from_netdev | ( | gnrc_netif_t * | netif, |
const gnrc_netapi_opt_t * | opt | ||
) |
Default operation for gnrc_netif_ops_t::set()
[in] | netif | The network interface. |
[in] | opt | The option parameters. |
netif
.