Ethernet (IEEE 802.3) network interface layer Service
[Network interface layer]


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_teth_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 Documentation

#define ETH_DUMMY   (1 << ETH_DUMMY_SHIFT)

Dummy device flag.

Preamble and FCS are mandatory part of the packets.

Definition at line 104 of file eth.c.

#define ETH_MODE_MASK   (3 << ETH_MODE_SHIFT)

Device mode flags.

See also:
ETH_DIX

ETH_8023_2_LSAP

ETH_8023_2_SNAP

Definition at line 116 of file eth.c.

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

Parameters:
[in] flags Ethernet flags.
See also:
ETH_8023_2_LSAP

Definition at line 138 of file eth.c.

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

Parameters:
[in] flags Ethernet flags.
See also:
ETH_8023_2_SNAP

Definition at line 149 of file eth.c.

#define IS_DIX ( flags   )     (((flags) & ETH_MODE_MASK) == ETH_DIX)

Return whether the DIX Ethernet mode flag is set.

Parameters:
[in] flags Ethernet flags.
See also:
ETH_DIX

Definition at line 127 of file eth.c.

#define IS_DUMMY ( flags   )     ((flags) & ETH_DUMMY)

Returns the dummy flag.

See also:
ETH_DUMMY

Definition at line 109 of file eth.c.


Typedef Documentation

typedef enum eth_addr_type eth_addr_type_t

Type definition of the ethernet address type.

See also:
eth_addr_type

Definition at line 154 of file eth.c.

typedef struct eth_device eth_device_t

Type definition of the Ethernet device specific data.

See also:
eth_device

Definition at line 200 of file eth.h.

typedef struct eth_globals eth_globals_t

Type definition of the Ethernet global data.

See also:
eth_globals

Definition at line 195 of file eth.h.

typedef struct eth_header_lsap eth_header_lsap_t

Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.

See also:
eth_header_lsap

Definition at line 66 of file eth.h.

typedef struct eth_header_snap eth_header_snap_t

Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.

See also:
eth_header_snap

Definition at line 61 of file eth.h.

typedef struct eth_header eth_header_t

Type definition of the Ethernet header.

See also:
eth_header

Definition at line 86 of file eth.h.

typedef struct eth_ieee_lsap eth_ieee_lsap_t

Type definition of the Ethernet header LSAP extension.

See also:
eth_ieee_lsap

Definition at line 71 of file eth.h.

typedef struct eth_preamble eth_preamble_t

Type definition of the Ethernet header preamble.

See also:
preamble

Definition at line 81 of file eth.h.

typedef struct eth_proto eth_proto_t

Type definition of the Ethernet protocol specific data.

See also:
eth_proto

Definition at line 205 of file eth.h.

typedef struct eth_snap eth_snap_t

Type definition of the Ethernet header SNAP extension.

See also:
eth_snap

Definition at line 76 of file eth.h.


Enumeration Type Documentation

enum eth_addr_type

Ethernet address type.

Enumerator:
ETH_LOCAL_ADDR  Local address.
ETH_BROADCAST_ADDR  Broadcast address.

Definition at line 157 of file eth.c.


Function Documentation

DEVICE_MAP_DECLARE ( eth_devices  ,
eth_device_t   
)

Ethernet device map.

Maps devices to the Ethernet device specific data.

See also:
device.h

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.

Parameters:
[in] device_id The device identifier.
[in] type Type of the desired address.
[out] address The device hardware address.
Returns:
EOK on success.

EBADMEM if the address parameter is NULL.

ENOENT if there no such device.

Definition at line 589 of file eth.c.

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.

Parameters:
[in] device_id The new device identifier.
[in] service The device driver service.
[in] mtu The device maximum transmission unit.
Returns:
EOK on success.

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.

Definition at line 277 of file eth.c.

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.

Parameters:
[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.
Returns:
EOK on success.

EBADMEM if either one of the parameters is NULL.

ENOENT if there is no such device.

Definition at line 555 of file eth.c.

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.

Parameters:
[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.
Returns:
EOK on success.

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.

Definition at line 679 of file eth.c.

static eth_proto_t* eth_process_packet ( int  flags,
packet_t packet 
) [static]

Processes the received packet and chooses the target registered module.

Parameters:
[in] flags The device flags.
[in] packet The packet.
Returns:
The target registered module.

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.

Definition at line 428 of file eth.c.

static void eth_receiver ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Processes IPC messages from the registered device driver modules in an infinite loop.

Parameters:
[in] iid The message identifier.
[in,out] icall The message parameters.

Definition at line 231 of file eth.c.

static int eth_register_message ( services_t  service,
int  phone 
) [static]

Registers receiving module service.

Passes received packets for this service.

Parameters:
[in] service The module service.
[in] phone The service phone.
Returns:
EOK on success.

ENOENT if the service is not known.

ENOMEM if there is not enough memory left.

Definition at line 623 of file eth.c.

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.

Parameters:
[in] device_id The device identifier.
[in] packet The packet queue.
[in] sender The sending module service.
Returns:
EOK on success.

ENOENT if there no such device.

EINVAL if the service parameter is not known.

Definition at line 786 of file eth.c.

INT_MAP_DECLARE ( eth_protos  ,
eth_proto_t   
)

Ethernet protocol map.

Maps protocol identifiers to the Ethernet protocol specific data.

See also:
int_map.h

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 893 of file eth.c.

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.

Parameters:
[in] nil_phone Network interface layer phone.
[in] device_id Device identifier.
[in] state New device state.
Returns:
EOK on success.

Other error codes as defined for each specific module device state function.

Definition at line 170 of file eth.c.

int nil_initialize ( int  net_phone  ) 

Module initialization.

This has to be implemented in user code.

Parameters:
[in] net_phone Networking module phone.
Returns:
EOK on success.

Other error codes as defined for each specific module initialize function.

Definition at line 189 of file eth.c.

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.

Parameters:
[in] name Module name.
[in] callid Message identifier.
[in] call Message parameters.
[out] answer Message answer parameters.
[out] count Message answer arguments.
Returns:
EOK on success.

ENOTSUP if the message is not known.

Other error codes as defined for each specific module message function.

See also:
IS_NET_NIL_MESSAGE()

Definition at line 836 of file eth.c.

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.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for each specific module received function.

Definition at line 507 of file eth.c.


Generated on Thu Jun 2 07:45:55 2011 for HelenOS/USB by  doxygen 1.4.7