RetroArch
Files | Classes | Macros | Enumerations | Functions | Variables
uIP Address Resolution Protocol
Collaboration diagram for uIP Address Resolution Protocol:

Files

file  uip_arp.c
 
file  uip_arp.h
 

Classes

struct  arp_entry
 
struct  uip_eth_addr
 
struct  uip_eth_hdr
 
struct  uip_arp_hdr
 
struct  uip_ethip_hdr
 

Macros

#define UIP_LOG(m)
 
#define UIP_STAT(s)
 
#define ARP_TRY_HARD   0x01
 
#define ARP_MAXAGE   240
 
#define ARP_MAXPENDING   2
 
#define ARP_REQUEST   1
 
#define ARP_REPLY   2
 
#define ARP_HWTYPE_ETH   1
 
#define ARPH_HWLEN(hdr)   (ntohs((hdr)->_hwlen_protolen) >> 8)
 
#define ARPH_PROTOLEN(hdr)   (ntohs((hdr)->_hwlen_protolen) & 0xff)
 
#define ARPH_HWLEN_SET(hdr, len)   (hdr)->_hwlen_protolen = htons(ARPH_PROTOLEN(hdr) | ((len) << 8))
 
#define ARPH_PROTOLEN_SET(hdr, len)   (hdr)->_hwlen_protolen = htons((len) | (ARPH_HWLEN(hdr) << 8))
 
#define UIP_ARP_TMRINTERVAL   5000
 
#define UIP_ETHTYPE_ARP   0x0806
 
#define UIP_ETHTYPE_IP   0x0800
 
#define UIP_ETHTYPE_IP6   0x86dd
 
#define PACK_STRUCT_STRUCT   __attribute__((packed))
 

Enumerations

enum  arp_state { ARP_STATE_EMPTY, ARP_STATE_PENDING, ARP_STATE_STABLE, ARP_STATE_EXPIRED }
 

Functions

void uip_arp_init (void)
 
void uip_arp_timer (void)
 
static s8_t uip_arp_findentry (struct uip_ip_addr *ipaddr, u8_t flags)
 
static s8_t uip_arp_update (struct uip_netif *netif, struct uip_ip_addr *ipaddr, struct uip_eth_addr *ethaddr, u8_t flags)
 
void uip_arp_ipin (struct uip_netif *netif, struct uip_pbuf *p)
 
void uip_arp_arpin (struct uip_netif *netif, struct uip_eth_addr *ethaddr, struct uip_pbuf *p)
 
s8_t uip_arp_out (struct uip_netif *netif, struct uip_ip_addr *ipaddr, struct uip_pbuf *q)
 
s8_t uip_arp_arpquery (struct uip_netif *netif, struct uip_ip_addr *ipaddr, struct uip_pbuf *q)
 
s8_t uip_arp_arprequest (struct uip_netif *netif, struct uip_ip_addr *ipaddr)
 
 uip_eth_addr::PACK_STRUCT_FIELD (u8_t addr[6])
 
 uip_eth_hdr::PACK_STRUCT_FIELD (struct uip_eth_addr dest)
 
 uip_eth_hdr::PACK_STRUCT_FIELD (u16_t type)
 
 uip_arp_hdr::PACK_STRUCT_FIELD (struct uip_eth_hdr ethhdr)
 
 uip_arp_hdr::PACK_STRUCT_FIELD (u16_t hwtype)
 
 uip_arp_hdr::PACK_STRUCT_FIELD (struct uip_eth_addr shwaddr)
 
 uip_arp_hdr::PACK_STRUCT_FIELD (struct uip_ip_addr2 sipaddr)
 
 uip_ethip_hdr::PACK_STRUCT_FIELD (struct uip_eth_hdr ethhdr)
 
 uip_ethip_hdr::PACK_STRUCT_FIELD (struct uip_ip_hdr ip)
 

Variables

static const struct uip_eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}
 
static struct arp_entry arp_table [UIP_ARPTAB_SIZE]
 
PACK_STRUCT_BEGIN struct uip_eth_addr PACK_STRUCT_STRUCT
 
PACK_STRUCT_END struct uip_eth_addr uip_ethaddr
 

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.

Macro Definition Documentation

◆ ARP_HWTYPE_ETH

#define ARP_HWTYPE_ETH   1

◆ ARP_MAXAGE

#define ARP_MAXAGE   240

◆ ARP_MAXPENDING

#define ARP_MAXPENDING   2

◆ ARP_REPLY

#define ARP_REPLY   2

◆ ARP_REQUEST

#define ARP_REQUEST   1

◆ ARP_TRY_HARD

#define ARP_TRY_HARD   0x01

◆ ARPH_HWLEN

