diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-07-21 03:13:54 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-07-21 17:38:54 +0200 |
commit | 615478be3e8d4d4e22f624fc33b60d1a79e9271b (patch) | |
tree | 1e69162bf6086e10d7d42e9d047085d56c10c580 /src/lib/ndpi_utils.c | |
parent | 32275543c421eae55fd98a5a98e00059a0407953 (diff) |
Implemented function to retrieve flow information. #1253add/get-flow-info-apifn
* fixed [h]euristic typo
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 87b2b3e8a..43eacefb1 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -846,6 +846,41 @@ int ndpi_has_human_readeable_string(struct ndpi_detection_module_struct *ndpi_st /* ********************************** */ +static const char* ndpi_get_flow_info_by_proto_id(struct ndpi_flow_struct const * const flow, + u_int16_t proto_id) +{ + switch (proto_id) + { + case NDPI_PROTOCOL_DNS: + case NDPI_PROTOCOL_HTTP: + return (char const *)flow->host_server_name; + case NDPI_PROTOCOL_QUIC: + case NDPI_PROTOCOL_TLS: + if (flow->l4.tcp.tls.hello_processed != 0) + { + return flow->protos.tls_quic_stun.tls_quic.client_requested_server_name; + } + break; + } + + return NULL; +} + +const char* ndpi_get_flow_info(struct ndpi_flow_struct const * const flow, + ndpi_protocol const * const l7_protocol) +{ + char const * const app_protocol_info = ndpi_get_flow_info_by_proto_id(flow, l7_protocol->app_protocol); + + if (app_protocol_info != NULL) + { + return app_protocol_info; + } + + return ndpi_get_flow_info_by_proto_id(flow, l7_protocol->master_protocol); +} + +/* ********************************** */ + char* ndpi_ssl_version2str(struct ndpi_flow_struct *flow, u_int16_t version, u_int8_t *unknown_tls_version) { |