xref: /dpdk/lib/net/rte_arp.h (revision fba9875559906e04eaeb74532f4cfd51194259a2)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2013 6WIND S.A.
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_ARP_H_
699a2dd95SBruce Richardson #define _RTE_ARP_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file
1099a2dd95SBruce Richardson  *
1199a2dd95SBruce Richardson  * ARP-related defines
1299a2dd95SBruce Richardson  */
1399a2dd95SBruce Richardson 
1499a2dd95SBruce Richardson #include <stdint.h>
1599a2dd95SBruce Richardson #include <rte_ether.h>
1699a2dd95SBruce Richardson 
1799a2dd95SBruce Richardson #ifdef __cplusplus
1899a2dd95SBruce Richardson extern "C" {
1999a2dd95SBruce Richardson #endif
2099a2dd95SBruce Richardson 
2199a2dd95SBruce Richardson /**
2299a2dd95SBruce Richardson  * ARP header IPv4 payload.
2399a2dd95SBruce Richardson  */
24*fba98755SAndre Muezerie struct __rte_aligned(2) __rte_packed_begin rte_arp_ipv4 {
2599a2dd95SBruce Richardson 	struct rte_ether_addr arp_sha;  /**< sender hardware address */
267f9cf804SThomas Monjalon 	rte_be32_t            arp_sip;  /**< sender IP address */
2799a2dd95SBruce Richardson 	struct rte_ether_addr arp_tha;  /**< target hardware address */
287f9cf804SThomas Monjalon 	rte_be32_t            arp_tip;  /**< target IP address */
29*fba98755SAndre Muezerie } __rte_packed_end;
3099a2dd95SBruce Richardson 
3199a2dd95SBruce Richardson /**
3299a2dd95SBruce Richardson  * ARP header.
3399a2dd95SBruce Richardson  */
34*fba98755SAndre Muezerie struct __rte_aligned(2) __rte_packed_begin rte_arp_hdr {
357f9cf804SThomas Monjalon 	rte_be16_t arp_hardware; /**< format of hardware address */
367f9cf804SThomas Monjalon #define RTE_ARP_HRD_ETHER     1  /**< ARP Ethernet address format */
3799a2dd95SBruce Richardson 
387f9cf804SThomas Monjalon 	rte_be16_t arp_protocol; /**< format of protocol address */
397f9cf804SThomas Monjalon 	uint8_t    arp_hlen;     /**< length of hardware address */
407f9cf804SThomas Monjalon 	uint8_t    arp_plen;     /**< length of protocol address */
417f9cf804SThomas Monjalon 	rte_be16_t arp_opcode;   /**< ARP opcode (command) */
427f9cf804SThomas Monjalon #define	RTE_ARP_OP_REQUEST    1  /**< request to resolve address */
437f9cf804SThomas Monjalon #define	RTE_ARP_OP_REPLY      2  /**< response to previous request */
447f9cf804SThomas Monjalon #define	RTE_ARP_OP_REVREQUEST 3  /**< request proto addr given hardware */
457f9cf804SThomas Monjalon #define	RTE_ARP_OP_REVREPLY   4  /**< response giving protocol address */
467f9cf804SThomas Monjalon #define	RTE_ARP_OP_INVREQUEST 8  /**< request to identify peer */
477f9cf804SThomas Monjalon #define	RTE_ARP_OP_INVREPLY   9  /**< response identifying peer */
4899a2dd95SBruce Richardson 
4999a2dd95SBruce Richardson 	struct rte_arp_ipv4 arp_data;
50*fba98755SAndre Muezerie } __rte_packed_end;
5199a2dd95SBruce Richardson 
5299a2dd95SBruce Richardson /**
5399a2dd95SBruce Richardson  * Make a RARP packet based on MAC addr.
5499a2dd95SBruce Richardson  *
5599a2dd95SBruce Richardson  * @param mpool
5699a2dd95SBruce Richardson  *   Pointer to the rte_mempool
5799a2dd95SBruce Richardson  * @param mac
5899a2dd95SBruce Richardson  *   Pointer to the MAC addr
5999a2dd95SBruce Richardson  *
6099a2dd95SBruce Richardson  * @return
6199a2dd95SBruce Richardson  *   - RARP packet pointer on success, or NULL on error
6299a2dd95SBruce Richardson  */
6399a2dd95SBruce Richardson struct rte_mbuf *
6499a2dd95SBruce Richardson rte_net_make_rarp_packet(struct rte_mempool *mpool,
6599a2dd95SBruce Richardson 		const struct rte_ether_addr *mac);
6699a2dd95SBruce Richardson 
6799a2dd95SBruce Richardson #ifdef __cplusplus
6899a2dd95SBruce Richardson }
6999a2dd95SBruce Richardson #endif
7099a2dd95SBruce Richardson 
7199a2dd95SBruce Richardson #endif /* _RTE_ARP_H_ */
72