Commit graph

448 commits

Author SHA1 Message Date
Vitaly Lavrov
3c9bcebc88 Merge commit '2279a011c8' into flow_info-5 2025-08-19 11:12:12 +03:00
Vitaly Lavrov
566e0a7915 Merge commit '8dd2220116' into flow_info-5 2025-08-19 10:50:13 +03:00
Vitaly Lavrov
517e9bad48 Merge commit '81ca06b0c7' into flow_info-5 2025-08-19 10:24:44 +03:00
Vitaly Lavrov
06bd450722 Merge commit '06a49b4086' into flow_info-5 2025-08-19 10:18:28 +03:00
Vitaly Lavrov
26ad40ee1a Merge commit '978ca1ba1a' into flow_info-5
New API to enable/disable protocols. Removed `NDPI_LAST_IMPLEMENTED_PROTOCOL` (#2894)
2025-08-11 20:36:39 +03:00
Vitaly Lavrov
bf4a30935c Merge commit '6cbc8d1471' into flow_info-5 2025-08-11 20:23:50 +03:00
Ivan Nardi
eb5f8a037c
fuzz: improve coverage (#2931)
Sync `pl7m` code with upstream.
Add a new fuzzer to test the same flows with different L4 ports
2025-08-04 12:52:51 +02:00
Ivan Nardi
8dd2220116
Add the concept of protocols stack: more than 2 protocols per flow (#2913)
The idea is to remove the limitation of only two protocols ("master" and
"app") in the flow classifcation.
This is quite handy expecially for STUN flows and, in general, for any
flows where there is some kind of transitionf from a cleartext protocol
to TLS: HTTP_PROXY -> TLS/Youtube; SMTP -> SMTPS (via STARTTLS msg).

In the vast majority of the cases, the protocol stack is simply
Master/Application.

Examples of real stacks (from the unit tests)  different from the standard
"master/app":
* "STUN.WhatsAppCall.SRTP": a WA call
* "STUN.DTLS.GoogleCall": a Meet call
* "Telegram.STUN.DTLS.TelegramVoip": a Telegram call
* "SMTP.SMTPS.Google": a SMTP connection to Google server started in
  cleartext and updated to TLS
* "HTTP.Google.ntop": a HTTP connection to a Google domain (match via
  "Host" header) and to a ntop server (match via "Server" header)

The logic to create the stack is still a bit coarse: we have a decade of
code try to push everything in only ywo protocols... Therefore, the
content of the stack is still **highly experimental** and might change
in the next future; do you have any suggestions?

It is quite likely that the legacy fields "master_protocol" and
"app_protocol" will be there for a long time.

Add some helper to use the stack:
```
ndpi_stack_get_upper_proto();
ndpi_stack_get_lower_proto();
bool ndpi_stack_contains(struct ndpi_proto_stack *s, u_int16_t proto_id);
bool ndpi_stack_is_tls_like(struct ndpi_proto_stack *s);
bool ndpi_stack_is_http_like(struct ndpi_proto_stack *s);

```

Be sure new stack logic is compatible with legacy code:
```
assert(ndpi_stack_get_upper_proto(&flow->detected_protocol.protocol_stack) ==
       ndpi_get_upper_proto(flow->detected_protocol));
assert(ndpi_stack_get_lower_proto(&flow->detected_protocol.protocol_stack) ==
       ndpi_get_lower_proto(flow->detected_protocol));
```
2025-08-01 10:05:50 +02:00
Vitaly Lavrov
d3ebb45589 Merge commit 'cbd7136b34' into flow_info-5
Remove `NDPI_PROTOCOL_BITMASK`; add a new generic bitmask data structure (#2871)
2025-07-29 15:46:04 +03:00
Vitaly Lavrov
fd4b5103b3 Merge commit 'ed21057710' into flow_info-5 2025-07-29 15:11:41 +03:00
Vitaly Lavrov
54387218a1 Merge commit '70a72f1638' into flow_info-5
Major changes to initialization logic.
Don't use.
2025-07-28 12:29:49 +03:00
Fábio Depin
4eff2cdb99
Refactor: make src_name/dst_name dynamically allocated to reduce RAM usage (#2908)
- Changed ndpi_flow_info: replaced fixed-size char arrays (always INET6_ADDRSTRLEN) for src_name and dst_name with char* pointers.
- Now IPv4 flows use only INET_ADDRSTRLEN when needed, instead of always reserving IPv6 size.
2025-07-02 07:41:55 +02:00
Fábio Depin
c2526cffc1
Fix stats memory reuse and cleanup across duration loops in ndpiReader (#2903) (#2904)
Refactored stats allocation and reset logic to avoid segmentation faults
when running ndpiReader in live_capture mode with the -m (duration) option.

- Introduced ndpi_stats_init(), ndpi_stats_reset(), and ndpi_stats_free()
  to encapsulate lifecycle management of stats.
- Applied these functions in ndpiReader.c and reader_util.{c,h}.
- Prevented multiple allocations and ensured safe reuse of cumulative_stats
  and per-thread stats structures between capture iterations.

Fixes: https://github.com/ntop/nDPI/issues/2903
2025-06-24 09:48:34 +02:00
Ivan Nardi
06a49b4086 ndpiReader: fix check on max number of packets per flow 2025-06-23 17:27:39 +02:00
Ivan Nardi
978ca1ba1a
New API to enable/disable protocols. Removed NDPI_LAST_IMPLEMENTED_PROTOCOL (#2894)
Change the API to enable/disable protocols: you can set that via the
standard `ndpi_set_config()` function, as every configuration
parameters. By default, all protocols are enabled.

Split the (local) context initialization into two phases:
* `ndpi_init_detection_module()`: generic part. It does not depend on the
configuration and on the protocols being enabled or not. It also
calculates the real number of internal protocols
* `ndpi_finalize_initialization()`: apply the configuration. All the
initialization stuff that depend on protocols being enabled or not
must be put here

This is the last step to have the protocols number fully calculated at
runtime

Remove a (now) useless fuzzer.

Important API changes:
* remove `NDPI_LAST_IMPLEMENTED_PROTOCOL` define
* remove `ndpi_get_num_internal_protocols()`. To get the number of
configured protocols (internal and custom) you must use
`ndpi_get_num_protocols()` after having called `ndpi_finalize_initialization()`
2025-06-23 11:24:18 +02:00
Ivan Nardi
6cbc8d1471
fuzz: fuzz loading of external protocols lists (#2897) 2025-06-22 20:43:16 +02:00
Vitaly Lavrov
2c0649bba4 Merge commit '40fe26b2f1' into flow_info-4 2025-06-09 11:12:32 +03:00
Vitaly Lavrov
3395e8c654 Merge commit '8350cc68d4' into flow_info-4 2025-06-09 10:55:32 +03:00
Ivan Nardi
cbd7136b34
Remove NDPI_PROTOCOL_BITMASK; add a new generic bitmask data structure (#2871)
The main difference is that the memory is allocated at runtime

Typical usercase:
```
struct ndpi_bitmask b;

ndpi_bitmask_alloc(&b, ndpi_get_num_internal_protocols());

ndpi_bitmask_set(&b, $BIT);
ndpi_bitmask_is_set(&b, $BIT);
[...]

ndpi_bitmask_dealloc(&b);

```

See #2136
2025-06-09 09:00:17 +02:00
Ivan Nardi
ed21057710
First step into a dynamic number of protocols (#2857)
We want to get rid of the defines `NDPI_MAX_SUPPORTED_PROTOCOLS` and
`NDPI_MAX_NUM_CUSTOM_PROTOCOLS`.

You can use:
```
ndpi_get_num_protocols()
```

See #2136

Removed some unused functions from public API
2025-06-03 10:22:15 +02:00
Ivan Nardi
70a72f1638
New API to enable/disable protocols; remove ndpi_set_protocol_detection_bitmask2() (#2853)
The main goal is not to have the bitmask depending on the total number
of protocols anymore: `NDPI_INTERNAL_PROTOCOL_BITMASK` depends only on
internal protocols, i.e. on `NDPI_MAX_INTERNAL_PROTOCOLS`, i.e.
custom-defined protocols are not counted.
See #2136

Keep the old data structure `NDPI_PROTOCOL_BITMASK` with the old
semantic.

Since we need to change the API (and all the application code...)
anyway, simplify the API: by default all the protocols are enabled.
If you need otherwise, please use `ndpi_init_detection_module_ext()`
instead of `ndpi_init_detection_module()` (you can find an example in
the `ndpiReader` code).

To update the application code you likely only need to remove these 3
lines from your code:
```
- NDPI_PROTOCOL_BITMASK all;
- NDPI_BITMASK_SET_ALL(all);
- ndpi_set_protocol_detection_bitmask2(ndpi_str, &all);
```

Removed an unused field and struct definition.
2025-06-03 09:45:46 +02:00
Luca Deri
b4ce01d507 Moved variable across files 2025-05-29 10:51:02 +02:00
Luca Deri
bebacc853d Changed variable name 2025-05-29 09:18:37 +02:00
Luca Deri
2e679ba864 Added ndpi_load_protocols_dir() API call for loading IP-based protocol detection
Added --protocols-list-dir <dir> to ndpiReader for loading IP_based protocol
2025-05-28 22:13:11 +02:00
Ivan Nardi
8350cc68d4
BFCP: fix check on payload length and extract metadata (#2854)
We should be able to identified this protocol on the first packet,
without keeping any state

Close #2745
2025-05-26 15:08:53 +02:00
Vitaly Lavrov
aa1cc29df6 Merge commit '9e38b55a9a' into flow_info-4 2025-04-29 13:21:49 +03:00
Ivan Nardi
78ca74cf45
TLS: avoid exporting TLS heuristic fingerprint as metadata (#2783) 2025-03-27 14:54:49 +01:00
Vitaly Lavrov
0a979fcd8a Merge commit '8bada1fc02' into flow_info-4 2025-03-26 10:02:40 +03:00
Ivan Nardi
70728b3425
FastCGI: use specific metadata, not the HTTP ones (#2774)
We are going to use HTTP metadata only for real HTTP traffic; FastCGI
should be the only protocol using them improperly
2025-03-19 16:22:53 +01:00
Vitaly Lavrov
82f3e6b162 Merge commit '086d41c' into flow_info-4 2025-03-04 22:35:37 +03:00
Vitaly Lavrov
16e804c42b Merge commit 'b162e5406e' into flow_info-4 2025-03-03 16:57:30 +03:00
Vitaly Lavrov
d774dcfbe5 Merge commit 'cbfc20d' into flow_info-4 2025-03-03 16:17:12 +03:00
Ivan Nardi
1439abe23c ndpiReader: remove redundant checks 2025-02-28 19:11:59 +01:00
Vitaly Lavrov
f43a9d707e Merge commit '642cf57' into flow_info-4
Fix override host name.
2025-02-28 14:31:57 +03:00
Vitaly Lavrov
1f48a01b3b Merge commit 'af011e3' into flow_info-4 2025-02-28 11:52:19 +03:00
Vitaly Lavrov
548ce2e0e5 Merge commit '63a3547' into flow_info-4 2025-02-28 11:45:54 +03:00
Ivan Nardi
cde5773762
Move rtp info out of flow->protos (#2739)
Thiw way, the code is ready to handle rtp info from STUN flows too.
And, most important, this change works as workaround to fix some crashes
reported by oss-fuzz
2025-02-21 19:17:28 +01:00
Luca Deri
30c3613f2f Improved RTP dissection with EVS and other mobile voice codecs 2025-02-20 22:59:23 +01:00
Luca Deri
3bef87666d Exported RTP payload in packet metadata
Added ndpi_rtp_payload_type2str() API call
2025-02-19 11:34:19 +01:00
Ivan Nardi
baca06bfd2
ndpiReader: print more DNS information (#2717) 2025-02-11 18:16:55 +01:00
Luca Deri
1577955fca Added ndpi_find_protocol_qoe() API call
Updated (C)
2025-02-10 21:21:51 +01:00
Ivan Nardi
d4fb7b0aa1
fuzz: extend fuzzing coverage (#2696) 2025-01-23 15:23:01 +01:00
Ivan Nardi
af011e338e
TLS: remove JA3C (#2679)
Last step of removing JA3C fingerprint

Remove some duplicate tests: testing with ja4c/ja3s disabled is already
performed by `disable_metadata_and_flowrisks` configuration.

Close:#2551
2025-01-14 15:02:20 +01:00
Luca Deri
1a1fa63dda Fixes https://github.com/ntop/nDPI/issues/2672 2025-01-13 20:06:31 +01:00
Ivan Nardi
2e20f670dd
QUIC: extract "max idle timeout" parameter (#2649)
Even if it is only the proposed value by the client (and not the
negotiated one), it might be use as hint for timeout by the (external)
flows manager
2025-01-06 13:45:12 +01:00
Ivan Nardi
cae9fb9989
TLS: remove ESNI support (#2648)
ESNI has been superseded by ECH for years, now.
See: https://blog.cloudflare.com/encrypted-client-hello/
Set the existing flow risk if we still found this extension.
2025-01-06 11:04:50 +01:00
Vitaly Lavrov
06c34dead8 Merge commit '4d17dc635c' into flow_info-4 2025-01-04 17:21:40 +03:00
Vitaly Lavrov
3ce5dcdd08 Merge commit '214a2e5356' into flow_info-4 2024-12-14 12:46:31 +03:00
Vitaly Lavrov
80a3a797e7 Merge commit 'd7d942586a' into flow_info-4 2024-12-14 12:44:13 +03:00
Ivan Nardi
803410542e
STUN/RTP: improve metadata extraction (#2641) 2024-12-11 15:28:00 +01:00