Skip to content

Commit

Permalink
Add -f <bpf> to ftflow. Update FT libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Sep 3, 2024
1 parent 152c540 commit 970e2c5
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions userland/examples_ft/ftflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ void print_help(void) {
printf("-h Print this help\n");
printf("-i <device> Device name\n");
printf("-7 Enable L7 protocol detection (nDPI)\n");
printf("-f <bpf> Capture filter (BPF)\n");
printf("-F <file> Load filtering/shunting rules from file\n");
printf("-p <file> Load nDPI custom protocols from file\n");
printf("-c <file> Load nDPI categories by host from file\n");
Expand Down Expand Up @@ -419,8 +420,9 @@ int main(int argc, char* argv[]) {
packet_direction direction = rx_and_tx_direction;
pthread_t time_thread;
u_int8_t ignore_hw_hash = 0;
char *filter = NULL;

while ((c = getopt(argc,argv,"c:dEg:hHi:p:qvF:s:S:tV7")) != '?') {
while ((c = getopt(argc,argv,"c:dEf:g:hHi:p:qvF:s:S:tV7")) != '?') {
if ((c == 255) || (c == -1)) break;

switch(c) {
Expand All @@ -437,6 +439,9 @@ int main(int argc, char* argv[]) {
enable_l7_extra = 1;
break;
#endif
case 'f':
filter = strdup(optarg);
break;
case 'g':
bind_core = atoi(optarg);
break;
Expand Down Expand Up @@ -556,7 +561,7 @@ int main(int argc, char* argv[]) {

promisc = 1;

if (promisc) flags |= PF_RING_PROMISC;
if (promisc) flags |= PF_RING_PROMISC;
if (!time_pulse) flags |= PF_RING_TIMESTAMP; /* needed for flow processing */

pd = pfring_open(device, snaplen, flags);
Expand Down Expand Up @@ -584,6 +589,14 @@ int main(int argc, char* argv[]) {
if ((rc = pfring_set_socket_mode(pd, recv_only_mode)) != 0)
fprintf(stderr, "pfring_set_socket_mode returned [rc=%d]\n", rc);

if (filter != NULL) {
rc = pfring_set_bpf_filter(pd, filter);
if (rc != 0)
fprintf(stderr, "pfring_set_bpf_filter(%s) returned %d\n", filter, rc);
else if (!quiet)
printf("Successfully set BPF filter '%s'\n", filter);
}

signal(SIGINT, sigproc);
signal(SIGTERM, sigproc);

Expand Down
Binary file modified userland/lib/libs/libpfring_ft_x86_64.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64.so
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_core-avx2.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_core-avx2_dl.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_corei7-avx.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_corei7-avx_dl.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_corei7.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_corei7_dl.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_dl.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_ft_x86_64_dl.so
Binary file not shown.
2 changes: 1 addition & 1 deletion userland/lib/pfring_ft.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
extern "C" {
#endif

#define FT_API_VERSION 77
#define FT_API_VERSION 83

typedef void pfring_ft_table;
typedef void pfring_ft_list;
Expand Down

0 comments on commit 970e2c5

Please sign in to comment.