netif.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
3  * Copyright (C) 2017 Freie Universität Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
33 #ifndef NET_NETIF_H
34 #define NET_NETIF_H
35 
36 #include <stdint.h>
37 
38 #include "list.h"
39 #include "net/netopt.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
53 #ifndef CONFIG_NETIF_NAMELENMAX
54 #define CONFIG_NETIF_NAMELENMAX (8U)
55 #endif
56 
63 typedef struct {
65 } netif_t;
66 
78 netif_t *netif_iter(netif_t *last);
79 
96 int netif_get_name(netif_t *netif, char *name);
97 
106 int16_t netif_get_id(const netif_t *netif);
107 
120 netif_t *netif_get_by_name(const char *name);
121 
130 netif_t *netif_get_by_id(int16_t id);
131 
146 int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context,
147  void *value, size_t max_len);
148 
163 int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context,
164  void *value, size_t value_len);
165 
166 
177 int netif_register(netif_t *netif);
178 
195 char *netif_addr_to_str(const uint8_t *addr, size_t addr_len, char *out);
196 
215 size_t netif_addr_from_str(const char *str, uint8_t *out);
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* NET_NETIF_H */
222 
netopt_t
netopt_t
Global list of configuration options available throughout the network stack, e.g.
Definition: netopt.h:50
netif_t
Network interface descriptor.
Definition: netif.h:63
netif_addr_from_str
size_t netif_addr_from_str(const char *str, uint8_t *out)
Parses a string of colon-separated hexadecimals to a hardware address.
netopt.h
Definition of global configuration options.
netif_set_opt
int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context, void *value, size_t value_len)
Sets option to an interface.
netif_get_opt
int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context, void *value, size_t max_len)
Gets option from an interface.
netif_get_name
int netif_get_name(netif_t *netif, char *name)
Gets name of an interface.
netif_get_id
int16_t netif_get_id(const netif_t *netif)
Gets the numeric identifier of an interface.
netif_get_by_id
netif_t * netif_get_by_id(int16_t id)
Gets interface by a numeric identifier.
netif_get_by_name
netif_t * netif_get_by_name(const char *name)
Gets interface by name.
netif_iter
netif_t * netif_iter(netif_t *last)
Iterator for the interfaces.
netif_t::node
list_node_t node
Pointer to the next interface.
Definition: netif.h:64
netif_register
int netif_register(netif_t *netif)
Registers a network interface in the global interface list.
list_node
List node structure.
Definition: list.h:40
list.h
Intrusive linked list.
netif_addr_to_str
char * netif_addr_to_str(const uint8_t *addr, size_t addr_len, char *out)
Converts a hardware address to a human readable string.