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.
This commit is contained in:
Ivan Nardi 2022-07-24 17:46:24 +02:00 committed by GitHub
parent 523f22b942
commit e6b332aa4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 267 additions and 165 deletions

View file

@ -13,7 +13,7 @@ If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------------------------------------------------------
"""
from ndpi import NDPI, NDPIFlow
from ndpi import NDPI, NDPIFlow, ffi
import time
@ -21,7 +21,7 @@ if __name__ == '__main__':
try:
nDPI = NDPI()
ndpi_flow = NDPIFlow()
nDPI.process_packet(ndpi_flow, b'', time.time())
nDPI.process_packet(ndpi_flow, b'', time.time(), ffi.NULL)
nDPI.giveup(ndpi_flow)
print("nDPI Python bindings: OK")
except Exception: