weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Files | Data Structures | Defines | Functions | Variables
uIP Address Resolution Protocol
+ + uIP -- Application (layer) support + +

Overview

The Address Resolution Protocol ARP is used for mapping between IP addresses and link level addresses such as the Ethernet MAC addresses. ARP uses broadcast queries to ask for the link level address of a known IP address and the host which is configured with the IP address for which the query was meant, will respond with its link level address.

Note:
uIP's ARP implementation only supports Ethernet.

The ARP code needs to know the MAC address of the Ethernet card in order to be able to respond to ARP queries and to generate working Ethernet headers. So actMACadd has to be set to the correct value before the ARP implementation can work.

Files

file  uip_arp.h
 

Definitions for the ARP module.


Data Structures

struct  arp_entry
 An ARP entry. More...
struct  arp_hdr
 The ARP header. More...
struct  ethip_hdr
 The IP header. More...
struct  uip_eth_hdr
 The Ethernet header. More...

Defines

#define ARP_HWTYPE_ETH
 ARP packet hardware Ethernet (the only supported one)
#define ARP_REPLY
 packet type answer "I have IP.. and MAC.."
#define ARP_REQUEST
 packet type request "which MAC has IP...?"
#define UIP_ETHTYPE_ARP
 Type ARP (in little endian)
#define UIP_ETHTYPE_IP
 Type IP (V.4) (in little endian)
#define UIP_ETHTYPE_IP6
 Type IPV6 (in little endian)

Functions

void uip_arp_arpin (void)
 ARP processing for incoming ARP packets.
void uip_arp_init (void)
 Initialise the ARP module.
void uip_arp_ipin (void)
 ARP processing for incoming IP packets.
void uip_arp_out (void)
 The ARP output prepare function.
void uip_arp_timer (void)
 Periodic ARP processing function.

Variables

struct arp_entry arp_table []
 The ARP table.
struct uip_eth_addr broadcast_ethaddr
 The broadcast MAC.
const uint16_t broadcast_ipaddr []
 The broadcast IP address.

Function Documentation

void uip_arp_init ( void  )

Initialise the ARP module.

This functions just clears all entries in the ARP table and the ARP time tick.
It should be called before calling any other ARP functions.

void uip_arp_ipin ( void  )

ARP processing for incoming IP packets.

This function should be called by the device driver when an IP packet has been received. The function will check if the address is in the ARP cache, and if so the ARP cache entry will be refreshed. If no ARP cache entry was found, a new one is created.

This function expects an IP packet with a prepended Ethernet header in the uip_buf[] buffer, and the length of the packet in the global variable uip_len.

void uip_arp_arpin ( void  )

ARP processing for incoming ARP packets.

This function should be called by the device driver when an ARP packet has been received. The function will act differently depending on the ARP packet type: if it is a reply for a request that we previously sent out, the ARP cache will be filled in with the values from the ARP reply. If the incoming ARP packet is an ARP request for our IP address, an ARP reply packet is created and put into the uip_buf[] buffer.

When the function returns, the value of the global variable uip_len indicates whether the device driver should send out a packet. If uip_len is zero, no packet should be sent. If uip_len is non-zero, it contains the length of the outbound packet that is present in the uip_buf[] buffer.

This function expects an ARP packet with a prepended Ethernet header in the uip_buf[] buffer, and the length of the packet in the global variable uip_len.

void uip_arp_out ( void  )

The ARP output prepare function.

It should be called before sending out an IP packet. The function checks the destination IP address of the IP packet to see what Ethernet MAC address that should be used as a destination MAC address on the Ethernet.

If the destination IP address is in the local network (determined by logical ANDing of netmask and our IP address), the function checks the ARP cache to see if an entry for the destination IP address is found. If so, an Ethernet header is prepended and the function returns. If no ARP cache entry is found for the destination IP address, the packet in the uip_buf[] is replaced by an ARP request packet for the IP address. The IP packet is dropped and it is assumed that the higher level protocols (e.g., TCP) eventually will retransmit the dropped packet.

If the destination IP address is not on the local network, the IP address of the default router is used instead.

When the function returns, a packet is present in the uip_buf[] buffer, and the length of the packet is in the global variable uip_len.

void uip_arp_timer ( void  )

Periodic ARP processing function.

This function performs periodic timer processing in the ARP module and should be called at regular intervals. It will clear old (out-dated) entries in the ARP table.

The recommended frequency is every 10 seconds.

  See also:   UIP_ARP_MAXAGE


Variable Documentation

struct arp_entry arp_table[]

The ARP table.

  See also:   UIP_ARPTAB_SIZE