netdev_driver Struct Reference

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

Detailed Description

The send/receive functions expect/return a full ethernet frame (dst mac, src mac, ethertype, payload, no checksum).

Definition at line 131 of file drivers/include/net/netdev.h.

#include <net/netdev.h>

Data Fields

int(* send )(netdev_t *dev, const struct iovec *vector, unsigned count)
 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, void *value, size_t value_len)
 Set an option value for a given network device. More...
 

Field Documentation

int(* netdev_driver::get) (netdev_t *dev, netopt_t opt, void *value, size_t max_len)
Precondition
(dev != NULL)
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
< 0 on error, 0 on success

Definition at line 209 of file drivers/include/net/netdev.h.

int(* netdev_driver::init) (netdev_t *dev)
Precondition
(dev != NULL)
Returns
< 0 on error, 0 on success

Definition at line 178 of file drivers/include/net/netdev.h.

void(* netdev_driver::isr) (netdev_t *dev)
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_t::event_callback() for each occuring event.

See receive packet flow description for details.

Parameters
[in]devnetwork device descriptor

Definition at line 194 of file drivers/include/net/netdev.h.

int(* netdev_driver::recv) (netdev_t *dev, void *buf, size_t len, void *info)
Precondition
(dev != NULL)
(buf != NULL) && (len > 0)

Supposed to be called from netdev_t::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
[out]bufbuffer to write into or NULL
[in]lenmaximum number of bytes to read
[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
< 0 on error
number of bytes read if buf != NULL
packet size if buf == NULL

Definition at line 169 of file drivers/include/net/netdev.h.

int(* netdev_driver::send) (netdev_t *dev, const struct iovec *vector, unsigned count)
Precondition
(dev != NULL)
(count == 0) || (vector != NULL) ((count != 0) => (vector != NULL))
Parameters
[in]devnetwork device descriptor
[in]vectorio vector array to send
[in]countnr of entries in vector
Returns
number of bytes sent, or < 0 on error

Definition at line 145 of file drivers/include/net/netdev.h.

int(* netdev_driver::set) (netdev_t *dev, netopt_t opt, void *value, size_t value_len)
Precondition
(dev != NULL)
Parameters
[in]devnetwork device descriptor
[in]optoption type
[in]valuevalue to set
[in]value_lenthe length of value
Returns
number of bytes used from value
< 0 on error, 0 on success

Definition at line 225 of file drivers/include/net/netdev.h.


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