- memcpy(&hdr_arp->ether_hdr.d_addr.addr_bytes, &mac_bcast, 6);
- memcpy(&hdr_arp->ether_hdr.s_addr.addr_bytes, src_mac, 6);
- hdr_arp->ether_hdr.ether_type = ETYPE_ARP;
- hdr_arp->arp.htype = 0x100,
- hdr_arp->arp.ptype = 0x0008;
- hdr_arp->arp.hlen = 6;
- hdr_arp->arp.plen = 4;
- hdr_arp->arp.oper = 0x100;
- hdr_arp->arp.data.spa = ip_src;
- hdr_arp->arp.data.tpa = ip_dst;
- memset(&hdr_arp->arp.data.tha, 0, sizeof(prox_rte_ether_addr));
- memcpy(&hdr_arp->arp.data.sha, src_mac, sizeof(prox_rte_ether_addr));
+ if (vlan) {
+ ether_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *);
+ vlan_hdr = (prox_rte_vlan_hdr *)(ether_hdr + 1);
+ arp = (struct my_arp_t *)(vlan_hdr + 1);
+ ether_hdr->ether_type = ETYPE_VLAN;
+ vlan_hdr->eth_proto = ETYPE_ARP;
+ vlan_hdr->vlan_tci = rte_cpu_to_be_16(vlan);
+ rte_pktmbuf_pkt_len(mbuf) = 42 + sizeof(prox_rte_vlan_hdr);
+ rte_pktmbuf_data_len(mbuf) = 42 + sizeof(prox_rte_vlan_hdr);
+ } else {
+ ether_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *);
+ arp = (struct my_arp_t *)(ether_hdr + 1);
+ ether_hdr->ether_type = ETYPE_ARP;
+ rte_pktmbuf_pkt_len(mbuf) = 42;
+ rte_pktmbuf_data_len(mbuf) = 42;
+ }
+
+ memcpy(ðer_hdr->d_addr.addr_bytes, &mac_bcast, 6);
+ memcpy(ðer_hdr->s_addr.addr_bytes, src_mac, 6);
+ arp->htype = 0x100,
+ arp->ptype = 0x0008;
+ arp->hlen = 6;
+ arp->plen = 4;
+ arp->oper = 0x100;
+ arp->data.spa = ip_src;
+ arp->data.tpa = ip_dst;
+ memset(&arp->data.tha, 0, sizeof(prox_rte_ether_addr));
+ memcpy(&arp->data.sha, src_mac, sizeof(prox_rte_ether_addr));