netif.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
24 #ifndef NET_GNRC_NETIF_H
25 #define NET_GNRC_NETIF_H
26 
27 #include <stddef.h>
28 #include <stdint.h>
29 #include <stdbool.h>
30 
31 #include "kernel_types.h"
32 #include "msg.h"
33 #include "net/gnrc/netapi.h"
34 #include "net/gnrc/pkt.h"
35 #include "net/gnrc/netif/conf.h"
36 #ifdef MODULE_GNRC_SIXLOWPAN
37 #include "net/gnrc/netif/6lo.h"
38 #endif
39 #include "net/gnrc/netif/flags.h"
40 #ifdef MODULE_GNRC_IPV6
41 #include "net/gnrc/netif/ipv6.h"
42 #endif
43 #ifdef MODULE_GNRC_MAC
44 #include "net/gnrc/netif/mac.h"
45 #endif
46 #include "net/netdev.h"
47 #include "rmutex.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
57 
61 typedef struct {
65 #if defined(MODULE_GNRC_IPV6) || DOXYGEN
67 #endif
68 #if defined(MODULE_GNRC_MAC) || DOXYGEN
70 #endif /* MODULE_GNRC_MAC */
71 
76  uint32_t flags;
77 #if (GNRC_NETIF_L2ADDR_MAXLEN > 0)
78 
84  uint8_t l2addr[GNRC_NETIF_L2ADDR_MAXLEN];
85 
91  uint8_t l2addr_len;
92 #endif
93 #if defined(MODULE_GNRC_SIXLOWPAN) || DOXYGEN
95 #endif
96  uint8_t cur_hl;
97  uint8_t device_type;
99 } gnrc_netif_t;
100 
117  void (*init)(gnrc_netif_t *netif);
118 
139  int (*send)(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt);
140 
157  gnrc_pktsnip_t *(*recv)(gnrc_netif_t *netif);
158 
173  int (*get)(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt);
174 
190  int (*set)(gnrc_netif_t *netif, const gnrc_netapi_opt_t *opt);
191 
202  void (*msg_handler)(gnrc_netif_t *netif, msg_t *msg);
203 };
204 
224 gnrc_netif_t *gnrc_netif_create(char *stack, int stacksize, char priority,
225  const char *name, netdev_t *dev,
226  const gnrc_netif_ops_t *ops);
227 
233 unsigned gnrc_netif_numof(void);
234 
244 
254 
267 
280  const gnrc_netapi_opt_t *opt);
281 
298 char *gnrc_netif_addr_to_str(const uint8_t *addr, size_t addr_len, char *out);
299 
318 size_t gnrc_netif_addr_from_str(const char *str, uint8_t *out);
319 
320 #ifdef __cplusplus
321 }
322 #endif
323 
324 #endif /* NET_GNRC_NETIF_H */
325 
Types used by the kernel.
Definitions low-level network driver interface.
uint8_t cur_hl
Current hop-limit for out-going packets.
Definition: netif.h:96
void(* msg_handler)(gnrc_netif_t *netif, msg_t *msg)
Message handler for network interface.
Definition: netif.h:202
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.
6Lo component of gnrc_netif_t
Definition: 6lo.h:30
size_t gnrc_netif_addr_from_str(const char *str, uint8_t *out)
Parses a string of colon-separated hexadecimals to a hardware address.
uint32_t flags
Flags for the interface.
Definition: netif.h:76
int(* send)(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Send a packet over the network interface.
Definition: netif.h:139
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
General definitions for network packets and their helper functions.
int gnrc_netif_set_from_netdev(gnrc_netif_t *netif, const gnrc_netapi_opt_t *opt)
Default operation for gnrc_netif_ops_t::set()
Data structure to be send for setting (GNRC_NETAPI_MSG_TYPE_SET) and getting (GNRC_NETAPI_MSG_TYPE_GE...
Definition: netapi.h:99
6LoWPAN definitions for New network interface API
Configuration macros for New network interface API.
Common MAC module definitions for New network interface API
Generic interface to communicate with GNRC modules.
const gnrc_netif_ops_t * ops
Operations of the network interface.
Definition: netif.h:62
Mutex structure.
Definition: rmutex.h:36
IPv6 defintions for New network interface API.
uint8_t device_type
Device type.
Definition: netif.h:97
Common MAC module component of gnrc_netif_mac_t
Definition: netif/mac.h:72
int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
Default operation for gnrc_netif_ops_t::get()
gnrc_netif_6lo_t sixlo
6Lo component
Definition: netif.h:94
netdev_t * dev
Network device of the network interface.
Definition: netif.h:63
IPv6 component for gnrc_netif_t.
Messaging API for inter process communication.
#define GNRC_NETIF_L2ADDR_MAXLEN
Maximum length of the link-layer address.
Definition: netif/conf.h:113
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: netif.h:66
void(* init)(gnrc_netif_t *netif)
Initializes network interface beyond the default settings.
Definition: netif.h:117
rmutex_t mutex
Mutex of the interface.
Definition: netif.h:64
Structure to hold driver state.
Definition: netdev.h:274
Describes a message object which can be sent between threads.
Definition: msg.h:184
Recursive Mutex for thread synchronization.
unsigned gnrc_netif_numof(void)
Get number of network interfaces actually allocated.
kernel_pid_t pid
PID of the network interface&#39;s thread.
Definition: netif.h:98
Representation of a network interface.
Definition: netif.h:61
gnrc_netif_t * gnrc_netif_get_by_pid(kernel_pid_t pid)
Get network interface by PID.
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.
gnrc_netif_mac_t mac
Common MAC module component
Definition: netif.h:69
Type to represent parts (either headers or payload) of a packet, called snips.
Flag definitions for New network interface API.
gnrc_netif_t * gnrc_netif_iter(const gnrc_netif_t *prev)
Iterate over all network interfaces.