Reputation: 55
I'm trying to run this eBPF program found in Internet:
#include <linux/bpf.h>
#include <linux/ptrace.h>
#include <linux/tcp.h>
#include <linux/inet.h>
#include <linux/ip.h>
#include <bpf/bpf_helpers.h>
SEC("filter/tcp_ingress")
int capture_tcp_packets(struct __sk_buff *skb) {
struct ethhdr *eth = bpf_hdr_pointer(skb);
struct iphdr *ip = (struct iphdr *)(eth + 1);
if (ip->protocol == IPPROTO_TCP) {
// You can add code here to log or process TCP packets.
// E.g., extract source and destination IP addresses
}
return 0;
}
char _license[] SEC("license") = "GPL";
The problem is that when I try to compile with clang compiler, I get lots of fatal error relate to linux-headers:
<headers.h> not found
I tried to manually change the location of the headers.h
file to make them available for the clang compiler (under the /usr/include
path). Apparently it works, but since I have lots of types.h
headers under my /usr/* folders and I don't know which one to copy, the result is the error:
unknown type name unsigned_u64
Or something similar.
Upvotes: 0
Views: 46