iPXE
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.
#define __arp_net_protocol   __table_entry ( ARP_NET_PROTOCOLS, 01 )
 Declare an ARP protocol.

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.
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.

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.

32#define ARP_NET_PROTOCOLS \
33 __table ( struct arp_net_protocol, "arp_net_protocols" )

Referenced by arp_find_protocol().

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

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:53
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
A network-layer protocol.
Definition netdevice.h:65

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

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 {
63 struct ll_protocol *ll_protocol = netdev->ll_protocol;
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;
74
75 /* Build up ARP request */
76 arphdr = iob_put ( iobuf, sizeof ( *arphdr ) );
83 netdev->ll_addr, ll_protocol->ll_addr_len );
85 net_source, net_protocol->net_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",
95 netdev->name, net_protocol->name,
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:3
#define DBGC(...)
Definition compiler.h:505
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ARPOP_REQUEST
ARP request.
Definition if_arp.h:33
#define htons(value)
Definition byteswap.h:136
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
#define iob_put(iobuf, len)
Definition iobuf.h:125
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
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
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition netdevice.h:46
#define MAX_NET_ADDR_LEN
Maximum length of a network-layer address.
Definition netdevice.h:49
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
Definition netdevice.h:37
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
An ARP header.
Definition if_arp.h:48
uint8_t ar_hln
Link-layer address length.
Definition if_arp.h:60
uint16_t ar_op
ARP opcode.
Definition if_arp.h:64
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
uint16_t ar_hrd
Link-layer protocol.
Definition if_arp.h:53
A persistent I/O buffer.
Definition iobuf.h:38
A link-layer protocol.
Definition netdevice.h:115
uint8_t ll_addr_len
Link-layer address length.
Definition netdevice.h:199
uint16_t ll_proto
Link-layer protocol.
Definition netdevice.h:195
const char * name
Protocol name.
Definition netdevice.h:67
uint16_t net_proto
Network-layer protocol.
Definition netdevice.h:100
uint8_t net_addr_len
Network-layer address length.
Definition netdevice.h:102
const char *(* ntoa)(const void *net_addr)
Transcribe network-layer address.
Definition netdevice.h:95

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, ll_protocol::ll_addr_len, ll_protocol::ll_proto, MAX_LL_ADDR_LEN, MAX_LL_HEADER_LEN, MAX_NET_ADDR_LEN, memcpy(), memset(), net_protocol::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
extern

AoE protocol.

AoE protocol.

AoE protocol.

FIP protocol.

Definition at line 56 of file aoe.c.

◆ arp_discovery

struct neighbour_discovery arp_discovery
extern

ARP neighbour discovery protocol.

Definition at line 104 of file arp.c.

104 {
105 .name = "ARP",
106 .tx_request = arp_tx_request,
107};
int arp_tx_request(struct net_device *netdev, struct net_protocol *net_protocol, const void *net_dest, const void *net_source)
Transmit ARP request.
Definition arp.c:60

Referenced by arp_tx().