1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Intel Corporation 3 */ 4 5 /* 6 * eBPF program sample. 7 * Accepts pointer to struct rte_mbuf as an input parameter. 8 * Dump the mbuf into stdout if it is an ARP packet (aka tcpdump 'arp'). 9 * 10 * To compile on x86: 11 * clang -O2 -U __GNUC__ -I${RTE_SDK}/${RTE_TARGET}/include \ 12 * -target bpf -Wno-int-to-void-pointer-cast -c t3.c 13 * 14 * To compile on ARM: 15 * clang -O2 -I/usr/include/aarch64-linux-gnu \ 16 * -I${RTE_SDK}/${RTE_TARGET}/include -target bpf \ 17 * -Wno-int-to-void-pointer-cast -c t3.c 18 */ 19 20 #include <stdint.h> 21 #include <stddef.h> 22 #include <stdio.h> 23 #include <net/ethernet.h> 24 #include <rte_config.h> 25 #include "mbuf.h" 26 #include <arpa/inet.h> 27 28 extern void rte_pktmbuf_dump(FILE *, const struct rte_mbuf *, unsigned int); 29 30 uint64_t 31 entry(const void *pkt) 32 { 33 const struct rte_mbuf *mb; 34 const struct ether_header *eth; 35 36 mb = pkt; 37 eth = rte_pktmbuf_mtod(mb, const struct ether_header *); 38 39 if (eth->ether_type == htons(ETHERTYPE_ARP)) 40 rte_pktmbuf_dump(stdout, mb, 64); 41 42 return 1; 43 } 44