1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
9 #define RARP_PKT_SIZE 64
11 rte_net_make_rarp_packet(struct rte_mempool *mpool,
12 const struct rte_ether_addr *mac)
14 struct rte_ether_hdr *eth_hdr;
15 struct rte_arp_hdr *rarp;
16 struct rte_mbuf *mbuf;
21 mbuf = rte_pktmbuf_alloc(mpool);
25 eth_hdr = (struct rte_ether_hdr *)
26 rte_pktmbuf_append(mbuf, RARP_PKT_SIZE);
27 if (eth_hdr == NULL) {
28 rte_pktmbuf_free(mbuf);
32 /* Ethernet header. */
33 memset(eth_hdr->d_addr.addr_bytes, 0xff, RTE_ETHER_ADDR_LEN);
34 rte_ether_addr_copy(mac, ð_hdr->s_addr);
35 eth_hdr->ether_type = htons(RTE_ETHER_TYPE_RARP);
38 rarp = (struct rte_arp_hdr *)(eth_hdr + 1);
39 rarp->arp_hardware = htons(RTE_ARP_HRD_ETHER);
40 rarp->arp_protocol = htons(RTE_ETHER_TYPE_IPV4);
41 rarp->arp_hlen = RTE_ETHER_ADDR_LEN;
43 rarp->arp_opcode = htons(RTE_ARP_OP_REVREQUEST);
45 rte_ether_addr_copy(mac, &rarp->arp_data.arp_sha);
46 rte_ether_addr_copy(mac, &rarp->arp_data.arp_tha);
47 memset(&rarp->arp_data.arp_sip, 0x00, 4);
48 memset(&rarp->arp_data.arp_tip, 0x00, 4);