uIP Address Resolution Protocol
[Uip]


Detailed Description

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:
This ARP implementation only supports Ethernet.


Files

file  uip_arp.c
file  uip_arp.h

Data Structures

struct  arp_hdr
struct  ethip_hdr
struct  arp_entry
struct  uip_eth_addr
struct  uip_eth_hdr

Defines

#define ARP_REQUEST   1
#define ARP_REPLY   2
#define ARP_HWTYPE_ETH   1
#define BUF   ((struct arp_hdr *)&uip_buf[0])
#define IPBUF   ((struct ethip_hdr *)&uip_buf[0])
#define UIP_ETHTYPE_ARP   0x0806
#define UIP_ETHTYPE_IP   0x0800
#define UIP_ETHTYPE_IP6   0x86dd

Functions

void uip_arp_init (void)
void uip_arp_timer (void)
static void uip_arp_update (u16_t *ipaddr, struct uip_eth_addr *ethaddr)
void uip_arp_ipin (void)
void uip_arp_arpin (void)
void uip_arp_out (void)

Variables

uip_eth_addr uip_ethaddr
static struct arp_entry arp_table [UIP_ARPTAB_SIZE]
static u16_t ipaddr [2]
static u8_t i
static u8_t c
static u8_t arptime
static u8_t tmpage
uip_eth_addr uip_ethaddr


Define Documentation

#define ARP_HWTYPE_ETH   1
 

Definition at line 97 of file uip_arp.c.

#define ARP_REPLY   2
 

Definition at line 95 of file uip_arp.c.

#define ARP_REQUEST   1
 

Definition at line 94 of file uip_arp.c.

Referenced by uip_arp_arpin().

#define BUF   ((struct arp_hdr *)&uip_buf[0])
 

Definition at line 119 of file uip_arp.c.

#define IPBUF   ((struct ethip_hdr *)&uip_buf[0])
 

Definition at line 120 of file uip_arp.c.

Referenced by uip_arp_ipin(), and uip_arp_out().

#define UIP_ETHTYPE_ARP   0x0806
 

Definition at line 76 of file uip_arp.h.

Referenced by uip_arp_arpin().

#define UIP_ETHTYPE_IP   0x0800
 

Definition at line 77 of file uip_arp.h.

Referenced by main().

#define UIP_ETHTYPE_IP6   0x86dd
 

Definition at line 78 of file uip_arp.h.


Function Documentation

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 or not. 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.

Definition at line 278 of file uip_arp.c.

References uip_eth_addr::addr, ARP_REQUEST, BUF, HTONS, UIP_ETHTYPE_ARP, uip_hostaddr, and uip_len.

void uip_arp_init void   ) 
 

Initialize the ARP module.

Definition at line 128 of file uip_arp.c.

References i, and ipaddr.

Referenced by main().

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.

Definition at line 236 of file uip_arp.c.

References IPBUF, uip_arp_netmask, uip_arp_update(), uip_hostaddr, and uip_len.

Referenced by main().

void uip_arp_out void   ) 
 

Prepend Ethernet header to an outbound IP packet and see if we need to send out an ARP request.

This function 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 they 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.

Definition at line 353 of file uip_arp.c.

References ipaddr, IPBUF, uip_arp_draddr, uip_arp_netmask, and uip_hostaddr.

Referenced by main().

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. The recommended interval is 10 seconds between the calls.

Definition at line 145 of file uip_arp.c.

References arptime, i, arp_entry::ipaddr, arp_entry::time, and UIP_ARP_MAXAGE.

static void uip_arp_update u16_t ipaddr,
struct uip_eth_addr ethaddr
[static]
 

Definition at line 161 of file uip_arp.c.

References uip_eth_addr::addr, arptime, arp_entry::ethaddr, i, arp_entry::ipaddr, and arp_entry::time.

Referenced by uip_arp_ipin().


Variable Documentation

struct arp_entry arp_table[UIP_ARPTAB_SIZE] [static]
 

Definition at line 112 of file uip_arp.c.

u8_t arptime [static]
 

Definition at line 116 of file uip_arp.c.

Referenced by uip_arp_timer(), and uip_arp_update().

u8_t c [static]
 

Definition at line 114 of file uip_arp.c.

u8_t i [static]
 

Definition at line 114 of file uip_arp.c.

Referenced by delay(), delay_u(), main(), RxFrame(), TxFrame(), TxStr(), uip_arp_init(), uip_arp_timer(), and uip_arp_update().

u16_t ipaddr[2] [static]
 

Definition at line 113 of file uip_arp.c.

Referenced by uip_arp_init(), and uip_arp_out().

u8_t tmpage [static]
 

Definition at line 117 of file uip_arp.c.

struct uip_eth_addr uip_ethaddr
 

Definition at line 105 of file uip_arp.c.

struct uip_eth_addr uip_ethaddr
 

Initial value:

Definition at line 105 of file uip_arp.c.


Generated on Fri Jan 6 22:23:19 2006 for EtherProgs by  doxygen 1.4.5