Files | |
file | eth.c |
Ethernet module implementation. | |
file | eth.h |
Ethernet module. | |
Data Structures | |
struct | eth_device |
Ethernet device specific data. More... | |
struct | eth_globals |
Ethernet global data. More... | |
struct | eth_header |
Ethernet header. More... | |
struct | eth_header_lsap |
Ethernet header IEEE 802.3 + 802.2 extension. More... | |
struct | eth_header_snap |
Ethernet header IEEE 802.3 + 802.2 + SNAP extensions. More... | |
struct | eth_ieee_lsap |
Ethernet header Link Service Access Point extension. More... | |
struct | eth_preamble |
Ethernet header preamble. More... | |
struct | eth_proto |
Ethernet protocol specific data. More... | |
struct | eth_snap |
Ethernet header SNAP extension. More... | |
Defines | |
#define | ETH_8023_2_LSAP (2 << ETH_MODE_SHIFT) |
802.3 + 802.2 + LSAP mode flag. | |
#define | ETH_8023_2_SNAP (3 << ETH_MODE_SHIFT) |
802.3 + 802.2 + LSAP + SNAP mode flag. | |
#define | ETH_ADDR 6 |
Ethernet address length. | |
#define | ETH_DIX (1 << ETH_MODE_SHIFT) |
DIX Ethernet mode flag. | |
#define | ETH_DUMMY (1 << ETH_DUMMY_SHIFT) |
Dummy device flag. | |
#define | ETH_DUMMY_SHIFT 0 |
Dummy flag shift value. | |
#define | ETH_MAX_CONTENT 1500u |
Maximum packet content length. | |
#define | ETH_MAX_TAGGED_CONTENT(flags) |
Maximum tagged packet content length. | |
#define | ETH_MIN_CONTENT 46u |
Minimum packet content length. | |
#define | ETH_MIN_TAGGED_CONTENT(flags) |
Minimum tagged packet content length. | |
#define | ETH_MODE_MASK (3 << ETH_MODE_SHIFT) |
Device mode flags. | |
#define | ETH_MODE_SHIFT 1 |
Mode flag shift value. | |
#define | ETH_PREAMBLE 0x55 |
Ethernet header preamble value. | |
#define | ETH_PREFIX |
Reserved packet prefix length. | |
#define | ETH_SFD 0xD5 |
Ethernet header start of frame value. | |
#define | ETH_SUFFIX (sizeof(eth_fcs_t)) |
Reserved packet suffix length. | |
#define | IEEE_8023_2_UI 0x03 |
IEEE 802.2 unordered information control field. | |
#define | IS_8023_2_LSAP(flags) (((flags) & ETH_MODE_MASK) == ETH_8023_2_LSAP) |
Return whether the 802.3 + 802.2 + LSAP mode flag is set. | |
#define | IS_8023_2_SNAP(flags) (((flags) & ETH_MODE_MASK) == ETH_8023_2_SNAP) |
Return whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set. | |
#define | IS_DIX(flags) (((flags) & ETH_MODE_MASK) == ETH_DIX) |
Return whether the DIX Ethernet mode flag is set. | |
#define | IS_DUMMY(flags) ((flags) & ETH_DUMMY) |
Returns the dummy flag. | |
#define | NAME "eth" |
The module name. | |
Typedefs | |
typedef enum eth_addr_type | eth_addr_type_t |
Type definition of the ethernet address type. | |
typedef eth_device | eth_device_t |
Type definition of the Ethernet device specific data. | |
typedef uint32_t | eth_fcs_t |
Ethernet Frame Check Sequence. | |
typedef eth_globals | eth_globals_t |
Type definition of the Ethernet global data. | |
typedef eth_header_lsap | eth_header_lsap_t |
Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions. | |
typedef eth_header_snap | eth_header_snap_t |
Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions. | |
typedef eth_header | eth_header_t |
Type definition of the Ethernet header. | |
typedef eth_ieee_lsap | eth_ieee_lsap_t |
Type definition of the Ethernet header LSAP extension. | |
typedef eth_preamble | eth_preamble_t |
Type definition of the Ethernet header preamble. | |
typedef eth_proto | eth_proto_t |
Type definition of the Ethernet protocol specific data. | |
typedef eth_snap | eth_snap_t |
Type definition of the Ethernet header SNAP extension. | |
Enumerations | |
enum | eth_addr_type { ETH_LOCAL_ADDR, ETH_BROADCAST_ADDR } |
Ethernet address type. More... | |
Functions | |
DEVICE_MAP_DECLARE (eth_devices, eth_device_t) | |
Ethernet device map. | |
static int | eth_addr_message (device_id_t device_id, eth_addr_type_t type, measured_string_t **address) |
Returns the device hardware address. | |
static int | eth_device_message (device_id_t device_id, services_t service, size_t mtu) |
Registers new device or updates the MTU of an existing one. | |
static int | eth_packet_space_message (device_id_t device_id, size_t *addr_len, size_t *prefix, size_t *content, size_t *suffix) |
Returns the device packet dimensions for sending. | |
static int | eth_prepare_packet (int flags, packet_t *packet, uint8_t *src_addr, int ethertype, size_t mtu) |
Prepares the packet for sending. | |
static eth_proto_t * | eth_process_packet (int flags, packet_t *packet) |
Processes the received packet and chooses the target registered module. | |
static void | eth_receiver (ipc_callid_t iid, ipc_call_t *icall) |
Processes IPC messages from the registered device driver modules in an infinite loop. | |
static int | eth_register_message (services_t service, int phone) |
Registers receiving module service. | |
static int | eth_send_message (device_id_t device_id, packet_t *packet, services_t sender) |
Sends the packet queue. | |
INT_MAP_DECLARE (eth_protos, eth_proto_t) | |
Ethernet protocol map. | |
int | main (int argc, char *argv[]) |
Main entry point. | |
int | nil_device_state_msg_local (int nil_phone, device_id_t device_id, int state) |
Notify the network interface layer about the device state change. | |
int | nil_initialize (int net_phone) |
Module initialization. | |
int | nil_module_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *answer_count) |
Message processing function. | |
int | nil_received_msg_local (int nil_phone, device_id_t device_id, packet_t *packet, services_t target) |
Pass the packet queue to the network interface layer. | |
Variables | |
eth_globals_t | eth_globals |
Ethernet module global data. |
#define ETH_DUMMY (1 << ETH_DUMMY_SHIFT) |
#define ETH_MODE_MASK (3 << ETH_MODE_SHIFT) |
#define IS_8023_2_LSAP | ( | flags | ) | (((flags) & ETH_MODE_MASK) == ETH_8023_2_LSAP) |
Return whether the 802.3 + 802.2 + LSAP mode flag is set.
[in] | flags | Ethernet flags. |
#define IS_8023_2_SNAP | ( | flags | ) | (((flags) & ETH_MODE_MASK) == ETH_8023_2_SNAP) |
Return whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set.
[in] | flags | Ethernet flags. |
#define IS_DIX | ( | flags | ) | (((flags) & ETH_MODE_MASK) == ETH_DIX) |
#define IS_DUMMY | ( | flags | ) | ((flags) & ETH_DUMMY) |
typedef enum eth_addr_type eth_addr_type_t |
typedef struct eth_device eth_device_t |
typedef struct eth_globals eth_globals_t |
typedef struct eth_header_lsap eth_header_lsap_t |
Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.
typedef struct eth_header_snap eth_header_snap_t |
Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.
typedef struct eth_header eth_header_t |
typedef struct eth_ieee_lsap eth_ieee_lsap_t |
typedef struct eth_preamble eth_preamble_t |
typedef struct eth_proto eth_proto_t |
typedef struct eth_snap eth_snap_t |
enum eth_addr_type |
DEVICE_MAP_DECLARE | ( | eth_devices | , | |
eth_device_t | ||||
) |
static int eth_addr_message | ( | device_id_t | device_id, | |
eth_addr_type_t | type, | |||
measured_string_t ** | address | |||
) | [static] |
Returns the device hardware address.
[in] | device_id | The device identifier. |
[in] | type | Type of the desired address. |
[out] | address | The device hardware address. |
EBADMEM if the address parameter is NULL.
ENOENT if there no such device.
static int eth_device_message | ( | device_id_t | device_id, | |
services_t | service, | |||
size_t | mtu | |||
) | [static] |
Registers new device or updates the MTU of an existing one.
Determines the device local hardware address.
[in] | device_id | The new device identifier. |
[in] | service | The device driver service. |
[in] | mtu | The device maximum transmission unit. |
EEXIST if the device with the different service exists.
ENOMEM if there is not enough memory left.
Other error codes as defined for the net_get_device_conf_req() function.
Other error codes as defined for the netif_bind_service() function.
Other error codes as defined for the netif_get_addr_req() function.
static int eth_packet_space_message | ( | device_id_t | device_id, | |
size_t * | addr_len, | |||
size_t * | prefix, | |||
size_t * | content, | |||
size_t * | suffix | |||
) | [static] |
Returns the device packet dimensions for sending.
[in] | device_id | The device identifier. |
[out] | addr_len | The minimum reserved address length. |
[out] | prefix | The minimum reserved prefix size. |
[out] | content | The maximum content size. |
[out] | suffix | The minimum reserved suffix size. |
EBADMEM if either one of the parameters is NULL.
ENOENT if there is no such device.
static int eth_prepare_packet | ( | int | flags, | |
packet_t * | packet, | |||
uint8_t * | src_addr, | |||
int | ethertype, | |||
size_t | mtu | |||
) | [static] |
Prepares the packet for sending.
[in] | flags | The device flags. |
[in] | packet | The packet. |
[in] | src_addr | The source hardware address. |
[in] | ethertype | The ethernet protocol type. |
[in] | mtu | The device maximum transmission unit. |
EINVAL if the packet addresses length is not long enough.
EINVAL if the packet is bigger than the device MTU.
ENOMEM if there is not enough memory in the packet.
static eth_proto_t* eth_process_packet | ( | int | flags, | |
packet_t * | packet | |||
) | [static] |
Processes the received packet and chooses the target registered module.
[in] | flags | The device flags. |
[in] | packet | The packet. |
NULL if the packet is not long enough.
NULL if the packet is too long.
NULL if the raw ethernet protocol is used.
NULL if the dummy device FCS checksum is invalid.
NULL if the packet address length is not big enough.
static void eth_receiver | ( | ipc_callid_t | iid, | |
ipc_call_t * | icall | |||
) | [static] |
static int eth_register_message | ( | services_t | service, | |
int | phone | |||
) | [static] |
static int eth_send_message | ( | device_id_t | device_id, | |
packet_t * | packet, | |||
services_t | sender | |||
) | [static] |
Sends the packet queue.
Sends only packet successfully processed by the eth_prepare_packet() function.
[in] | device_id | The device identifier. |
[in] | packet | The packet queue. |
[in] | sender | The sending module service. |
ENOENT if there no such device.
EINVAL if the service parameter is not known.
INT_MAP_DECLARE | ( | eth_protos | , | |
eth_proto_t | ||||
) |
Ethernet protocol map.
Maps protocol identifiers to the Ethernet protocol specific data.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
int nil_device_state_msg_local | ( | int | , | |
device_id_t | , | |||
int | ||||
) |
Notify the network interface layer about the device state change.
This has to be implemented in user code.
[in] | nil_phone | Network interface layer phone. |
[in] | device_id | Device identifier. |
[in] | state | New device state. |
Other error codes as defined for each specific module device state function.
int nil_initialize | ( | int | net_phone | ) |
int nil_module_message | ( | ipc_callid_t | , | |
ipc_call_t * | , | |||
ipc_call_t * | , | |||
size_t * | ||||
) |
Message processing function.
This has to be implemented in user code.
[in] | name | Module name. |
[in] | callid | Message identifier. |
[in] | call | Message parameters. |
[out] | answer | Message answer parameters. |
[out] | count | Message answer arguments. |
ENOTSUP if the message is not known.
Other error codes as defined for each specific module message function.
int nil_received_msg_local | ( | int | , | |
device_id_t | , | |||
packet_t * | , | |||
services_t | ||||
) |
Pass the packet queue to the network interface layer.
Process and redistribute the received packet queue to the registered upper layers.
This has to be implemented in user code.
[in] | nil_phone | Network interface layer phone. |
[in] | device_id | Source device identifier. |
[in] | packet | Received packet or the received packet queue. |
[in] | target | Target service. Ignored parameter. |
Other error codes as defined for each specific module received function.