diff --git a/CMakeLists.txt b/CMakeLists.txt index e44e223eb..d9a0ccb61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,6 +190,8 @@ if(BUILD_NDPI) CONFIGURE_COMMAND env CC=${CMAKE_C_COMPILER} CXX=false + AR=${CMAKE_C_COMPILER_AR} + RANLIB=${CMAKE_C_COMPILER_RANLIB} PKG_CONFIG=${PKG_CONFIG_EXECUTABLE} CFLAGS=${CMAKE_C_FLAGS} LDFLAGS=${CMAKE_MODULE_LINKER_FLAGS} diff --git a/libnDPI b/libnDPI index 7c19de490..37f918322 160000 --- a/libnDPI +++ b/libnDPI @@ -1 +1 @@ -Subproject commit 7c19de49047a5731f3107ff17854e9afe839cc61 +Subproject commit 37f918322c0a489b5143a987c8f1a44a6f78a6f3 diff --git a/nDPId-test.c b/nDPId-test.c index da152f17f..48cf6e003 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -1076,6 +1076,13 @@ int main(int argc, char ** argv) nDPId_return.total_active_flows != nDPId_return.total_idle_flows) { logger(1, "%s: %s", argv[0], "Memory / Flow leak detected."); + logger(1, "%s: Allocated / Free'd bytes: %lu / %lu", argv[0], ndpi_memory_alloc_bytes, ndpi_memory_free_bytes); + logger(1, "%s: Allocated / Free'd count: %lu / %lu", argv[0], ndpi_memory_alloc_count, ndpi_memory_free_count); + logger(1, + "%s: Total Active / Idle Flows: %llu / %llu", + argv[0], + nDPId_return.total_active_flows, + nDPId_return.total_idle_flows); return 1; } diff --git a/nDPId.c b/nDPId.c index f57419de9..6e044abc9 100644 --- a/nDPId.c +++ b/nDPId.c @@ -2400,11 +2400,13 @@ static void jsonize_flow_event(struct nDPId_reader_thread * const reader_thread, { struct nDPId_flow * const flow = (struct nDPId_flow *)flow_ext; + ndpi_serialize_start_of_block(&workflow->ndpi_serializer, "ndpi"); ndpi_serialize_proto(workflow->ndpi_struct, &workflow->ndpi_serializer, flow->finished.risk, flow->finished.confidence, flow->flow_extended.detected_l7_protocol); + ndpi_serialize_end_of_block(&workflow->ndpi_serializer); } break; @@ -2821,7 +2823,7 @@ static int process_datalink_layer(struct nDPId_reader_thread * const reader_thre return 1; } - struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const)&packet[eth_offset]; + struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const) & packet[eth_offset]; *ip_offset = sizeof(struct ndpi_chdlc); *layer3_type = ntohs(chdlc->proto_code); break; @@ -2843,7 +2845,7 @@ static int process_datalink_layer(struct nDPId_reader_thread * const reader_thre if (packet[0] == 0x0f || packet[0] == 0x8f) { - struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const)&packet[eth_offset]; + struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const) & packet[eth_offset]; *ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */ *layer3_type = ntohs(chdlc->proto_code); } @@ -2881,7 +2883,7 @@ static int process_datalink_layer(struct nDPId_reader_thread * const reader_thre } struct ndpi_radiotap_header const * const radiotap = - (struct ndpi_radiotap_header const * const)&packet[eth_offset]; + (struct ndpi_radiotap_header const * const) & packet[eth_offset]; uint16_t radio_len = radiotap->len; /* Check Bad FCS presence */ @@ -3761,7 +3763,8 @@ static void ndpi_process_packet(uint8_t * const args, &flow_to_process->info.detection_data->flow, ip != NULL ? (uint8_t *)ip : (uint8_t *)ip6, ip_size, - workflow->last_thread_time); + workflow->last_thread_time, + NULL); if (ndpi_is_protocol_detected(workflow->ndpi_struct, flow_to_process->flow_extended.detected_l7_protocol) != 0 && flow_to_process->info.detection_completed == 0) @@ -4848,6 +4851,14 @@ int main(int argc, char ** argv) "----------------------------------\n", ndpi_get_gcrypt_version()); } + if (NDPI_API_VERSION != ndpi_get_api_version()) + { + logger_early(1, + "Unforeseen Consequences; nDPId was compiled with libnDPI api version %u, but the api version of " + "the shared library is: %u.", + NDPI_API_VERSION, + ndpi_get_api_version()); + } #ifdef ENABLE_MEMORY_PROFILING logger_early(0, "size/workflow...: %zu bytes", sizeof(struct nDPId_workflow)); diff --git a/schema/flow_event_schema.json b/schema/flow_event_schema.json index 8724ecfd2..649e21891 100644 --- a/schema/flow_event_schema.json +++ b/schema/flow_event_schema.json @@ -208,91 +208,126 @@ }, "ndpi": { "type": "object", - "required": [ "proto", "breed" ], + "required": [ "proto", "proto_id", "breed", "encrypted" ], - "if": { - "properties": { "proto": { "enum": [ "Unknown", "Skype_Teams" ] } } + "properties": { + "proto": { + "type": "string" + }, + "proto_id": { + "type": "string" + }, + "category": { + "type": "string" + }, + "category_id": { + "type": "number" + }, + "encrypted": { + "type": "number", + "enum": [ + 0, + 1 + ] + }, + "breed": { + "type": "string" + }, + "flow_risk": { + "type": "object" + }, + "confidence": { + "type": "object", + "properties": { + "0": { + "type": "string" + }, + "1": { + "type": "string" + }, + "2": { + "type": "string" + }, + "3": { + "type": "string" + }, + "4": { + "type": "string" + }, + "5": { + "type": "string" + }, + "6": { + "type": "string" + } + }, + "additionalProperties": false + }, + "entropy": { + "type": "number" + }, + "hostname": { + "type": "string" + }, + "dhcp": { + "type": "object" + }, + "discord": { + "type": "object" + }, + "bittorrent": { + "type": "object" + }, + "mdns": { + "type": "object" + }, + "ntp": { + "type": "object" + }, + "ubntac2": { + "type": "object" + }, + "kerberos": { + "type": "object" + }, + "telnet": { + "type": "object" + }, + "tls": { + "type": "object" + }, + "quic": { + "type": "object" + }, + "imap": { + "type": "object" + }, + "http": { + "type": "object" + }, + "pop": { + "type": "object" + }, + "smtp": { + "type": "object" + }, + "dns": { + "type": "object" + }, + "ftp": { + "type": "object" + }, + "ssh": { + "type": "object" + }, + "stun": { + "type": "object" + }, + "softether": { + "type": "object" + } }, - "then": { - "return": true - }, - "else": { - "required": [ "category", "confidence" ] - }, - - "proto": { - "type": "string" - }, - "category": { - "type": "string" - }, - "breed": { - "type": "string" - }, - "flow_risk": { - "type": "object" - }, - "confidence": { - "type": "string", - "enum": [ - "0", - "1", - "2", - "3", - "4" - ] - } - }, - "entropy": { - "type": "number" - }, - "dhcp": { - "type": "object" - }, - "bittorrent": { - "type": "object" - }, - "mdns": { - "type": "object" - }, - "ntp": { - "type": "object" - }, - "ubntac2": { - "type": "object" - }, - "kerberos": { - "type": "object" - }, - "telnet": { - "type": "object" - }, - "tls": { - "type": "object" - }, - "quic": { - "type": "object" - }, - "imap": { - "type": "object" - }, - "http": { - "type": "object" - }, - "pop": { - "type": "object" - }, - "smtp": { - "type": "object" - }, - "dns": { - "type": "object" - }, - "ftp": { - "type": "object" - }, - "ssh": { - "type": "object" + "additionalProperties": false } }, "additionalProperties": false diff --git a/scripts/get-and-build-libndpi.sh b/scripts/get-and-build-libndpi.sh index f9851c852..518ae820a 100755 --- a/scripts/get-and-build-libndpi.sh +++ b/scripts/get-and-build-libndpi.sh @@ -14,6 +14,8 @@ cat <