Skip to content

Commit db8778a

Browse files
committed
Merge branch 'dev' into config2
2 parents 5254d8e + 5eb468d commit db8778a

File tree

167 files changed

+553
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+553
-191
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ jobs:
8989
nBPF: [""]
9090
lto_gold_linker: [""]
9191
include:
92-
- compiler: "gcc-7" # "Oldest" gcc easily available
92+
- compiler: "gcc-4.9" # "Oldest" gcc easily available. To simulate RHEL7
9393
os: ubuntu-20.04
9494
arch: "x86_64"
9595
gcrypt: ""
9696
pcre: "--with-pcre2"
9797
maxminddb: "--with-maxminddb"
9898
msan: "--with-sanitizer"
9999
nBPF: ""
100-
- compiler: "gcc-12" # "Newest" gcc easily available
100+
- compiler: "gcc-13" # "Newest" gcc easily available
101101
os: ubuntu-22.04
102102
arch: "x86_64"
103103
gcrypt: ""
@@ -114,9 +114,9 @@ jobs:
114114
maxminddb: "--with-maxminddb"
115115
msan: "--with-sanitizer"
116116
nBPF: ""
117-
- compiler: "clang-14" # "Newest" clang easily available
118-
ar: "llvm-ar-14"
119-
ranlib: "llvm-ranlib-14"
117+
- compiler: "clang-17" # "Newest" clang easily available
118+
ar: "llvm-ar-17"
119+
ranlib: "llvm-ranlib-17"
120120
os: ubuntu-22.04
121121
arch: "x86_64"
122122
gcrypt: ""
@@ -141,7 +141,7 @@ jobs:
141141
maxminddb: "--with-maxminddb"
142142
msan: "--with-sanitizer"
143143
nBPF: "nBPF"
144-
- compiler: "clang-14"
144+
- compiler: "clang-17"
145145
os: ubuntu-22.04
146146
arch: "x86_64"
147147
gcrypt: ""
@@ -226,9 +226,22 @@ jobs:
226226
make
227227
cd -
228228
- name: Setup Ubuntu specified compiler
229-
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && ! startsWith(matrix.compiler, 'cc')
230-
run: |
229+
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && ! startsWith(matrix.compiler, 'cc') && ! startsWith(matrix.compiler, 'clang-17')
230+
run: |
231+
#For gcc-4.9 (on ubuntu-20.04)
232+
echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list
233+
echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" | sudo tee -a /etc/apt/sources.list
234+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
235+
#For gcc-13 (on ubuntu-22.04)
236+
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
237+
sudo apt-get update
231238
sudo apt-get install ${{ matrix.compiler }}
239+
- name: Setup Ubuntu specified (newest) compiler
240+
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.compiler, 'clang-17')
241+
run: |
242+
wget https://apt.llvm.org/llvm.sh
243+
chmod u+x llvm.sh
244+
sudo ./llvm.sh 17
232245
- name: Install Windows msys2 prerequisites
233246
if: startsWith(matrix.os, 'windows')
234247
uses: msys2/setup-msys2@v2

configure.ac

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = se
6464
])
6565

6666
AS_IF([test "${with_sanitizer+set}" = set],[
67-
NDPI_CFLAGS="${NDPI_CFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak -fno-omit-frame-pointer"
68-
NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak"
67+
NDPI_CFLAGS="${NDPI_CFLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak -fno-omit-frame-pointer"
68+
NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=leak"
69+
#Sanitizers should work on any compilers that we support (or that we test on CI, at least)
70+
#Exception: "-fsanitize=alignment" is not supported in gcc 4.9
71+
AX_CHECK_COMPILE_FLAG([-fno-sanitize=alignment], [
72+
NDPI_CFLAGS="${NDPI_CFLAGS} -fno-sanitize=alignment"
73+
NDPI_LDFLAGS="${NDPI_LDFLAGS} -fno-sanitize=alignment"
74+
])
6975
])
7076

