arp.h File Reference

Address Resolution Protocol. More...

#include <gpxe/tables.h>

Go to the source code of this file.

Data Structures

struct  arp_net_protocol
 A network-layer protocol that relies upon ARP. More...

Defines

#define ARP_NET_PROTOCOLS   __table ( struct arp_net_protocol, "arp_net_protocols" )
 ARP protocol table.
#define __arp_net_protocol   __table_entry ( ARP_NET_PROTOCOLS, 01 )
 Declare an ARP protocol.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int arp_resolve (struct net_device *netdev, struct net_protocol *net_protocol, const void *dest_net_addr, const void *source_net_addr, void *dest_ll_addr)
 Look up media-specific link-layer address in the ARP cache.

Variables

struct net_protocol arp_protocol


Detailed Description

Address Resolution Protocol.

Definition in file arp.h.


Define Documentation

#define ARP_NET_PROTOCOLS   __table ( struct arp_net_protocol, "arp_net_protocols" )

ARP protocol table.

Definition at line 32 of file arp.h.

Referenced by arp_find_protocol().

#define __arp_net_protocol   __table_entry ( ARP_NET_PROTOCOLS, 01 )

Declare an ARP protocol.

Definition at line 36 of file arp.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int arp_resolve ( struct net_device netdev,
struct net_protocol net_protocol,
const void *  dest_net_addr,
const void *  source_net_addr,
void *  dest_ll_addr 
)

Look up media-specific link-layer address in the ARP cache.

Parameters:
netdev Network device
net_protocol Network-layer protocol
dest_net_addr Destination network-layer address
source_net_addr Source network-layer address
Return values:
dest_ll_addr Destination link layer address
rc Return status code
This function will use the ARP cache to look up the link-layer address for the link-layer protocol associated with the network device and the given network-layer protocol and addresses. If found, the destination link-layer address will be filled in in dest_ll_addr.

If no address is found in the ARP cache, an ARP request will be transmitted on the specified network device and -ENOENT will be returned.

Definition at line 113 of file arp.c.

References alloc_iob(), arphdr::ar_hln, arphdr::ar_hrd, arphdr::ar_op, arphdr::ar_pln, arphdr::ar_pro, arp_find_entry(), arp_protocol, ARPOP_REQUEST, DBG, ENOENT, ENOMEM, htons, iob_put, iob_reserve, net_device::ll_addr, arp_entry::ll_addr, ll_protocol::ll_addr_len, net_device::ll_broadcast, ll_protocol::ll_proto, net_device::ll_protocol, MAX_LL_ADDR_LEN, MAX_LL_HEADER_LEN, MAX_NET_ADDR_LEN, memcpy, memset(), ll_protocol::name, net_protocol::name, arp_entry::net_addr, net_protocol::net_addr_len, net_protocol::net_proto, net_tx(), ll_protocol::ntoa, and net_protocol::ntoa.

Referenced by ipv4_ll_addr().

00115                                        {
00116         struct ll_protocol *ll_protocol = netdev->ll_protocol;
00117         const struct arp_entry *arp;
00118         struct io_buffer *iobuf;
00119         struct arphdr *arphdr;
00120         int rc;
00121 
00122         /* Look for existing entry in ARP table */
00123         arp = arp_find_entry ( ll_protocol, net_protocol, dest_net_addr );
00124         if ( arp ) {
00125                 DBG ( "ARP cache hit: %s %s => %s %s\n",
00126                       net_protocol->name, net_protocol->ntoa ( arp->net_addr ),
00127                       ll_protocol->name, ll_protocol->ntoa ( arp->ll_addr ) );
00128                 memcpy ( dest_ll_addr, arp->ll_addr, ll_protocol->ll_addr_len);
00129                 return 0;
00130         }
00131         DBG ( "ARP cache miss: %s %s\n", net_protocol->name,
00132               net_protocol->ntoa ( dest_net_addr ) );
00133 
00134         /* Allocate ARP packet */
00135         iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *arphdr ) +
00136                           2 * ( MAX_LL_ADDR_LEN + MAX_NET_ADDR_LEN ) );
00137         if ( ! iobuf )
00138                 return -ENOMEM;
00139         iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
00140 
00141         /* Build up ARP request */
00142         arphdr = iob_put ( iobuf, sizeof ( *arphdr ) );
00143         arphdr->ar_hrd = ll_protocol->ll_proto;
00144         arphdr->ar_hln = ll_protocol->ll_addr_len;
00145         arphdr->ar_pro = net_protocol->net_proto;
00146         arphdr->ar_pln = net_protocol->net_addr_len;
00147         arphdr->ar_op = htons ( ARPOP_REQUEST );
00148         memcpy ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
00149                  netdev->ll_addr, ll_protocol->ll_addr_len );
00150         memcpy ( iob_put ( iobuf, net_protocol->net_addr_len ),
00151                  source_net_addr, net_protocol->net_addr_len );
00152         memset ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
00153                  0, ll_protocol->ll_addr_len );
00154         memcpy ( iob_put ( iobuf, net_protocol->net_addr_len ),
00155                  dest_net_addr, net_protocol->net_addr_len );
00156 
00157         /* Transmit ARP request */
00158         if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol, 
00159                              netdev->ll_broadcast ) ) != 0 )
00160                 return rc;
00161 
00162         return -ENOENT;
00163 }


Variable Documentation

Definition at line 66 of file arp.c.

Referenced by arp_resolve(), arp_rx(), pxenv_undi_isr(), and pxenv_undi_transmit().


Generated on Tue Apr 6 20:01:48 2010 for gPXE by  doxygen 1.5.7.1