#include #include #include "bridge_xdp.h" int main(int argc, char **argv) { if (argc != 2) { printf("Uso: %s \n", argv[0]); return 1; } // Carregar programa XDP struct bpf_object *obj = bpf_object__open("bridge_xdp.o"); if (!obj) { printf("Erro ao abrir objeto BPF\n"); return 1; } if (bpf_object__load(obj)) { printf("Erro ao carregar objeto BPF\n"); return 1; } // Anexar à interface int prog_fd = bpf_program__fd(bpf_object__find_program_by_name(obj, "bridge_filter")); if (bpf_xdp_attach(if_nametoindex(argv[1]), prog_fd, XDP_FLAGS_SKB_MODE, NULL) != 0) { printf("Erro ao anexar XDP\n"); return 1; } printf("XDP anexado com sucesso à interface %s\n", argv[1]); return 0; }