#define ARPH_HWLEN (   hdr)    (ntohs((hdr)->_hwlen_protolen) >> 8)

◆ ARPH_HWLEN_SET

#define ARPH_HWLEN_SET (   hdr,
  len 
)    (hdr)->_hwlen_protolen = htons(ARPH_PROTOLEN(hdr) | ((len) << 8))

◆ ARPH_PROTOLEN

#define ARPH_PROTOLEN (   hdr)    (ntohs((hdr)->_hwlen_protolen) & 0xff)

◆ ARPH_PROTOLEN_SET

#define ARPH_PROTOLEN_SET (   hdr,
  len 
)    (hdr)->_hwlen_protolen = htons((len) | (ARPH_HWLEN(hdr) << 8))

◆ PACK_STRUCT_STRUCT

◆ UIP_ARP_TMRINTERVAL

#define UIP_ARP_TMRINTERVAL   5000

◆ UIP_ETHTYPE_ARP

#define UIP_ETHTYPE_ARP   0x0806

◆ UIP_ETHTYPE_IP

#define UIP_ETHTYPE_IP   0x0800

◆ UIP_ETHTYPE_IP6

#define UIP_ETHTYPE_IP6   0x86dd

◆ UIP_LOG

#define UIP_LOG (   m)

◆ UIP_STAT

#define UIP_STAT (   s)

Enumeration Type Documentation

◆ arp_state

enum arp_state
Enumerator
ARP_STATE_EMPTY 
ARP_STATE_PENDING 
ARP_STATE_STABLE 
ARP_STATE_EXPIRED 

Function Documentation

◆ PACK_STRUCT_FIELD() [1/9]

uip_eth_addr::PACK_STRUCT_FIELD ( u8_t  addr[6])

◆ PACK_STRUCT_FIELD() [2/9]

uip_eth_hdr::PACK_STRUCT_FIELD ( struct uip_eth_addr  dest)

◆ PACK_STRUCT_FIELD() [3/9]

uip_eth_hdr::PACK_STRUCT_FIELD ( u16_t  type)

◆ PACK_STRUCT_FIELD() [4/9]

uip_arp_hdr::PACK_STRUCT_FIELD ( struct uip_eth_hdr  ethhdr)

◆ PACK_STRUCT_FIELD() [5/9]

uip_arp_hdr::PACK_STRUCT_FIELD ( u16_t  hwtype)

◆ PACK_STRUCT_FIELD() [6/9]

uip_arp_hdr::PACK_STRUCT_FIELD ( struct uip_eth_addr  shwaddr)

◆ PACK_STRUCT_FIELD() [7/9]

uip_arp_hdr::PACK_STRUCT_FIELD ( struct uip_ip_addr2  sipaddr)

◆ PACK_STRUCT_FIELD() [8/9]

uip_ethip_hdr::PACK_STRUCT_FIELD ( struct uip_eth_hdr  ethhdr)

◆ PACK_STRUCT_FIELD() [9/9]

uip_ethip_hdr::PACK_STRUCT_FIELD ( struct uip_ip_hdr  ip)

◆ uip_arp_arpin()

void uip_arp_arpin ( struct uip_netif netif,
struct uip_eth_addr ethaddr,
struct uip_pbuf p 
)

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_arpquery()

s8_t uip_arp_arpquery ( struct uip_netif netif,
struct uip_ip_addr ipaddr,
struct uip_pbuf q 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_arprequest()

s8_t uip_arp_arprequest ( struct uip_netif netif,
struct uip_ip_addr ipaddr 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_findentry()

static s8_t uip_arp_findentry ( struct uip_ip_addr ipaddr,
u8_t  flags 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_init()

void uip_arp_init ( void  )

Initialize the ARP module.

Here is the caller graph for this function:

◆ uip_arp_ipin()

void uip_arp_ipin ( struct uip_netif netif,
struct uip_pbuf p 
)

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_out()

s8_t uip_arp_out ( struct uip_netif netif,
struct uip_ip_addr ipaddr,
struct uip_pbuf q 
)

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_timer()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uip_arp_update()

static s8_t uip_arp_update ( struct uip_netif netif,
struct uip_ip_addr ipaddr,
struct uip_eth_addr ethaddr,
u8_t  flags 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ arp_table

struct arp_entry arp_table[UIP_ARPTAB_SIZE]
static

◆ ethbroadcast

const struct uip_eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}
static

◆ PACK_STRUCT_STRUCT

PACK_STRUCT_END PACK_STRUCT_BEGIN struct uip_ethip_hdr PACK_STRUCT_STRUCT

◆ uip_ethaddr

PACK_STRUCT_END struct uip_eth_addr uip_ethaddr