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_mbuf *mbuf, const struct ether_addr *mac)
13 struct ether_hdr *eth_hdr;
16 if (mbuf->buf_len < RARP_PKT_SIZE)
19 /* Ethernet header. */
20 eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
21 memset(eth_hdr->d_addr.addr_bytes, 0xff, ETHER_ADDR_LEN);
22 ether_addr_copy(mac, ð_hdr->s_addr);
23 eth_hdr->ether_type = htons(ETHER_TYPE_RARP);
26 rarp = (struct arp_hdr *)(eth_hdr + 1);
27 rarp->arp_hrd = htons(ARP_HRD_ETHER);
28 rarp->arp_pro = htons(ETHER_TYPE_IPv4);
29 rarp->arp_hln = ETHER_ADDR_LEN;
31 rarp->arp_op = htons(ARP_OP_REVREQUEST);
33 ether_addr_copy(mac, &rarp->arp_data.arp_sha);
34 ether_addr_copy(mac, &rarp->arp_data.arp_tha);
35 memset(&rarp->arp_data.arp_sip, 0x00, 4);
36 memset(&rarp->arp_data.arp_tip, 0x00, 4);
38 mbuf->data_len = RARP_PKT_SIZE;
39 mbuf->pkt_len = RARP_PKT_SIZE;