first commit

This commit is contained in:
Rodrigo Bertoldo de Sousa Martins committed 2026-09-13 20:49:33 -03:00
commit 01d7cb1a80
34 files changed
+5723

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#include <stdio.h>
#include <bpf/libbpf.h>
#include "bridge_xdp.h"
int main(int argc, char **argv)
{
if (argc != 2) {
printf("Uso: %s <interface>\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;
}