Ethernet module implementation. More...
#include <async.h>
#include <malloc.h>
#include <mem.h>
#include <stdio.h>
#include <string.h>
#include <ipc/ipc.h>
#include <ipc/services.h>
#include "../../err.h"
#include "../../messages.h"
#include "../../modules.h"
#include "../../include/byteorder.h"
#include "../../include/checksum.h"
#include "../../include/ethernet_lsap.h"
#include "../../include/ethernet_protocols.h"
#include "../../include/protocol_map.h"
#include "../../include/device.h"
#include "../../include/netif_interface.h"
#include "../../include/net_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/il_interface.h"
#include "../../structures/measured_strings.h"
#include "../../structures/packet/packet_client.h"
#include "../nil_module.h"
#include "eth.h"
#include "eth_header.h"
Defines | |
#define | ETH_PREFIX (sizeof(eth_header_t) + sizeof(eth_header_lsap_t) + sizeof(eth_header_snap_t)) |
Reserved packet prefix length. | |
#define | ETH_SUFFIX sizeof(eth_fcs_t) |
Reserved packet suffix length. | |
#define | ETH_MAX_CONTENT 1500u |
Maximum packet content length. | |
#define | ETH_MIN_CONTENT 46u |
Minimum packet content length. | |
#define | ETH_MAX_TAGGED_CONTENT(flags) (ETH_MAX_CONTENT - ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? sizeof(eth_header_lsap_t) : 0) - (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0)) |
Maximum tagged packet content length. | |
#define | ETH_MIN_TAGGED_CONTENT(flags) (ETH_MIN_CONTENT - ((IS_8023_2_LSAP(flags) || IS_8023_2_SNAP(flags)) ? sizeof(eth_header_lsap_t) : 0) - (IS_8023_2_SNAP(flags) ? sizeof(eth_header_snap_t) : 0)) |
Minimum tagged packet content length. | |
#define | ETH_DUMMY_SHIFT 0 |
Dummy flag shift value. | |
#define | ETH_MODE_SHIFT 1 |
Mode flag shift value. | |
#define | ETH_DUMMY (1 << ETH_DUMMY_SHIFT) |
Dummy device flag. | |
#define | IS_DUMMY(flags) ((flags) Ð_DUMMY) |
Returns the dummy flag. | |
#define | ETH_MODE_MASK (3 << ETH_MODE_SHIFT) |
Device mode flags. | |
#define | ETH_DIX (1 << ETH_MODE_SHIFT) |
DIX Ethernet mode flag. | |
#define | IS_DIX(flags) (((flags) Ð_MODE_MASK) == ETH_DIX) |
Returns whether the DIX Ethernet mode flag is set. | |
#define | ETH_8023_2_LSAP (2 << ETH_MODE_SHIFT) |
802.3 + 802.2 + LSAP mode flag. | |
#define | IS_8023_2_LSAP(flags) (((flags) Ð_MODE_MASK) == ETH_8023_2_LSAP) |
Returns whether the 802.3 + 802.2 + LSAP mode flag is set. | |
#define | ETH_8023_2_SNAP (3 << ETH_MODE_SHIFT) |
802.3 + 802.2 + LSAP + SNAP mode flag. | |
#define | IS_8023_2_SNAP(flags) (((flags) Ð_MODE_MASK) == ETH_8023_2_SNAP) |
Returns whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set. | |
Typedefs | |
typedef enum eth_addr_type | eth_addr_type_t |
Type definition of the ethernet address type. | |
typedef eth_addr_type_t * | eth_addr_type_ref |
Type definition of the ethernet address type pointer. | |
Enumerations | |
enum | eth_addr_type { ETH_LOCAL_ADDR, ETH_BROADCAST_ADDR } |
Ethernet address type. More... | |
Functions | |
eth_proto_ref | eth_process_packet (int flags, packet_t packet) |
Processes the received packet and chooses the target registered module. | |
int | eth_prepare_packet (int flags, packet_t packet, uint8_t *src_addr, int ethertype, size_t mtu) |
Prepares the packet for sending. | |
int | nil_device_state_msg (int nil_phone, device_id_t device_id, int state) |
int | nil_initialize (int net_phone) |
Module initialization. | |
int | nil_received_msg (int nil_phone, device_id_t device_id, packet_t packet, services_t target) |
int | nil_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, int *answer_count) |
Message processing function. | |
Message processing functions | |
void | eth_receiver (ipc_callid_t iid, ipc_call_t *icall) |
Processes IPC messages from the registered device driver modules in an infinite loop. | |
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. | |
int | eth_register_message (services_t service, int phone) |
Registers receiving module service. | |
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. | |
int | eth_addr_message (device_id_t device_id, eth_addr_type_t type, measured_string_ref *address) |
Returns the device hardware address. | |
int | eth_send_message (device_id_t device_id, packet_t packet, services_t sender) |
Sends the packet queue. | |
Variables | |
eth_globals_t | eth_globals |
Ethernet module global data. |
Ethernet module implementation.