7177
AS_IF([test "${with_thread_sanitizer+set}" = set],[

doc/protocols.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,34 @@ References: `Protocol Specs: <https://uftp-multicast.sourceforge.net/protocol.tx
377377
OpenFlow protocol is a network protocol closely associated with Software-Defined Networking (SDN).
378378

379379
References: `Protocol Specs: <https://opennetworking.org/wp-content/uploads/2014/10/openflow-switch-v1.5.1.pdf>`_.
380+
381+
382+
.. _Proto 375:
383+
384+
`NDPI_PROTOCOL_JSON_RPC`
385+
======================
386+
JSON-RPC is a remote procedure call protocol encoded in JSON.
387+
388+
References: `Protocol Specs: <https://www.jsonrpc.org/specification>`_.
389+
390+
391+
.. _Proto 376:
392+
393+
`NDPI_PROTOCOL_WEBDAV`
394+
======================
395+
WebDAV is a set of extensions to the HTTP protocol that allows WebDAV clients to collaboratively edit and manage files on remote Web servers.
396+
397+
References: `RFC4918: <https://datatracker.ietf.org/doc/html/rfc4918>`_.
398+
399+
Notes:
400+
401+
- WebDAV is almost always encrypted, i.e. transported over TLS.
402+
403+
404+
.. _Proto 377:
405+
406+
`NDPI_PROTOCOL_APACHE_KAFKA`
407+
======================
408+
Apache Kafka is a distributed event store and stream-processing platform.
409+
410+
References: `Official site <https://kafka.apache.org>`_ and `Github <https://github.com/apache/kafka>`_.

example/ndpiSimpleIntegration.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ static void ndpi_flow_info_freer(void * const node)
226226
static void free_workflow(struct nDPI_workflow ** const workflow)
227227
{
228228
struct nDPI_workflow * const w = *workflow;
229+
size_t i;
229230

230231
if (w == NULL) {
231232
return;
@@ -239,7 +240,7 @@ static void free_workflow(struct nDPI_workflow ** const workflow)
239240
if (w->ndpi_struct != NULL) {
240241
ndpi_exit_detection_module(w->ndpi_struct);
241242
}
242-
for(size_t i = 0; i < w->max_active_flows; i++) {
243+
for(i = 0; i < w->max_active_flows; i++) {
243244
ndpi_tdestroy(w->ndpi_flows_active[i], ndpi_flow_info_freer);
244245
}
245246
ndpi_free(w->ndpi_flows_active);
@@ -268,6 +269,7 @@ static int setup_reader_threads(char const * const file_or_device)
268269
{
269270
char * file_or_default_device;
270271
char pcap_error_buffer[PCAP_ERRBUF_SIZE];
272+
int i;
271273

272274
if (reader_thread_count > MAX_READER_THREADS) {
273275
return 1;
@@ -286,7 +288,7 @@ static int setup_reader_threads(char const * const file_or_device)
286288
}
287289
}
288290

289-
for (int i = 0; i < reader_thread_count; ++i) {
291+
for (i = 0; i < reader_thread_count; ++i) {
290292
reader_threads[i].workflow = init_workflow(file_or_default_device);
291293
if (reader_threads[i].workflow == NULL)
292294
{
@@ -496,8 +498,10 @@ static int ndpi_workflow_node_cmp(void const * const A, void const * const B) {
496498

497499
static void check_for_idle_flows(struct nDPI_workflow * const workflow)
498500
{
501+
size_t idle_scan_index;
502+
499503
if (workflow->last_idle_scan_time + IDLE_SCAN_PERIOD < workflow->last_time) {
500-
for (size_t idle_scan_index = 0; idle_scan_index < workflow->max_active_flows; ++idle_scan_index) {
504+
for (idle_scan_index = 0; idle_scan_index < workflow->max_active_flows; ++idle_scan_index) {
501505
ndpi_twalk(workflow->ndpi_flows_active[idle_scan_index], ndpi_idle_scan_walker, workflow);
502506

503507
while (workflow->cur_idle_flows > 0) {
@@ -526,7 +530,7 @@ static void ndpi_process_packet(uint8_t * const args,
526530
struct nDPI_reader_thread * const reader_thread =
527531
(struct nDPI_reader_thread *)args;
528532
struct nDPI_workflow * workflow;
529-
struct nDPI_flow_info flow = {};
533+
struct nDPI_flow_info flow;
530534

531535
size_t hashed_index;
532536
void * tree_result;
@@ -547,6 +551,8 @@ static void ndpi_process_packet(uint8_t * const args,
547551
uint16_t type;
548552
uint32_t thread_index = INITIAL_THREAD_HASH; // generated with `dd if=/dev/random bs=1024 count=1 |& hd'
549553

554+
memset(&flow, '\0', sizeof(flow));
555+
550556
if (reader_thread == NULL) {
551557
return;
552558
}
@@ -1024,7 +1030,9 @@ static void * processing_thread(void * const ndpi_thread_arg)
10241030

10251031
static int processing_threads_error_or_eof(void)
10261032
{
1027-
for (int i = 0; i < reader_thread_count; ++i) {
1033+
int i;
1034+
1035+
for (i = 0; i < reader_thread_count; ++i) {
10281036
if (__sync_fetch_and_add(&reader_threads[i].workflow->error_or_eof, 0) == 0) {
10291037
return 0;
10301038
}
@@ -1034,6 +1042,8 @@ static int processing_threads_error_or_eof(void)
10341042

10351043
static int start_reader_threads(void)
10361044
{
1045+
int i;
1046+
10371047
#ifndef WIN32
10381048
sigset_t thread_signal_set, old_signal_set;
10391049

@@ -1046,7 +1056,7 @@ static int start_reader_threads(void)
10461056
}
10471057
#endif
10481058

1049-
for (int i = 0; i < reader_thread_count; ++i) {
1059+
for (i = 0; i < reader_thread_count; ++i) {
10501060
reader_threads[i].array_index = i;
10511061

10521062
if (reader_threads[i].workflow == NULL) {
@@ -1072,20 +1082,21 @@ static int start_reader_threads(void)
10721082

10731083
static int stop_reader_threads(void)
10741084
{
1085+
int i;
10751086
unsigned long long int total_packets_captured = 0;
10761087
unsigned long long int total_packets_processed = 0;
10771088
unsigned long long int total_l4_data_len = 0;
10781089
unsigned long long int total_flows_captured = 0;
10791090
unsigned long long int total_flows_idle = 0;
10801091
unsigned long long int total_flows_detected = 0;
10811092

1082-
for (int i = 0; i < reader_thread_count; ++i) {
1093+
for (i = 0; i < reader_thread_count; ++i) {
10831094
break_pcap_loop(&reader_threads[i]);
10841095
}
10851096

10861097
printf("------------------------------------ Stopping reader threads\n");
10871098

1088-
for (int i = 0; i < reader_thread_count; ++i) {
1099+
for (i = 0; i < reader_thread_count; ++i) {
10891100
if (reader_threads[i].workflow == NULL) {
10901101
continue;
10911102
}
@@ -1110,7 +1121,7 @@ static int stop_reader_threads(void)
11101121
/* total packets captured: same value for all threads as packet2thread distribution happens later */
11111122
total_packets_captured = reader_threads[0].workflow->packets_captured;
11121123

1113-
for (int i = 0; i < reader_thread_count; ++i) {
1124+
for (i = 0; i < reader_thread_count; ++i) {
11141125
if (reader_threads[i].workflow == NULL) {
11151126
continue;
11161127
}

fuzz/dictionary.dict

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@
8181
"RPC_CONNECT"
8282
"RPC_IN_DATA"
8383
"RPC_OUT_DATA"
84+
"MKCOL"
85+
"MOVE"
86+
"COPY"
87+
"LOCK"
88+
"UNLOCK"
89+
"PROPFIND"
90+
"PROPPATCH"
8491

8592
#HTTP payload signatures
8693

src/include/ndpi_protocol_ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ typedef enum {
403403
NDPI_PROTOCOL_HISLIP = 372,
404404
NDPI_PROTOCOL_UFTP = 373,
405405
NDPI_PROTOCOL_OPENFLOW = 374,
406+
NDPI_PROTOCOL_JSON_RPC = 375,
407+
NDPI_PROTOCOL_WEBDAV = 376,
408+
NDPI_PROTOCOL_APACHE_KAFKA = 377,
406409

407410
#ifdef CUSTOM_NDPI_PROTOCOLS
408411
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"

src/include/ndpi_typedefs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,13 @@ typedef enum {
680680
NDPI_HTTP_METHOD_RPC_CONNECT,
681681
NDPI_HTTP_METHOD_RPC_IN_DATA,
682682
NDPI_HTTP_METHOD_RPC_OUT_DATA,
683+
NDPI_HTTP_METHOD_MKCOL,
684+
NDPI_HTTP_METHOD_MOVE,
685+
NDPI_HTTP_METHOD_COPY,
686+
NDPI_HTTP_METHOD_LOCK,
687+
NDPI_HTTP_METHOD_UNLOCK,
688+
NDPI_HTTP_METHOD_PROPFIND,
689+
NDPI_HTTP_METHOD_PROPPATCH,
683690
} ndpi_http_method;
684691

685692
typedef enum {

src/lib/ndpi_main.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,8 @@ int ndpi_init_empty_app_protocol(ndpi_protocol_match const * const hostname_list
813813
return 0;
814814
}
815815

816+
/* ******************************************************************** */
817+
816818
int ndpi_init_app_protocol(struct ndpi_detection_module_struct *ndpi_str,
817819
ndpi_protocol_match const * const match) {
818820
ndpi_port_range ports_a[MAX_DEFAULT_PORTS], ports_b[MAX_DEFAULT_PORTS];
@@ -1056,6 +1058,7 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
10561058
NDPI_PROTOCOL_MPEGDASH,
10571059
NDPI_PROTOCOL_RTSP,
10581060
NDPI_PROTOCOL_APACHE_THRIFT,
1061+
NDPI_PROTOCOL_JSON_RPC,
10591062
NDPI_PROTOCOL_MATCHED_BY_CONTENT,
10601063
NDPI_PROTOCOL_NO_MORE_SUBPROTOCOLS); /* NDPI_PROTOCOL_HTTP can have (content-matched) subprotocols */
10611064
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_MDNS,
@@ -2166,13 +2169,25 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
21662169
ndpi_build_default_ports(ports_a, 4880, 0, 0, 0, 0) /* TCP */,
21672170
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
21682171
ndpi_set_proto_defaults(ndpi_str, 0 /* encrypted */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_UFTP,
2169-
"UFTP", NDPI_PROTOCOL_CATEGORY_DOWNLOAD_FT,
2170-
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
2171-
ndpi_build_default_ports(ports_b, 1044, 0, 0, 0, 0) /* UDP */);
2172+
"UFTP", NDPI_PROTOCOL_CATEGORY_DOWNLOAD_FT,
2173+
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
2174+
ndpi_build_default_ports(ports_b, 1044, 0, 0, 0, 0) /* UDP */);
21722175
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_OPENFLOW,
21732176
"OpenFlow", NDPI_PROTOCOL_CATEGORY_NETWORK,
21742177
ndpi_build_default_ports(ports_a, 6653, 0, 0, 0, 0) /* TCP */,
21752178
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
2179+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_JSON_RPC,
2180+
"JSON-RPC", NDPI_PROTOCOL_CATEGORY_RPC,
2181+
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
2182+
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
2183+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_WEBDAV,
2184+
"WebDAV", NDPI_PROTOCOL_CATEGORY_COLLABORATIVE,
2185+
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0), /* TCP */
2186+
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0)); /* UDP */
2187+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_APACHE_KAFKA,
2188+
"Kafka", NDPI_PROTOCOL_CATEGORY_RPC,
2189+
ndpi_build_default_ports(ports_a, 9092, 0, 0, 0, 0) /* TCP */,
2190+
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
21762191

21772192
#ifdef CUSTOM_NDPI_PROTOCOLS
21782193
#include "../../../nDPI-custom/custom_ndpi_main.c"
@@ -5692,6 +5707,12 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
56925707
/* OpenFlow */
56935708
init_openflow_dissector(ndpi_str, &a);
56945709

5710+
/* JSON-RPC */
5711+
init_json_rpc_dissector(ndpi_str, &a);
5712+
5713+
/* Apache Kafka */
5714+
init_kafka_dissector(ndpi_str, &a);
5715+
56955716
#ifdef CUSTOM_NDPI_PROTOCOLS
56965717
#include "../../../nDPI-custom/custom_ndpi_main_init.c"
56975718
#endif
@@ -6949,6 +6970,7 @@ static void ndpi_reconcile_protocols(struct ndpi_detection_module_struct *ndpi_s
69496970
break;
69506971

69516972
case NDPI_PROTOCOL_SYSLOG:
6973+
case NDPI_PROTOCOL_MDNS:
69526974
if(flow->l4_proto == IPPROTO_UDP)
69536975
ndpi_unset_risk(ndpi_str, flow, NDPI_UNIDIRECTIONAL_TRAFFIC);
69546976
break;

src/lib/ndpi_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ void init_profinet_io_dissector(struct ndpi_detection_module_struct *ndpi_struct
610610
void init_hislip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
611611
void init_uftp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
612612
void init_openflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
613+
void init_json_rpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
614+
void init_kafka_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
613615

614616
#endif
615617

0 commit comments

Comments
 (0)