Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

ARP Protocol

RFC 826 address resolution protocol. More...

Functions

void NutArpCacheUpdate (NUTDEVICE *dev, u_long ip, u_char *ha)
 Update an ARP entry. More...

int NutArpCacheQuery (NUTDEVICE *dev, const u_long ip, u_char *mac, NETBUF *nbip)
 Query MAC address for a specified IP address. More...

void NutArpInput (NUTDEVICE *dev, NETBUF *nb)
 Handle incoming ARP packets. More...

NETBUFNutArpAllocNetBuf (u_short type, u_long ip, u_char *mac)
 Allocate an ARP network buffer structure. More...

int NutArpOutput (NUTDEVICE *dev, NETBUF *nb, u_char flags)
 Send an ARP packet. More...


Detailed Description

RFC 826 address resolution protocol.

ARP is used to map IP addresses to hardware addresses. Each network interface of Nut/Net keeps its own mapping table.

When an IP packet has to be sent out, IP needs the hardware address to pass it to the Ethernet layer. If the mapping is not in the ARP cache, an Ethernet broadcast packet is sent to the local network requesting the physical hardware address for the given IP address.

Version:
2.0.4
Author:
Harald Kipp, egnite Software GmbH

Todo:
Configurable cache timeout.

Only save the last packet to unresolved destinations.

Add functions to manually add or remove ARP entries. \toto Add function to query ARP tables.

Todo:
Response may reuse received ARP packet.

Function Documentation

NETBUF * NutArpAllocNetBuf ( u_short type,
u_long ip,
u_char * mac )
 

Allocate an ARP network buffer structure.

Parameters:
type   Type of ARP packet.
ip   Target IP address.
mac   Target MAC address, null pointer for broadcast.

Returns:
Pointer to the allocated network buffer structure or 0 on failure.

int NutArpCacheQuery ( NUTDEVICE * dev,
const u_long ip,
u_char * mac,
NETBUF * nbip )
 

Query MAC address for a specified IP address.

If no entry is available in the ARP cache, an ARP request is generated, sent out to the network and the calling thread will be suspended.

Todo:
Only hold the IP latest packet in the network buffer queue.
Parameters:
dev   Identifies the device to be used for sending. This pointer must have been retrieved previously by using the NutDeviceOpen() function.
ip   IP address of which the caller asked the MAC address.
Return values:
mac   Retrieved MAC address.
Parameters:
nbip   Pointer to a network buffer to be sent asynchronously. This pointer should be NULL for synchronous output.

Returns:
0 if address resolved, -1 otherwise.

void NutArpCacheUpdate ( NUTDEVICE * dev,
u_long ip,
u_char * ha )
 

Update an ARP entry.

If an entry with the same IP address exists, then this entry is updated. If no entry exists, a new one is created. Any previously queued packets (asynchronous send) for this IP address are sent out and all threads waiting for address resolution (synchronous send) are woken up.

Note:
This function is automatically called on each incoming ARP telegram. Applications typically do not call this function.
Parameters:
dev   Identifies the device, which cache is updated. This pointer must have been retrieved previously by using the NutDeviceOpen() function.
ip   IP address.
ha   MAC address.

void NutArpInput ( NUTDEVICE * dev,
NETBUF * nb )
 

Handle incoming ARP packets.

Packets not destined to us or packets with unsupported address type or item length are silently discarded.

Note:
This routine is called by the Ethernet layer on incoming ARP packets. Applications typically do not call this function.
Parameters:
dev   Identifies the device that received the packet.
nb   Pointer to a network buffer structure containing the ARP packet.

int NutArpOutput ( NUTDEVICE * dev,
NETBUF * nb,
u_char flags )
 

Send an ARP packet.

Note:
Applications typically do not call this function.
Parameters:
dev   Identifies the device to use.
nb   Packet to send.
flags   Set to 1 for asynchronous output, 0 otherwise.

Returns:
0 on success. If an error occurs, -1 will be returned and the net buffer is automatically released.


© 2000-2001 by egnite Software GmbH - visit http://www.ethernut.de/