-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.c
More file actions
38 lines (30 loc) · 816 Bytes
/
loader.c
File metadata and controls
38 lines (30 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <linux/bpf.h>
#include "libbpf.h"
#include "bpf_load.h"
#include <unistd.h>
#include <arpa/inet.h>
int main(int argc, char **argv)
{
char filename[256];
FILE *f;
int i, sock;
/* Usage: <binary> kern_dot_o_file bpf_prog_name */
if (argc < 2) {
printf("Usage: %s kern_dot_o_file bpf_prog_name\n", argv[0]);
return 1;
}
snprintf(filename, sizeof(filename), "%s", argv[1]);
struct bpf_insn * prog;
int prog_len;
if (get_prog(filename, argv[2], strlen(argv[2]),
&prog_len, &prog)) {
printf("Failed to extract a program from the provided .o filename %s"
" and BPF program name %s\n", argv[1], argv[2]);
return 1;
}
printf("Got program with a length %d \n", prog_len);
return 0;
}