net: use SPDX tags
[dpdk.git] / lib / librte_net / rte_arp.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2013 6WIND S.A.
3  */
4
5 #ifndef _RTE_ARP_H_
6 #define _RTE_ARP_H_
7
8 /**
9  * @file
10  *
11  * ARP-related defines
12  */
13
14 #include <stdint.h>
15 #include <rte_ether.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /**
22  * ARP header IPv4 payload.
23  */
24 struct arp_ipv4 {
25         struct ether_addr arp_sha;  /**< sender hardware address */
26         uint32_t          arp_sip;  /**< sender IP address */
27         struct ether_addr arp_tha;  /**< target hardware address */
28         uint32_t          arp_tip;  /**< target IP address */
29 } __attribute__((__packed__));
30
31 /**
32  * ARP header.
33  */
34 struct arp_hdr {
35         uint16_t arp_hrd;    /* format of hardware address */
36 #define ARP_HRD_ETHER     1  /* ARP Ethernet address format */
37
38         uint16_t arp_pro;    /* format of protocol address */
39         uint8_t  arp_hln;    /* length of hardware address */
40         uint8_t  arp_pln;    /* length of protocol address */
41         uint16_t arp_op;     /* ARP opcode (command) */
42 #define ARP_OP_REQUEST    1 /* request to resolve address */
43 #define ARP_OP_REPLY      2 /* response to previous request */
44 #define ARP_OP_REVREQUEST 3 /* request proto addr given hardware */
45 #define ARP_OP_REVREPLY   4 /* response giving protocol address */
46 #define ARP_OP_INVREQUEST 8 /* request to identify peer */
47 #define ARP_OP_INVREPLY   9 /* response identifying peer */
48
49         struct arp_ipv4 arp_data;
50 } __attribute__((__packed__));
51
52 /**
53  * @warning
54  * @b EXPERIMENTAL: this API may change without prior notice
55  *
56  * Make a RARP packet based on MAC addr.
57  *
58  * @param mpool
59  *   Pointer to the rte_mempool
60  * @param mac
61  *   Pointer to the MAC addr
62  *
63  * @return
64  *   - RARP packet pointer on success, or NULL on error
65  */
66 struct rte_mbuf * __rte_experimental
67 rte_net_make_rarp_packet(struct rte_mempool *mpool,
68                 const struct ether_addr *mac);
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 #endif /* _RTE_ARP_H_ */