iPXE
Data Structures | Macros | 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...
 

Macros

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

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. More...
 
int arp_tx_request (struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
 Transmit ARP request. More...
 

Variables

struct net_protocol arp_protocol __net_protocol
 AoE protocol. More...
 
struct neighbour_discovery arp_discovery
 ARP neighbour discovery protocol. More...
 

Detailed Description

Address Resolution Protocol.

Definition in file arp.h.

Macro Definition Documentation

◆ ARP_NET_PROTOCOLS

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

ARP protocol table.

Definition at line 31 of file arp.h.

◆ __arp_net_protocol

#define __arp_net_protocol   __table_entry ( ARP_NET_PROTOCOLS, 01 )

Declare an ARP protocol.

Definition at line 35 of file arp.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ arp_tx()

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 
)
inlinestatic

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.

54  {
55 
56  return neighbour_tx ( iobuf, netdev, net_protocol, net_dest,
57  &arp_discovery, net_source, ll_source );
58 }
struct neighbour_discovery arp_discovery
ARP neighbour discovery protocol.
Definition: arp.c:103
static struct net_device * netdev
Definition: gdbudp.c:52
A network-layer protocol.
Definition: netdevice.h:64
int neighbour_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, struct neighbour_discovery *discovery, const void *net_source, const void *ll_source)
Transmit packet, determining link-layer address via neighbour discovery.
Definition: neighbour.c:299

References arp_discovery, neighbour_tx(), and netdev.

Referenced by ipv4_tx().

◆ arp_tx_request()

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.

61  {
63  struct io_buffer *iobuf;
64  struct arphdr *arphdr;
65  int rc;
66 
67  /* Allocate ARP packet */
68  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *arphdr ) +
69  ( 2 * ( MAX_LL_ADDR_LEN + MAX_NET_ADDR_LEN ) ) );
70  if ( ! iobuf )
71  return -ENOMEM;
72  iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
73 
74  /* Build up ARP request */
75  arphdr = iob_put ( iobuf, sizeof ( *arphdr ) );
81  memcpy ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
84  net_source, net_protocol->net_addr_len );
85  memset ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
88  net_dest, net_protocol->net_addr_len );
89 
90  /* Transmit ARP request */
91  if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
92  netdev->ll_broadcast, netdev->ll_addr ) ) != 0 ) {
93  DBGC ( netdev, "ARP %s %s %s could not transmit request: %s\n",
95  net_protocol->ntoa ( net_dest ), strerror ( rc ) );
96  return rc;
97  }
98 
99  return 0;
100 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Protocol name.
Definition: netdevice.h:66
#define iob_put(iobuf, len)
Definition: iobuf.h:120
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define DBGC(...)
Definition: compiler.h:505
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:389
uint8_t ar_hln
Link-layer address length.
Definition: if_arp.h:59
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
A link-layer protocol.
Definition: netdevice.h:114
uint16_t ar_hrd
Link-layer protocol.
Definition: if_arp.h:52
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
Definition: netdevice.h:36
#define ARPOP_REQUEST
ARP request.
Definition: if_arp.h:32
const char *(* ntoa)(const void *net_addr)
Transcribe network-layer address.
Definition: netdevice.h:94
static struct net_device * netdev
Definition: gdbudp.c:52
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
An ARP header.
Definition: if_arp.h:47
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint16_t ar_op
ARP opcode.
Definition: if_arp.h:63
uint16_t net_proto
Network-layer protocol.
Definition: netdevice.h:99
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
A network-layer protocol.
Definition: netdevice.h:64
#define iob_reserve(iobuf, len)
Definition: iobuf.h:67
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition: netdevice.c:1073
uint8_t net_addr_len
Network-layer address length.
Definition: netdevice.h:101
uint16_t ar_pro
Network-layer protocol.
Definition: if_arp.h:57
uint8_t ar_pln
Network-layer address length.
Definition: if_arp.h:61
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define MAX_NET_ADDR_LEN
Maximum length of a network-layer address.
Definition: netdevice.h:48
#define htons(value)
Definition: byteswap.h:135
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:372
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:33

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(), netdev, net_protocol::ntoa, rc, and strerror().

Referenced by ipoib_transmit(), and ipv4_gratuitous_arp().

Variable Documentation

◆ __net_protocol

struct net_protocol arp_protocol __net_protocol

AoE protocol.

AoE protocol.

AoE protocol.

FIP protocol.

Definition at line 56 of file aoe.c.

◆ arp_discovery

struct neighbour_discovery arp_discovery

ARP neighbour discovery protocol.

Definition at line 103 of file arp.c.

Referenced by arp_tx().