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 #include <string.h>
38 
39 #include "list.h"
40 #include "net/netopt.h"
41 
42 #ifdef MODULE_NETSTATS_NEIGHBOR
43 #include "cib.h"
44 #include "net/netstats.h"
45 #endif
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
59 #ifndef CONFIG_NETIF_NAMELENMAX
60 #define CONFIG_NETIF_NAMELENMAX (8U)
61 #endif
69 typedef struct {
71 #ifdef MODULE_NETSTATS_NEIGHBOR
72  netstats_nb_table_t neighbors;
73 #endif
74 } netif_t;
75 
87 netif_t *netif_iter(const netif_t *last);
88 
105 int netif_get_name(netif_t *netif, char *name);
106 
115 int16_t netif_get_id(const netif_t *netif);
116 
128 netif_t *netif_get_by_name_buffer(const char *name, size_t name_len);
129 
142 static inline netif_t *netif_get_by_name(const char *name)
143 {
144  return netif_get_by_name_buffer(name, strlen(name));
145 }
146 
156 
171 int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context,
172  void *value, size_t max_len);
173 
188 int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context,
189  void *value, size_t value_len);
190 
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* NET_NETIF_H */
Circular integer buffer interface.
int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context, void *value, size_t value_len)
Sets option to an interface.
int netif_get_name(netif_t *netif, char *name)
Gets name of an interface.
netif_t * netif_get_by_id(int16_t id)
Gets interface by a numeric identifier.
netif_t * netif_iter(const netif_t *last)
Iterator for the interfaces.
static netif_t * netif_get_by_name(const char *name)
Gets interface by name.
Definition: netif.h:142
netif_t * netif_get_by_name_buffer(const char *name, size_t name_len)
Gets interface by name, from a buffer.
int netif_register(netif_t *netif)
Registers a network interface in the global interface list.
int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context, void *value, size_t max_len)
Gets option from an interface.
int16_t netif_get_id(const netif_t *netif)
Gets the numeric identifier of an interface.
netopt_t
Global list of configuration options available throughout the network stack, e.g.
Definition: netopt.h:42
Definition of net statistics.
Intrusive linked list.
Definition of global configuration options.
List node structure.
Definition: list.h:40
Network interface descriptor.
Definition: netif.h:69
list_node_t node
Pointer to the next interface.
Definition: netif.h:70
L2 Peer Info struct.
Definition: netstats.h:104