Commit graph

72 commits

Author SHA1 Message Date
Vitaly Lavrov
094c9014a4 Merge commit 'eb8024ea92' into flow_info-4 2026-10-07 10:18:05 +03:00
Vitaly Lavrov
7d5fc92248 Merge commit 'a6e250b724' into flow_info-4 2026-10-07 10:03:49 +03:00
Vitaly Lavrov
cab81ce615 Merge commit '7d1edd831c' into flow_info-4 2026-10-05 14:07:49 +03:00
Vitaly Lavrov
5fa42a1942 Merge commit 'dedf61e9cc' into flow_info-4 2026-10-02 15:32:03 +03:00
Luca Deri
f9daaf170d
Dynamic host_server_name and add JA5 implementation(#3257) 2026-09-14 10:34:33 +02:00
Luca Deri
61337dad12
Reworked code to split flow definition in core and metadata 2026-09-05 15:48:02 +02:00
Luca Deri
d7c97ba097 Improved dual-license wording 2026-08-25 16:58:08 +02:00
Ivan Nardi
1f2606902c
License: non-commercial vs commercial applications (#3220)
* WIP

* Fix compilation of fuzzing

* Fix fuzzing compilation

* Cleaned up old quic contributed code (#3222)

Recode commits 713cdd0, 26df140

* QUIC: refactoring

* WIP

* WIP

* Revert "QUIC: refactoring"

This reverts commit 50afd07f28.

* QUIC: refactoring original Wireshark code (#3224)

* Added ability to specify in protocol definition, when a (partial) protocol
can change. This can be queries using a new APi call
named ndpi_can_partial_proto_classification_change()

* TLS: minor changes and remove same stale comments

* Fix out-of-bounds read of TLS certificate dates (#3225)

notBefore and notAfter are u_int32_t, but ndpi_tls2json() passed their
address to ndpi_gmtime_r() as a time_t *. Wherever time_t is 8 bytes this
reads 4 bytes past the field, picking up the adjacent member, so the value
handed to gmtime_r() is notBefore | (notAfter << 32) on little-endian.

gmtime_r() then fails on that out-of-range value and returns NULL, leaving
before/after NULL, so the "notbefore" and "notafter" fields are silently
dropped from the JSON output. On architectures that require aligned access
the 8-byte load traps instead of merely being wrong.

Convert to a real time_t instead of casting the address. The temporaries
are named not_before/not_after because notBefore/notAfter are already
char[32] buffers in the same function.

* WIP

* fuzz: fix compilation

---------

Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
Co-authored-by: Luca Deri <deri@ntop.org>
Co-authored-by: shalseth <33956011+shalseth@users.noreply.github.com>
2026-08-22 17:57:28 +02:00
Vitaly Lavrov
c79d883936 Merge branch 'github.dev' into flow_info-4
Some checks failed
CIFuzz / Fuzzing (address) (push) Has been cancelled
CIFuzz / Fuzzing (memory) (push) Has been cancelled
CIFuzz / Fuzzing (undefined) (push) Has been cancelled
2026-07-07 12:14:31 +03:00
Ivan Nardi
79178b88c8
CI: compilation checks on more BSD flavors and add support for ubuntu 26.04 (#3188) 2026-06-22 17:20:16 +02:00
Vitaly Lavrov
07b76c4d26 Merge commit '1ffc582e76' into flow_info-4 2026-02-06 12:32:00 +03:00
Luca Deri
37ca034697 (C) update 2026-01-01 10:31:40 +01:00
Vitaly Lavrov
5f0dd0eb12 Merge commit '83d85775a8' into flow_info-4 2025-12-08 13:10:19 +03:00
Ivan Nardi
83d85775a8
Provide an explicit state for the flow classification process (#2942)
Application should keep calling nDPI until flow state became
`NDPI_STATE_CLASSIFIED`.

The main loop in the application is simplified to something like:
```
res = ndpi_detection_process_packet(...);
if(res->state == NDPI_STATE_CLASSIFIED) {
  /* Done: you can get finale classification and all metadata.
     nDPI doesn't need more packets for this flow */
} else {
  /* nDPI needs more packets for this flow. The provided
     classification is not final and more metadata might be
     extracted.
     If `res->state` is `NDPI_STATE_PARTIAL`, partial/initial
     classification is available in `res->proto`
     as usual but it can be updated later.
  */
}

/*
    Example A (QUIC flow):
     pkt 1: proto QUIC state NDPI_STATE_PARTIAL
     pkt 2: proto QUIC/Youtube  state NDPI_STATE_CLASSIFIED
    Example B (GoogleMeet call):
     pkt 1:   proto STUN state NDPI_STATE_PARTIAL
     pkt N:   proto DTLS state NDPI_STATE_PARTIAL
     pkt N+M: proto DTLS/GoogleCall state NDPI_STATE_CLASSIFIED
    Example C (standard TLS flow):
     pkt 1:   proto Unknown state NDPI_STATE_INSPECTING
     pkt 2:   proto Unknown state NDPI_STATE_INSPECTING
     pkt 3:   proto Unknown state NDPI_STATE_INSPECTING
     pkt 4:   proto TLS/Facebook state NDPI_STATE_PARTIAL
     pkt N:   proto TLS/Facebook state NDPI_STATE_CLASSIFIED
 */
}
```
You can take a look at `ndpiReader` for a slightly more complex example.

API changes:
* remove the third parameter from `ndpi_detection_giveup()`. If you need
to know if the classification flow has been guessed, you can access
`flow->protocol_was_guessed`
* remove `ndpi_extra_dissection_possible()`
* change some prototypes from accepting `ndpi_protocol foo` to
`ndpi_master_app_protocol bar`. The update is trivial: from `foo` to
`foo.proto`
2025-11-03 12:08:15 +01:00
Vitaly Lavrov
7935957927 Merge commit '28ae2e14d8' into flow_info-5 2025-07-29 16:06:16 +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
Ivan Nardi
28ae2e14d8
Check ndpi_finalize_initialization() return value (#2884) 2025-06-14 11:31:23 +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
Vitaly Lavrov
d774dcfbe5 Merge commit 'cbfc20d' into flow_info-4 2025-03-03 16:17:12 +03:00
Luca Deri
1577955fca Added ndpi_find_protocol_qoe() API call
Updated (C)
2025-02-10 21:21:51 +01:00
Vitaly Lavrov
75a60981d2 Merge commit 'f350379e95' into flow_info-4 2024-09-13 11:35:52 +03:00
Vitaly Lavrov
7a2bb5f7d5 Merge commit 'e4e91e9380' into flow_info-4
Fix after merge
2024-09-12 15:51:59 +03:00
Ivan Nardi
eb133b8fa5
TLS: better state about handshake (#2534)
Keep track if we received CH or/and SH messsages: usefull with
unidirectional flows
2024-09-03 12:44:22 +02:00
Luca Deri
2315f44efa Compilation fixes 2024-08-24 16:59:56 +02:00
Vitaly Lavrov
c957053e84 Merge branch 'github.dev' into flow_info-4 2024-04-09 11:58:00 +03:00
Toni
41eef9246c
Disable -Wno-unused-parameter -Wno-unused-function. (#2358)
* unused parameters and functions pollute the code and decrease readability

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2024-04-03 14:10:21 +02:00
Vitaly Lavrov
3ae463fbfa Merge commit '400cd516b5' into flow_info-4 2024-02-16 11:21:42 +03:00
Vitaly Lavrov
3c3200f05a Merge commit '0712d496fe' into flow_info-4
Added configuration support
2024-02-14 11:23:01 +03:00
Ivan Nardi
400cd516b5
Allow multiple struct ndpi_detection_module_struct to share some state (#2271)
Add the concept of "global context".

Right now every instance of `struct ndpi_detection_module_struct` (we
will call it "local context" in this description) is completely
independent from each other. This provide optimal performances in
multithreaded environment, where we pin each local context to a thread,
and each thread to a specific CPU core: we don't have any data shared
across the cores.

Each local context has, internally, also some information correlating
**different** flows; something like:
```
if flow1 (PeerA <-> Peer B) is PROTOCOL_X; then
  flow2 (PeerC <-> PeerD) will be PROTOCOL_Y
```
To get optimal classification results, both flow1 and flow2 must be
processed by the same local context. This is not an issue at all in the far
most common scenario where there is only one local context, but it might
be impractical in some more complex scenarios.

Create the concept of "global context": multiple local contexts can use
the same global context and share some data (structures) using it.
This way the data correlating multiple flows can be read/write from
different local contexts.
This is an optional feature, disabled by default.

Obviously data structures shared in a global context must be thread safe.
This PR updates the code of the LRU implementation to be, optionally,
thread safe.

Right now, only the LRU caches can be shared; the other main structures
(trees and automas) are basically read-only: there is little sense in
sharing them. Furthermore, these structures don't have any information
correlating multiple flows.

Every LRU cache can be shared, independently from the others, via
`ndpi_set_config(ndpi_struct, NULL, "lru.$CACHE_NAME.scope", "1")`.

It's up to the user to find the right trade-off between performances
(i.e. without shared data) and classification results (i.e. with some
shared data among the local contexts), depending on the specific traffic
patterns and on the algorithms used to balance the flows across the
threads/cores/local contexts.

Add some basic examples of library initialization in
`doc/library_initialization.md`.

This code needs libpthread as external dependency. It shouldn't be a big
issue; however a configure flag has been added to disable global context
support. A new CI job has been added to test it.

TODO: we should need to find a proper way to add some tests on
multithreaded enviroment... not an easy task...

*** API changes ***

If you are not interested in this feature, simply add a NULL parameter to
any `ndpi_init_detection_module()` calls.
2024-02-01 15:33:11 +01:00
Vitaly Lavrov
546963e557 Merge commit '5eb468d07b' into flow_info-4 2024-01-29 14:41:04 +03:00
Nardi Ivan
0712d496fe config: allow configuration of guessing algorithms 2024-01-18 10:21:24 +01:00
Nardi Ivan
88720331ae config: remove enum ndpi_prefs 2024-01-18 10:21:24 +01:00
Ivan Nardi
a5595d16c0
CI: update list of compilers (#2223)
Try using latest gcc and clang versions.
We still care about RHEL7: since handling a RHEL7 runner on GitHub is
quite complex, let try to use a similar version of gcc, at least
2023-12-20 19:22:22 +01:00
Vitaly Lavrov
c9d499941b Merge branch 'github.dev' into flow_info-4 2023-12-11 15:08:33 +03:00
rl1987
59d476195c
Fix typos (#2204)
* Fix typo in ndpiSimpleIntegration.c

* Fix misspelling in a comment
2023-12-10 19:58:22 +01:00
Vitaly Lavrov
93566de48d Merge branch 'github.dev' into flow_info-4 2023-11-30 15:35:52 +03:00
Toni
0cb6f4cb75
Fixed hash buffer size in ndpiSimpleIntegration. (#2143)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-11-10 10:23:37 +01:00
Vitaly Lavrov
3ff5a9b05f Merge branch 'github.dev' into flow_info-4 2022-12-12 10:07:45 +03:00
Gowa2017
c882120afd
thread_index may by negative. (#1814)
* thread_index may by negative.

Like:
192.168.8.155:55848 --> 183.3.224.139

* reader thread index also need to uint32
2022-12-05 10:22:05 +01:00
Vitaly Lavrov
dcff3ef841 Merge branch 'github.dev' into flow_info-4 2022-10-25 21:34:31 +03:00
Ivan Nardi
ca5ffc4988
TLS: improve handling of ALPN(s) (#1784)
Tell "Advertised" ALPN list from "Negotiated" ALPN; the former is
extracted from the CH, the latter from the SH.

Add some entries to the known ALPN list.

Fix printing of "TLS Supported Versions" field.
2022-10-25 17:06:29 +02:00
Vitaly Lavrov
01a243bbee Merge commit '8c4ece941e' into flow_info-4 2022-10-24 11:42:25 +03:00
Nardi Ivan
f3a74d97d8 TLS/DTLS: we process certificate for UDP flows, too
Note that current code access `certificate_processed` state even before
setting the protocol classification, so this piece of information can't
be saved in `flow->protos` union.
2022-09-30 06:53:29 +02:00
Vitaly Lavrov
0e9a517a00 Merge commit 'd8d525fff2' into flow_info-4 2022-09-07 15:52:30 +03:00
Ivan Nardi
e6b332aa4a
Add support for flow client/server information (#1671)
In a lot of places in ndPI we use *packet* source/dest info
(address/port/direction) when we are interested in *flow* client/server
info, instead.

Add basic logic to autodetect this kind of information.

nDPI doesn't perform any "flow management" itself but this task is
delegated to the external application. It is then likely that the
application might provide more reliable hints about flow
client/server direction and about the TCP handshake presence: in that case,
these information might be (optionally) passed to the library, disabling
the internal "autodetect" logic.

These new fields have been used in some LRU caches and in the "guessing"
algorithm.
It is quite likely that some other code needs to be updated.
2022-07-24 17:46:24 +02:00
Vitaly Lavrov
6258f37229 Merge commit '71636dcafd' into flow_info-4 2022-04-29 21:01:13 +03:00
Vitaly Lavrov
17a984a8de Merge commit '8b2c9860be' into flow_info-4 2022-04-29 16:16:10 +03:00
Luca Deri
3ad989f6a8 Added BPF filtering for discarding non-IP packets 2022-04-27 17:05:33 +02:00
Toni Uhlig
c3df3a12aa Fixed msys2 build warnings and re-activated CI Mingw64 build.
* Removed Visual Studio leftovers. Maintaining an autotools project with VS integration requires some additional overhead.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Signed-off-by: lns <matzeton@googlemail.com>
2022-04-14 19:17:48 +02:00
Vitaly Lavrov
459b49387e Merge branch 'github.dev' into flow_info-4 2022-02-24 12:28:51 +03:00