Skip to content

Commit ff80473

Browse files
committed
Fix for nDPI 4.6
1 parent 86a939e commit ff80473

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/Flow.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
/* static so default is zero-initialization, let's just define it */
2525

2626
const ndpi_protocol Flow::ndpiUnknownProtocol = { NDPI_PROTOCOL_UNKNOWN,
27-
NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NULL };
27+
NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN,
28+
NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NULL };
2829
// #define DEBUG_DISCOVERY
2930
// #define DEBUG_UA
3031
// #define DEBUG_SCORE
@@ -670,9 +671,12 @@ void Flow::processExtraDissectedInformation() {
670671
&& (ndpiFlow->protos.tls_quic.server_names != NULL))
671672
protos.tls.server_names = strdup(ndpiFlow->protos.tls_quic.server_names);
672673

673-
if((protos.tls.client_alpn == NULL)
674-
&& (ndpiFlow->protos.tls_quic.alpn != NULL))
675-
protos.tls.client_alpn = strdup(ndpiFlow->protos.tls_quic.alpn);
674+
if(protos.tls.client_alpn == NULL) {
675+
if(ndpiFlow->protos.tls_quic.negotiated_alpn != NULL)
676+
protos.tls.client_alpn = strdup(ndpiFlow->protos.tls_quic.negotiated_alpn);
677+
else if(ndpiFlow->protos.tls_quic.advertised_alpns != NULL)
678+
protos.tls.client_alpn = strdup(ndpiFlow->protos.tls_quic.advertised_alpns);
679+
}
676680

677681
if((protos.tls.client_tls_supported_versions == NULL)
678682
&& (ndpiFlow->protos.tls_quic.tls_supported_versions != NULL))
@@ -774,7 +778,7 @@ void Flow::processPacket(const struct pcap_pkthdr *h,
774778
* be able to guess the protocol. */
775779

776780
proto_id = ndpi_detection_process_packet(iface->get_ndpi_struct(), ndpiFlow,
777-
ip_packet, ip_len, packet_time);
781+
ip_packet, ip_len, packet_time, NULL);
778782

779783
detected = ndpi_is_protocol_detected(iface->get_ndpi_struct(), proto_id);
780784

@@ -857,10 +861,10 @@ void Flow::processDNSPacket(const u_char *ip_packet, u_int16_t ip_len, u_int64_t
857861
/* Instruct nDPI to continue the dissection
858862
See https://github.com/ntop/ntopng/commit/30f52179d9f7a1eb774534def93d55c77d6070bc#diff-20b1df29540b6de59ceb6c6d2f3afdb5R387
859863
*/
860-
ndpiFlow->check_extra_packets = 1, ndpiFlow->max_extra_packets_to_check = 10;
864+
ndpiFlow->max_extra_packets_to_check = 10;
861865

862866
proto_id = ndpi_detection_process_packet(iface->get_ndpi_struct(), ndpiFlow,
863-
ip_packet, ip_len, packet_time);
867+
ip_packet, ip_len, packet_time, NULL);
864868

865869
/*
866870
A DNS flow won't change to a non-DNS flow. However, this check is
@@ -2381,17 +2385,15 @@ void Flow::lua(lua_State* vm, AddressTree * ptree,
23812385

23822386
void Flow::lua_confidence(lua_State* vm) {
23832387
switch(getConfidence()) {
2384-
case NDPI_CONFIDENCE_MATCH_BY_PORT:
2385-
case NDPI_CONFIDENCE_MATCH_BY_IP:
2386-
lua_push_uint32_table_entry(vm, "confidence", (ndpiConfidence) confidence_guessed);
2387-
break;
2388-
23892388
case NDPI_CONFIDENCE_DPI_CACHE:
2389+
case NDPI_CONFIDENCE_DPI_PARTIAL_CACHE:
23902390
case NDPI_CONFIDENCE_DPI:
2391-
lua_push_uint32_table_entry(vm, "confidence", (ndpiConfidence) confidence_dpi);
2391+
case NDPI_CONFIDENCE_NBPF:
2392+
lua_push_uint32_table_entry(vm, "confidence", (ndpiConfidence) confidence_guessed);
23922393
break;
23932394

23942395
default:
2396+
lua_push_uint32_table_entry(vm, "confidence", (ndpiConfidence) confidence_guessed);
23952397
break;
23962398
}
23972399
}
@@ -6205,17 +6207,14 @@ void Flow::getProtocolJSONInfo(ndpi_serializer *serializer) {
62056207

62066208
if(getConfidence() != NDPI_CONFIDENCE_UNKNOWN) {
62076209
switch(getConfidence()) {
6208-
case NDPI_CONFIDENCE_MATCH_BY_PORT:
6209-
case NDPI_CONFIDENCE_MATCH_BY_IP:
6210-
ndpi_serialize_string_uint32(serializer, "confidence", (ndpiConfidence) confidence_guessed);
6211-
break;
6212-
6213-
case NDPI_CONFIDENCE_DPI_CACHE:
6214-
case NDPI_CONFIDENCE_DPI:
6215-
ndpi_serialize_string_uint32(serializer, "confidence", (ndpiConfidence) confidence_dpi);
6210+
case NDPI_CONFIDENCE_DPI_CACHE:
6211+
case NDPI_CONFIDENCE_DPI:
6212+
case NDPI_CONFIDENCE_NBPF:
6213+
ndpi_serialize_string_uint32(serializer, "confidence", (ndpiConfidence) confidence_dpi);
62166214
break;
62176215

6218-
default:
6216+
default:
6217+
ndpi_serialize_string_uint32(serializer, "confidence", (ndpiConfidence) confidence_guessed);
62196218
break;
62206219
}
62216220
}

0 commit comments

Comments
 (0)