diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2024-11-24 03:33:22 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2025-02-25 12:24:26 +0100 |
commit | 640a6b3d6d46eff60f53ce9e50db0484df2f526c (patch) | |
tree | 0fcb80be3377a029d2b046781b5e9ab48f19c7bd | |
parent | 122e234f81d58ded3183fcfe61a34f0291f3a4f4 (diff) |
Add `-t` command line / config option
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | nDPId-test.c | 1 | ||||
-rw-r--r-- | nDPId.c | 13 | ||||
-rw-r--r-- | ndpid.conf.example | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/nDPId-test.c b/nDPId-test.c index e1d2bf9f5..c2f9c4cf4 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -1717,6 +1717,7 @@ int main(int argc, char ** argv) set_cmdarg_ull(&nDPIsrvd_options.max_write_buffers, 32); set_cmdarg_string(&nDPId_options.pcap_file_or_interface, argv[1]); + set_cmdarg_boolean(&nDPId_options.decode_tunnel, 1); set_cmdarg_boolean(&nDPId_options.enable_data_analysis, 1); set_cmdarg_ull(&nDPId_options.max_packets_per_flow_to_send, 5); #ifdef ENABLE_ZLIB @@ -484,6 +484,7 @@ static struct struct cmdarg config_file; struct cmdarg pcap_file_or_interface; struct cmdarg bpf_str; + struct cmdarg decode_tunnel; struct cmdarg pidfile; struct cmdarg user; struct cmdarg group; @@ -533,6 +534,7 @@ static struct } nDPId_options = {.config_file = CMDARG_STR(NULL), .pcap_file_or_interface = CMDARG_STR(NULL), .bpf_str = CMDARG_STR(NULL), + .decode_tunnel = CMDARG_BOOL(0), .pidfile = CMDARG_STR(nDPId_PIDFILE), .user = CMDARG_STR(DEFAULT_CHUSER), .group = CMDARG_STR(NULL), @@ -590,6 +592,7 @@ static struct .error_event_threshold_time = CMDARG_ULL(nDPId_ERROR_EVENT_THRESHOLD_TIME)}; struct confopt general_config_map[] = {CONFOPT("netif", &nDPId_options.pcap_file_or_interface), CONFOPT("bpf", &nDPId_options.bpf_str), + CONFOPT("decode-tunnel", &nDPId_options.decode_tunnel), CONFOPT("pidfile", &nDPId_options.pidfile), CONFOPT("user", &nDPId_options.user), CONFOPT("group", &nDPId_options.group), @@ -4242,7 +4245,7 @@ process_layer3_again: } /* process intermediate protocols i.e. layer4 tunnel protocols */ - if (flow_basic.l4_protocol == IPPROTO_GRE) + if (IS_CMDARG_SET(nDPId_options.decode_tunnel) != 0 && flow_basic.l4_protocol == IPPROTO_GRE) { uint32_t offset = is_valid_gre_tunnel(header, packet, l4_ptr); @@ -5456,6 +5459,7 @@ static void print_usage(char const * const arg0) static char const usage[] = "Usage: %s " "[-f config-file]\n" + "\t \t" "[-i pcap-file/interface] [-I] [-E] [-B bpf-filter]\n" "\t \t" "[-l] [-L logfile] [-c address] [-e]" @@ -5485,6 +5489,8 @@ static void print_usage(char const * const arg0) "\t \tDefault: disabled\n" "\t-B\tSet an optional PCAP filter string. (BPF format)\n" "\t \tDefault: empty\n" + "\t-t\tEnable tunnel decapsulation. Supported protocols: GRE\n" + "\t \tDefault: disabled\n" "\t-l\tLog all messages to stderr.\n" "\t \tDefault: disabled\n" "\t-L\tLog all messages to a log file.\n" @@ -5609,7 +5615,7 @@ static int nDPId_parse_options(int argc, char ** argv) { int opt; - while ((opt = getopt(argc, argv, "f:i:rIEB:lL:c:edp:u:g:R:P:C:J:S:a:U:Azo:vh")) != -1) + while ((opt = getopt(argc, argv, "f:i:rIEB:tlL:c:edp:u:g:R:P:C:J:S:a:U:Azo:vh")) != -1) { switch (opt) { @@ -5636,6 +5642,9 @@ static int nDPId_parse_options(int argc, char ** argv) case 'B': set_cmdarg_string(&nDPId_options.bpf_str, optarg); break; + case 't': + set_cmdarg_boolean(&nDPId_options.decode_tunnel, 1); + break; case 'l': enable_console_logger(); break; diff --git a/ndpid.conf.example b/ndpid.conf.example index 20de510af..1edb052ac 100644 --- a/ndpid.conf.example +++ b/ndpid.conf.example @@ -1,11 +1,15 @@ [general] # Set the network interface from which packets are captured and processed. # Leave it empty to let nDPId choose the default network interface. -#netif = eth0 +#netif = eth0 # Set a Berkeley Packet Filter. # This will work for libpcap as well as with PF_RING. -#bpf = udp or tcp +#bpf = udp or tcp + +# Decapsulate Layer4 tunnel protocols. +# Supported protocols: GRE +#decode-tunnel = true #pidfile = /tmp/ndpid.pid #user = nobody |