Structure to hold driver interface -> function mapping. More...

Detailed Description

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).

Definition at line 298 of file netdev.h.

#include <net/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)
 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...
 

Field Documentation

◆ get

int(* netdev_driver::get) (netdev_t *dev, netopt_t opt, void *value, size_t max_len)

Get an option value from a given network device.

Precondition
(dev != NULL)
for scalar types of netopt_t max_len must be of exactly that length (see netopt documentation for type)
for array types of netopt_t max_len must greater or equal the required length (see netopt documentation for type)
Parameters
[in]devnetwork device descriptor
[in]optoption type
[out]valuepointer to store the option's value in
[in]max_lenmaximal amount of byte that fit into value
Returns
number of bytes written to value
-ENOTSUP if opt is not provided by the device

Definition at line 390 of file netdev.h.

◆ init

int(* netdev_driver::init) (netdev_t *dev)

the driver's initialization function

Precondition
(dev != NULL)
Parameters
[in]devnetwork device descriptor. Must not be NULL.
Returns
< 0 on error
0 on success

Definition at line 352 of file netdev.h.

◆ isr

void(* netdev_driver::isr) (netdev_t *dev)

a driver's user-space ISR handler

Precondition
(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 packet flow description for details.

Parameters
[in]devnetwork device descriptor. Must not be NULL.

Definition at line 370 of file netdev.h.

◆ recv

int(* netdev_driver::recv) (netdev_t *dev, void *buf, size_t len, void *info)

Get a received frame.

Precondition
(dev != NULL)
(buf != NULL) && (len > 0)

Supposed to be called from netdev->event_callback()

If buf == NULL and len == 0, returns the packet size without dropping it. If buf == NULL and len > 0, drops the packet and returns the packet size.

Parameters
[in]devnetwork device descriptor. Must not be NULL.
[out]bufbuffer to write into or NULL to return the packet size.
[in]lenmaximum number of bytes to read. If buf is NULL the currently buffered packet is dropped when len > 0. Must not be 0 when buf != NULL.
[out]infostatus information for the received packet. Might be of different type for different netdev devices. May be NULL if not needed or applicable.
Returns
-ENOBUFS if supplied buffer is too small
number of bytes read if buf != NULL
packet size if buf == NULL

Definition at line 340 of file netdev.h.

◆ send

int(* netdev_driver::send) (netdev_t *dev, const iolist_t *iolist)

Send frame.

Precondition
(dev != NULL) && (iolist != NULL
Parameters
[in]devNetwork device descriptor. Must not be NULL.
[in]iolistio vector list to send
Returns
negative errno on error
number of bytes sent

Definition at line 310 of file netdev.h.

◆ set

int(* netdev_driver::set) (netdev_t *dev, netopt_t opt, const void *value, size_t value_len)

Set an option value for a given network device.

Precondition
(dev != NULL)
for scalar types of netopt_t value_len must be of exactly that length (see netopt documentation for type)
for array types of netopt_t value_len must lesser or equal the required length (see netopt documentation for type)
Parameters
[in]devnetwork device descriptor
[in]optoption type
[in]valuevalue to set
[in]value_lenthe length of value
Returns
number of bytes written to value
-ENOTSUP if opt is not configurable for the device
-EINVAL if value is an invalid value with regards to opt

Definition at line 414 of file netdev.h.


The documentation for this struct was generated from the following file: