IP protocol support
[Protocol stack]


Detailed Description

Implementation of the IP layer.


Files

file  ip.c
 IP implementation (license: GPLv2).
file  ip.h
 IP header (license: GPLv2).

Defines

#define IP_PROTOCOL_ICMP
 Protocol identifier of the ICMP protocol.
#define IP_PROTOCOL_TCP
 Protocol identifier of the TCP protocol.
#define IP_PROTOCOL_UDP
 Protocol identifier of the UDP protocol.
#define ip_get_buffer()
 Retrieves a pointer to the IP transmit buffer.
#define ip_get_buffer_size()
 Retrieves the maximum payload size of the transmit buffer.

Functions

void ip_init (const uint8_t *ip, const uint8_t *netmask, const uint8_t *gateway)
 Initializes the IP layer and optionally assigns IP address, netmask and gateway.
bool ip_handle_packet (const struct ip_header *packet, uint16_t packet_len)
 Forwards incoming packets to the appropriate higher-level protocol.
bool ip_send_packet (const uint8_t *ip_dest, uint8_t protocol, uint16_t data_len)
 Sends data from the transmit buffer to a remote host.
const uint8_t * ip_get_address ()
 Retrieves the current IP address.
void ip_set_address (const uint8_t *ip_local)
 Configures a new IP address.
const uint8_t * ip_get_netmask ()
 Retrieves the current IP netmask.
void ip_set_netmask (const uint8_t *netmask)
 Configures a new IP netmask.
const uint8_t * ip_get_gateway ()
 Retrieves the current IP gateway.
void ip_set_gateway (const uint8_t *gateway)
 Configures a new IP gateway.
const uint8_t * ip_get_broadcast ()
 Retrieves the broadcast address.


Define Documentation

#define IP_PROTOCOL_ICMP

Protocol identifier of the ICMP protocol.

#define IP_PROTOCOL_TCP

Protocol identifier of the TCP protocol.

#define IP_PROTOCOL_UDP

Protocol identifier of the UDP protocol.

 
#define ip_get_buffer (  ) 

Retrieves a pointer to the IP transmit buffer.

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

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

 
#define ip_get_buffer_size (  ) 

Retrieves the maximum payload size of the transmit buffer.

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

Returns:
The maximum payload size per IP packet.


Function Documentation

void ip_init ( const uint8_t *  ip,
const uint8_t *  netmask,
const uint8_t *  gateway 
)

Initializes the IP layer and optionally assigns IP address, netmask and gateway.

Parameters:
[in] ip Buffer which contains an IP address. May be NULL.
[in] netmask Buffer which contains the netmask. May be NULL.
[in] gateway Buffer which contains the gateway. May be NULL.

bool ip_handle_packet ( const struct ip_header *  packet,
uint16_t  packet_len 
)

Forwards incoming packets to the appropriate higher-level protocol.

Note:
This function is used internally and should not be explicitly called by applications.
Parameters:
[in] packet The packet to be forwarded.
[in] packet_len The length of the packet.
Returns:
true if the packet has successfully been handled, false on failure.

bool ip_send_packet ( const uint8_t *  ip_dest,
uint8_t  protocol,
uint16_t  data_len 
)

Sends data from the transmit buffer to a remote host.

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

const uint8_t * ip_get_address (  ) 

Retrieves the current IP address.

Returns:
The buffer containing the IP address.

void ip_set_address ( const uint8_t *  ip_local  ) 

Configures a new IP address.

Parameters:
[in] ip_local The buffer containing the new IP address. May be NULL to accept broadcasts only.

const uint8_t * ip_get_netmask (  ) 

Retrieves the current IP netmask.

Returns:
The buffer containing the IP netmask.

void ip_set_netmask ( const uint8_t *  netmask  ) 

Configures a new IP netmask.

Parameters:
[in] netmask The buffer containing the new IP netmask.

const uint8_t * ip_get_gateway (  ) 

Retrieves the current IP gateway.

Returns:
The buffer containing the IP gateway.

void ip_set_gateway ( const uint8_t *  gateway  ) 

Configures a new IP gateway.

Parameters:
[in] gateway The buffer containing the new IP gateway.

const uint8_t * ip_get_broadcast (  ) 

Retrieves the broadcast address.

Returns:
The buffer containing the broadcast address.


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