device/class/net.h header reference
[Devices support library module]

The source code of this header can be browsed online.

Description  

See also DRIVER_CLASS_NET.

Description  

Network devices implement a network layer in libnetwork API terms.

On request, device is responsible for creating a network layer, and returns it to caller. Caller is then free to stack other layers on top of it.

As network layers are refcounted, caller may close its network session by dropping all references it has on layer returned by the device.

When asking for instanciation of a layer, caller must provide various parameters, including network layer type. This gives an opportunity to optimize stacks by using the highest-level layer possible.

For instance, in a classical IP over ethernet environment, most ethernet device drivers will implement IEEE802.3 MAC layer. Some high-end network adapters do optimizations at IP level, and then may also implement IP layer. A stack creation routine may try to use the device driver to implement each layer, going lower in stack depth until it gets an implemented layer for the driver.

For protocols sharing the same medium for various unrelated tasks, like Bluetooth Low Energy where Radio is used for Advertising, Connection, Scanning, etc., device driver may implement each as a separate layer.

A device should be able to run multiple concurrent layers where it makes sense.

Each layer API (tasks, commands, etc.) is defined in libnetwork. Layers returned by network drivers should be drop-in replacement for their generic libnetwork counterparts, if any.

Network layer definition may contain handler specialization. Layers returns by device drivers must implement the whose set of APIs of a layer definition.

Members  

Types  

Functions  

Macros  

Members detail  

#define DEVICE_NET_H  

This macro is declared in device/class/net.h source file, line 71.

#define DEV_NET_GET_INFO(n)  

This macro is declared in device/class/net.h source file, line 128.

this macro retrieves device information.

#define DEV_NET_LAYER_CREATE(n)  

This macro is declared in device/class/net.h source file, line 101.

this macro retrieves a layer from the device driver. Driver is responsible for memory allocation for layer structure. Layer is reference counted, ownership is transferred to caller. Caller may drop all references to layer when not needed any more.

layer is meaningful only if return value is not an error.

Parameter list:

  • accessor: Device instance
  • scheduler: Network scheduler to attach layer in
  • type: Network layer type
  • params: Layer creation parameters structure, as defined by layer type
  • delegate: Delegate for network layer side-channel handling
  • delegate_vtable: Delegate vtable, may be extended by layer type declaration
  • layer: Returned layer

The return value is an error level

#define DRIVER_NET_METHODS(prefix)  

This macro is declared in device/class/net.h source file, line 141.

struct dev_net_info_s  

This struct is declared in device/class/net.h source file, line 115.

FieldDescription
uint64_t implemented_layers;A bitfield from CONFIG_NET_LAYER_TYPE_ENUM enum allocator with a bit set for each layer type implemented by this device.
struct net_addr_s addr;
uint16_t prefix_size;
uint16_t mtu;

typedef error_t (device_net_get_info_t)(struct device_net_s *accessor, struct dev_net_info_s *info)   

This typedef is declared in device/class/net.h source file, line 134.

This typedef defines the prototype of the get_info function.

This declaration involves expansion of the DEV_NET_GET_INFO macro.

typedef error_t (device_net_layer_create_t)(struct device_net_s *accessor, struct net_scheduler_s *scheduler, uint_fast8_t type, const void *params, void *delegate, const struct net_layer_delegate_vtable_s *delegate_vtable, struct net_layer_s **layer)   

This typedef is declared in device/class/net.h source file, line 112.

This typedef defines the prototype of the layer creation function.

This declaration involves expansion of the DEV_NET_LAYER_CREATE macro.

struct device_net_s  

This struct is declared in DRIVER_CLASS_TYPES function like macro expansion, line 19 in device/class/net.h source file, line 140.

This struct is the device accessor object type for the net device class. This accessor must be initialized by calling the device_get_accessor function.

See also DRIVER_CLASS_NET, struct device_accessor_s and Device accessor.

FieldDescription
union <anonymous> {
struct device_accessor_s base;
struct <anonymous> {
struct device_s * dev;
struct driver_net_s * api;
uint_fast8_t number;
};
};

struct device_accessor_s * device_net_s_base(struct device_net_s *x)  

This function is declared in DRIVER_CLASS_TYPES function like macro expansion, line 40 in device/class/net.h source file, line 140.

This function casts a net device accessor to a generic device accessor

struct device_net_s * device_net_s_cast(struct device_accessor_s *x)  

This function is declared in DRIVER_CLASS_TYPES function like macro expansion, line 33 in device/class/net.h source file, line 140.

This function casts a generic device accessor to a net device accessor

struct driver_net_s  

This struct is declared in DRIVER_CLASS_TYPES function like macro expansion, line 5 in device/class/net.h source file, line 140.

This struct is the driver API descriptor for the net device class.

See also DRIVER_CLASS_NET and struct driver_class_s.

Valid XHTML 1.0 StrictGenerated by diaxen on Wed Oct 17 21:18:38 2018 using MkDoc