Structure to hold driver interface -> function mapping. More...
Structure to hold driver interface -> function mapping.
The send/receive functions expect/return a full ethernet frame (dst mac, src mac, ethertype, payload, no checksum).
#include <netdev.h>
Data Fields | |
int(* | send )(netdev_t *dev, const iolist_t *iolist) |
Send frame. More... | |
int(* | recv )(netdev_t *dev, void *buf, size_t len, void *info) |
Drop a received frame, OR get the length of a received frame, OR get a received frame. More... | |
int(* | init )(netdev_t *dev) |
the driver's initialization function More... | |
void(* | isr )(netdev_t *dev) |
a driver's user-space ISR handler More... | |
int(* | get )(netdev_t *dev, netopt_t opt, void *value, size_t max_len) |
Get an option value from a given network device. More... | |
int(* | set )(netdev_t *dev, netopt_t opt, const void *value, size_t value_len) |
Set an option value for a given network device. More... | |
Get an option value from a given network device.
(dev != NULL)
max_len
must be of exactly that length (see netopt documentation for type) max_len
must greater or equal the required length (see netopt documentation for type) value
must have the natural alignment of its type (see netopt documentation for type)[in] | dev | network device descriptor |
[in] | opt | option type |
[out] | value | pointer to store the option's value in |
[in] | max_len | maximal amount of byte that fit into value |
value
-ENOTSUP | if opt is not provided by the device |
int(* netdev_driver::init) (netdev_t *dev) |
void(* netdev_driver::isr) (netdev_t *dev) |
a driver's user-space ISR handler
(dev != NULL)
This function will be called from a network stack's loop when being notified by netdev_isr.
It is supposed to call netdev->event_callback() for each occurring event.
See receive frame flow description for details.
[in] | dev | network device descriptor. Must not be NULL. |
int(* netdev_driver::recv) (netdev_t *dev, void *buf, size_t len, void *info) |
Drop a received frame, OR get the length of a received frame, OR get a received frame.
(dev != NULL)
Supposed to be called from netdev->event_callback()
If buf
== NULL and len
== 0, returns the frame size – or an upper bound estimation of the size – without dropping the frame. If buf
== NULL and len
> 0, drops the frame and returns the frame size.
If called with buf
!= NULL and len
is smaller than the received frame:
buf
becomes invalid. (The driver may use the memory to implement the dropping - or may not change it.)-ENOBUFS
is returned[in] | dev | network device descriptor. Must not be NULL. |
[out] | buf | buffer to write into or NULL to return the frame size. |
[in] | len | maximum number of bytes to read. If buf is NULL the currently buffered frame is dropped when len > 0. Must not be 0 when buf != NULL. |
[out] | info | status information for the received frame. Might be of different type for different netdev devices. May be NULL if not needed or applicable. |
-ENOBUFS | if supplied buffer is too small |
Send frame.
(dev != NULL) && (iolist != NULL)
[in] | dev | Network device descriptor. Must not be NULL. |
[in] | iolist | IO vector list to send. Elements of this list may have iolist_t::iol_data == NULL or iolist_t::iol_size == 0. However, unless otherwise specified by the device, the first element must contain data. |
Set an option value for a given network device.
(dev != NULL)
value_len
must be of exactly that length (see netopt documentation for type) value_len
must lesser or equal the required length (see netopt documentation for type) value
must have the natural alignment of its type (see netopt documentation for type)[in] | dev | network device descriptor |
[in] | opt | option type |
[in] | value | value to set |
[in] | value_len | the length of value |
value
-ENOTSUP | if opt is not configurable for the device |
-EINVAL | if value is an invalid value with regards to opt |