Ethernet frame support
[Protocol stack]


Detailed Description

Implementation of the Ethernet protocol.


Files

file  ethernet.c
 Ethernet implementation (license: GPLv2).
file  ethernet.h
 Ethernet header (license: GPLv2).

Modules

 Ethernet configuration

Defines

#define ETHERNET_FRAME_TYPE_IP
 Protocol identifier of the IP protocol.
#define ETHERNET_FRAME_TYPE_ARP
 Protocol identifier of the ARP protocol.
#define ethernet_get_buffer()
 Retrieves a pointer to the ethernet transmit buffer.
#define ethernet_get_buffer_size()
 Retrieves the maximum payload size of the transmit buffer.

Functions

void ethernet_init (const uint8_t *mac)
 Initializes the ethernet layer and assigns an ethernet address.
bool ethernet_handle_packet ()
 Reads incoming packets and forwards them to the appropriate higher-level protocol.
bool ethernet_send_packet (const uint8_t *mac_dest, uint16_t type, uint16_t data_len)
 Sends data from the transmit buffer to a remote host.
const uint8_t * ethernet_get_mac ()
 Retrieves the current ethernet address.


Define Documentation

#define ETHERNET_FRAME_TYPE_IP

Protocol identifier of the IP protocol.

#define ETHERNET_FRAME_TYPE_ARP

Protocol identifier of the ARP protocol.

 
#define ethernet_get_buffer (  ) 

Retrieves a pointer to the ethernet transmit buffer.

For sending ethernet packets, write your data to the buffer returned by this function and call ethernet_send_packet() afterwards.

Returns:
A pointer pointing to the beginning of the transmit buffer.

 
#define ethernet_get_buffer_size (  ) 

Retrieves the maximum payload size of the transmit buffer.

You may not send more bytes per ethernet packet than returned by this function.

Returns:
The maximum payload size per ethernet packet.


Function Documentation

void ethernet_init ( const uint8_t *  mac  ) 

Initializes the ethernet layer and assigns an ethernet address.

Parameters:
[in] mac The ethernet MAC address to configure for the network interface. Six bytes are used from this buffer.

bool ethernet_handle_packet (  ) 

Reads incoming packets and forwards them to the appropriate higher-level protocol.

Note:
This function must be continuously called by the application within its main loop in order to properly handle incoming packets.
Returns:
true if a packet has been handled, false if none has been waiting.

bool ethernet_send_packet ( const uint8_t *  mac_dest,
uint16_t  type,
uint16_t  data_len 
)

Sends data from the transmit buffer to a remote host.

Parameters:
[in] mac_dest The six byte ethernet address of the remote host to which the packet gets sent.
[in] type The protocol identifier of the upper layer protocol.
[in] data_len The length of the packet payload which is read from the global transmit buffer.
Returns:
true on success, false on failure.

const uint8_t * ethernet_get_mac (  ) 

Retrieves the current ethernet address.

Returns:
The buffer containing the ethernet address.


Generated on Thu May 22 18:12:37 2008 for mega-eth by  doxygen 1.5.5