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)
 
 FILE_SECBOOT (PERMITTED)
 
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)
 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 32 of file arp.h.

◆ __arp_net_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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 
)
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
Return values
rcReturn status code

Definition at line 51 of file arp.h.

53  {
54 
55  return neighbour_tx ( iobuf, netdev, net_protocol, net_dest,
56  &arp_discovery, net_source );
57 }
struct neighbour_discovery arp_discovery
ARP neighbour discovery protocol.
Definition: arp.c:104
static struct net_device * netdev
Definition: gdbudp.c:52
A network-layer protocol.
Definition: netdevice.h:65
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)
Transmit packet, determining link-layer address via neighbour discovery.
Definition: neighbour.c:377

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 60 of file arp.c.

62  {
64  struct io_buffer *iobuf;
65  struct arphdr *arphdr;
66  int rc;
67 
68  /* Allocate ARP packet */
69  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *arphdr ) +
70  ( 2 * ( MAX_LL_ADDR_LEN + MAX_NET_ADDR_LEN ) ) );
71  if ( ! iobuf )
72  return -ENOMEM;
73  iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
74 
75  /* Build up ARP request */
76  arphdr = iob_put ( iobuf, sizeof ( *arphdr ) );
82  memcpy ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
85  net_source, net_protocol->net_addr_len );
86  memset ( iob_put ( iobuf, ll_protocol->ll_addr_len ),
89  net_dest, net_protocol->net_addr_len );
90 
91  /* Transmit ARP request */
92  if ( ( rc = net_tx ( iobuf, netdev, &arp_protocol,
93  netdev->ll_broadcast, netdev->ll_addr ) ) != 0 ) {
94  DBGC ( netdev, "ARP %s %s %s could not transmit request: %s\n",
96  net_protocol->ntoa ( net_dest ), strerror ( rc ) );
97  return rc;
98  }
99 
100  return 0;
101 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Protocol name.
Definition: netdevice.h:67
#define iob_put(iobuf, len)
Definition: iobuf.h:125
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:199
#define DBGC(...)
Definition: compiler.h:505
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:390
uint8_t ar_hln
Link-layer address length.
Definition: if_arp.h:60
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:131
A link-layer protocol.
Definition: netdevice.h:115
uint16_t ar_hrd
Link-layer protocol.
Definition: if_arp.h:53
#define ENOMEM
Not enough space.
Definition: errno.h:535
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:37
#define ARPOP_REQUEST
ARP request.
Definition: if_arp.h:33
const char *(* ntoa)(const void *net_addr)
Transcribe network-layer address.
Definition: netdevice.h:95
static struct net_device * netdev
Definition: gdbudp.c:52
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:46
An ARP header.
Definition: if_arp.h:48
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
uint16_t ar_op
ARP opcode.
Definition: if_arp.h:64
uint16_t net_proto
Network-layer protocol.
Definition: netdevice.h:100
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:195
A network-layer protocol.
Definition: netdevice.h:65
#define iob_reserve(iobuf, len)
Definition: iobuf.h:72
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:363
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:1074
uint8_t net_addr_len
Network-layer address length.
Definition: netdevice.h:102
uint16_t ar_pro
Network-layer protocol.
Definition: if_arp.h:58
uint8_t ar_pln
Network-layer address length.
Definition: if_arp.h:62
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:388
#define MAX_NET_ADDR_LEN
Maximum length of a network-layer address.
Definition: netdevice.h:49
#define htons(value)
Definition: byteswap.h:136
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:373
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:38

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 104 of file arp.c.

Referenced by arp_tx().