The friendly Operating System for the Internet of Things
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 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 
46 #ifndef NETDEV_H
47 #define NETDEV_H
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #include <stdint.h>
54 #include <sys/uio.h>
55 
56 #include "net/netstats.h"
57 #include "net/netopt.h"
58 
59 enum {
60  NETDEV_TYPE_UNKNOWN,
61  NETDEV_TYPE_RAW,
62  NETDEV_TYPE_ETHERNET,
63  NETDEV_TYPE_IEEE802154,
64  NETDEV_TYPE_CC110X,
65  NETDEV_TYPE_NRFMIN
66 };
67 
72 typedef enum {
82  /* expand this list if needed */
84 
91  uint8_t rssi;
92  uint8_t lqi;
93 };
94 
98 typedef struct netdev netdev_t;
99 
105 typedef void (*netdev_event_cb_t)(netdev_t *dev, netdev_event_t event);
106 
116 struct netdev {
117  const struct netdev_driver *driver;
119  void* context;
120 #ifdef MODULE_NETSTATS_L2
121  netstats_t stats;
122 #endif
123 };
124 
131 typedef struct netdev_driver {
145  int (*send)(netdev_t *dev, const struct iovec *vector, unsigned count);
146 
169  int (*recv)(netdev_t *dev, void *buf, size_t len, void *info);
170 
178  int (*init)(netdev_t *dev);
179 
194  void (*isr)(netdev_t *dev);
195 
209  int (*get)(netdev_t *dev, netopt_t opt,
210  void *value, size_t max_len);
211 
225  int (*set)(netdev_t *dev, netopt_t opt,
226  void *value, size_t value_len);
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /* NETDEV_H */
Definition of net statistics.
int(* send)(netdev_t *dev, const struct iovec *vector, unsigned count)
Send frame.
Structure to hold driver interface -> function mapping.
driver needs it's ISR handled
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
int(* init)(netdev_t *dev)
the driver's initialization function
started to receive a packet
ACK requested but not received.
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.
void(* isr)(netdev_t *dev)
a driver's user-space ISR handler
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.
struct netdev_driver netdev_driver_t
Structure to hold driver interface -> function mapping.
finished receiving a packet
uint8_t lqi
LQI of a received packet.
libc header for scatter/gather I/O
finished transferring packet
const struct netdev_driver * driver
ptr to that driver's interface.
int(* set)(netdev_t *dev, netopt_t opt, void *value, size_t value_len)
Set an option value for a given network device.
int(* recv)(netdev_t *dev, void *buf, size_t len, void *info)
Get a received frame.