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.
|
gnrc_netif_t * | gnrc_netif_create (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...
|
|
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...
|
|
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...
|
|
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...
|
|
◆ gnrc_netif_addr_from_str()
size_t gnrc_netif_addr_from_str |
( |
const char * |
str, |
|
|
uint8_t * |
out |
|
) |
| |
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.
- Precondition
(out != NULL)
-
out
MUST have allocated at least GNRC_NETIF_L2ADDR_MAXLEN bytes.
- Parameters
-
[in] | str | A string of colon-separated hexadecimals. |
[out] | out | The resulting hardware address. Must at least have GNRC_NETIF_L2ADDR_MAXLEN bytes allocated. |
- Returns
- Actual length of
out
on success.
-
0, on failure.
◆ gnrc_netif_addr_to_str()
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.
The format will be like xx:xx:xx:xx
where xx
are the bytes of addr
in hexadecimal representation.
- Precondition
(out != NULL) && ((addr != NULL) || (addr_len == 0))
-
out
MUST have allocated at least 3 * addr_len
bytes.
- Parameters
-
[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. |
- Returns
out
.
◆ gnrc_netif_create()
Creates a network interface.
- Parameters
-
[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. |
- Note
- If DEVELHELP is defined netif_params_t::name is used as the name of the network interface's thread.
- Attention
- Fails and crashes (assertion error with DEVELHELP or segmentation fault without) if
GNRC_NETIF_NUMOF
is lower than the number of calls to this function.
- Returns
- The network interface on success.
◆ gnrc_netif_default_init()
Default operation for gnrc_netif_ops_t::init()
- Note
- Can also be used to be called before a custom operation.
- Parameters
-
[in] | netif | The network interface. |
◆ gnrc_netif_get_by_pid()
Get network interface by PID.
- Parameters
-
[in] | pid | A PID of a network interface. |
- Returns
- The network interface on success.
-
NULL, if no network interface with PID exists.
◆ gnrc_netif_get_from_netdev()
◆ gnrc_netif_ipv6_addr_add()
static int gnrc_netif_ipv6_addr_add |
( |
const gnrc_netif_t * |
netif, |
|
|
ipv6_addr_t * |
addr, |
|
|
unsigned |
pfx_len, |
|
|
uint8_t |
flags |
|
) |
| |
|
inlinestatic |
Adds an (unicast or anycast) IPv6 address to an interface (if IPv6 is supported)
- Precondition
netif != NULL
-
addr != NULL
-
(pfx_len > 0) && (pfx_len <= 128)
- Parameters
-
[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). |
- Returns
- sizeof(ipv6_addr_t) on success.
-
-ENOMEM, if no space is left on
netif
to add addr
or its corresponding solicited-nodes multicast address.
-
-ENOTSUP, if
netif
doesn't support IPv6.
Definition at line 337 of file netif.h.
◆ gnrc_netif_ipv6_addr_remove()
Removes a (unicast or anycast) IPv6 address from an interface (if IPv6 is supported)
- Precondition
netif != NULL
-
addr != NULL
- Parameters
-
[in] | netif | The interface. May not be NULL . |
[in] | addr | The address to remove from netif . May not be NULL . |
- Returns
- sizeof(ipv6_addr_t) on success.
-
-ENOTSUP, if
netif
doesn't support IPv6.
Definition at line 362 of file netif.h.
◆ gnrc_netif_ipv6_addrs_get()
Gets the (unicast on anycast) IPv6 address of an interface (if IPv6 is supported)
- Precondition
netif != NULL
-
addrs != NULL
-
max_len >= sizeof(ipv6_addr_t)
- Parameters
-
[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 GNRC_NETIF_IPV6_ADDRS_NUMOF `* sizeof(ipv6_addr_t) here (and have addrs of the according length). |
- Returns
- Number of addresses in
addrs
times sizeof(ipv6_addr_t)
on success (including 0).
-
-ENOTSUP, if
netif
doesn't support IPv6.
Definition at line 306 of file netif.h.
◆ gnrc_netif_ipv6_group_join()
Joins an IPv6 multicast group on an interface (if IPv6 is supported)
- Precondition
netif != NULL
-
group != NULL
- Parameters
-
[in] | netif | The interface. |
[in] | group | The address of the multicast group to join on netif . May not be NULL . |
- Returns
- sizeof(ipv6_addr_t) on success.
-
-ENOMEM, if no space is left on
netif
to add group
.
-
-ENOTSUP, if
netif
doesn't support IPv6.
Definition at line 415 of file netif.h.
◆ gnrc_netif_ipv6_group_leave()
Leaves an IPv6 multicast group on an interface (if IPv6 is supported)
- Precondition
netif != NULL
-
group != NULL
- Parameters
-
[in] | netif | The interface. |
[in] | group | The address of the multicast group to leave on netif . May not be NULL . |
- Returns
- sizeof(ipv6_addr_t) on success.
-
-ENOTSUP, if
netif
doesn't support IPv6.
Definition at line 437 of file netif.h.
◆ gnrc_netif_ipv6_groups_get()
Gets the IPv6 multicast groups an interface is joined to (if IPv6 is supported)
- Precondition
netif != NULL
-
groups != NULL
-
max_len >= sizeof(ipv6_addr_t)
- Parameters
-
[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). |
- Returns
- Number of addresses in
groups
times sizeof(ipv6_addr_t)
on success (including 0).
-
-ENOTSUP, if
netif
doesn't support IPv6.
Definition at line 391 of file netif.h.
◆ gnrc_netif_iter()
Iterate over all network interfaces.
- Parameters
-
[in] | prev | previous interface in iteration. NULL to start iteration. |
- Returns
- The next network interface after
prev
.
-
NULL, if
prev
was the last network interface.
◆ gnrc_netif_numof()
unsigned gnrc_netif_numof |
( |
void |
| ) |
|
Get number of network interfaces actually allocated.
- Returns
- Number of network interfaces actually allocated
◆ gnrc_netif_set_from_netdev()