drivers/include/net/netdev.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2015 Ell-i open source co-operative
4  * 2015-2017 Freie Universit├Ąt Berlin
5  * 2014 Martine Lenders <mlenders@inf.fu-berlin.de>
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser General
8  * Public License v2.1. See the file LICENSE in the top level directory for
9  * more details.
10  */
11 
190 #ifndef NET_NETDEV_H
191 #define NET_NETDEV_H
192 
193 #ifdef __cplusplus
194 extern "C" {
195 #endif
196 
197 #include <stdint.h>
198 #include <sys/uio.h>
199 
200 #include "net/netopt.h"
201 
202 #ifdef MODULE_NETSTATS_L2
203 #include "net/netstats.h"
204 #endif
205 #ifdef MODULE_L2FILTER
206 #include "net/l2filter.h"
207 #endif
208 
209 enum {
210  NETDEV_TYPE_UNKNOWN,
211  NETDEV_TYPE_RAW,
212  NETDEV_TYPE_ETHERNET,
213  NETDEV_TYPE_IEEE802154,
214  NETDEV_TYPE_CC110X,
215  NETDEV_TYPE_NRFMIN
216 };
217 
222 typedef enum {
233  /* expand this list if needed */
235 
242  uint8_t rssi;
243  uint8_t lqi;
244 };
245 
249 typedef struct netdev netdev_t;
250 
256 typedef void (*netdev_event_cb_t)(netdev_t *dev, netdev_event_t event);
257 
267 struct netdev {
268  const struct netdev_driver *driver;
270  void* context;
271 #ifdef MODULE_NETSTATS_L2
272  netstats_t stats;
273 #endif
274 #ifdef MODULE_L2FILTER
275  l2filter_t filter[L2FILTER_LISTSIZE];
276 #endif
277 };
278 
285 typedef struct netdev_driver {
299  int (*send)(netdev_t *dev, const struct iovec *vector, unsigned count);
300 
324  int (*recv)(netdev_t *dev, void *buf, size_t len, void *info);
325 
333  int (*init)(netdev_t *dev);
334 
351  void (*isr)(netdev_t *dev);
352 
366  int (*get)(netdev_t *dev, netopt_t opt,
367  void *value, size_t max_len);
368 
382  int (*set)(netdev_t *dev, netopt_t opt,
383  void *value, size_t value_len);
385 
386 #ifdef __cplusplus
387 }
388 #endif
389 
390 #endif /* NET_NETDEV_H */
Definition of net statistics.
Structure to hold driver interface -> function mapping.
driver needs it&#39;s ISR handled
#define L2FILTER_LISTSIZE
Number of slots in each filter list (filter entries per device)
Definition: l2filter.h:54
static ssize_t recv(int socket, void *buffer, size_t length, int flags)
Receive a message from a connected socket.
Definition: socket.h:380
Link layer address filter interface definition.
netdev_event_t
Possible event types that are send from the device driver to the upper layer.
uint8_t rssi
RSSI of a received packet.
Global statistics struct.
started to transfer a packet
Received packet status information for most radios.
void * context
ptr to network stack context
started to receive a packet
ACK requested but not received.
Filter list entries.
Definition: l2filter.h:64
netopt_t
Global list of configuration options available throughout the network stack, e.g. ...
Definition: netopt.h:36
void(* netdev_event_cb_t)(netdev_t *dev, netdev_event_t event)
Event callback for signaling event to upper layers.
Structure to hold driver state.
Structure for scatter/gather I/O.
Definition: uio.h:33
netdev_event_cb_t event_callback
callback for device events
Definition of global configuration options.
transfer packet complete and data pending flag
couldn&#39;t transfer packet
struct netdev_driver netdev_driver_t
Structure to hold driver interface -> function mapping.
static ssize_t send(int socket, const void *buffer, size_t length, int flags)
Send a message on a socket.
Definition: socket.h:450
finished receiving a packet
uint8_t lqi
LQI of a received packet.
libc header for scatter/gather I/O
const struct netdev_driver * driver
ptr to that driver&#39;s interface.