iPXE
Data Structures | Defines | Functions | Variables
arp.h File Reference

Address Resolution Protocol. More...

#include <ipxe/tables.h>
#include <ipxe/netdevice.h>
#include <ipxe/neighbour.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_OR_UBDL)
static int arp_tx (struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source, const void *ll_source)
 Transmit packet, determining link-layer address via ARP.
int arp_tx_request (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
 Transmit ARP request.

Variables

struct net_protocol arp_protocol __net_protocol
 AoE protocol.
struct neighbour_discovery arp_discovery
 ARP neighbour discovery 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 31 of file arp.h.

Referenced by arp_find_protocol().

Declare an ARP protocol.

Definition at line 35 of file arp.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int arp_tx ( struct io_buffer iobuf,
struct net_device netdev,
struct net_protocol net_protocol,
const void *  net_dest,
const void *  net_source,
const void *  ll_source 
) [inline, static]

Transmit packet, determining link-layer address via ARP.

Parameters:
iobufI/O buffer
netdevNetwork device
net_protocolNetwork-layer protocol
net_destDestination network-layer address
net_sourceSource network-layer address
ll_sourceSource link-layer address
Return values:
rcReturn status code

Definition at line 51 of file arp.h.

References arp_discovery, and neighbour_tx().

Referenced by ipv4_tx().

                                                   {

        return neighbour_tx ( iobuf, netdev, net_protocol, net_dest,
                              &arp_discovery, net_source, ll_source );
}
int arp_tx_request ( struct net_device netdev,
struct net_protocol net_protocol,
const void *  net_dest,
const void *  net_source 
)

Transmit ARP request.

Parameters:
netdevNetwork device
net_protocolNetwork-layer protocol
net_destDestination network-layer address
net_sourceSource network-layer address
Return values:
rcReturn status code

Definition at line 59 of file arp.c.

References alloc_iob(), arphdr::ar_hln, arphdr::ar_hrd, arphdr::ar_op, arphdr::ar_pln, arphdr::ar_pro, ARPOP_REQUEST, DBGC, ENOMEM, htons, iob_put, iob_reserve, net_device::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(), net_protocol::name, net_device::name, net_protocol::net_addr_len, net_protocol::net_proto, net_tx(), net_protocol::ntoa, rc, and strerror().

Referenced by ipoib_transmit(), and ipv4_gratuitous_arp().

                                                                    {
        struct ll_protocol *ll_protocol = netdev->ll_protocol;
        struct io_buffer *iobuf;
        struct arphdr *arphdr;
        int rc;

        /* Allocate ARP packet */
        iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *arphdr ) +
                            ( 2 * ( MAX_LL_ADDR_LEN + MAX_NET_ADDR_LEN ) ) );
        if ( ! iobuf )
                return -ENOMEM;
        iob_reserve ( iobuf, MAX_LL_HEADER_LEN );

        /* Build up ARP request */
        arphdr = iob_put ( iobuf, sizeof ( *arphdr ) );
        arphdr->ar_hrd = ll_protocol->ll_proto;
        arphdr->ar_hln = ll_protocol->ll_addr_len;
        arphdr->ar_pro = net_protocol->net_proto;
        arphdr->ar_pln = net_protocol->net_addr_len;
        arphdr->ar_op = htons ( ARPOP_REQUEST );
        memcpy ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
                 netdev->ll_addr, ll_protocol->ll_addr_len );
        memcpy ( iob_put ( iobuf, net_protocol->net_addr_len ),
                 net_source, net_protocol->net_addr_len );
        memset ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
                 0, ll_protocol->ll_addr_len );
        memcpy ( iob_put ( iobuf, net_protocol->net_addr_len ),
                 net_dest, net_protocol->net_addr_len );

        /* Transmit ARP request */
        if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
                             netdev->ll_broadcast, netdev->ll_addr ) ) != 0 ) {
                DBGC ( netdev, "ARP %s %s %s could not transmit request: %s\n",
                       netdev->name, net_protocol->name,
                       net_protocol->ntoa ( net_dest ), strerror ( rc ) );
                return rc;
        }

        return 0;
}

Variable Documentation

struct net_protocol arp_protocol __net_protocol

AoE protocol.

AoE protocol.

FIP protocol.

Definition at line 55 of file aoe.c.

ARP neighbour discovery protocol.

Definition at line 103 of file arp.c.

Referenced by arp_tx().