aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiSimpleIntegration.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2023-12-20 19:22:22 +0100
committerGitHub <noreply@github.com>2023-12-20 19:22:22 +0100
commita5595d16c0f24924656813eccd0f0ac5c17c56a6 (patch)
tree5514d7138791f884dcd1726d7595053d2ff29116 /example/ndpiSimpleIntegration.c
parent149067b3fc4f3daafaa0cb8c2a5dab376b3ae975 (diff)
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
Diffstat (limited to 'example/ndpiSimpleIntegration.c')
-rw-r--r--example/ndpiSimpleIntegration.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/example/ndpiSimpleIntegration.c b/example/ndpiSimpleIntegration.c
index 7ffa3e3ed..d727d353e 100644
--- a/example/ndpiSimpleIntegration.c
+++ b/example/ndpiSimpleIntegration.c
@@ -230,6 +230,7 @@ static void ndpi_flow_info_freer(void * const node)
static void free_workflow(struct nDPI_workflow ** const workflow)
{
struct nDPI_workflow * const w = *workflow;
+ size_t i;
if (w == NULL) {
return;
@@ -243,7 +244,7 @@ static void free_workflow(struct nDPI_workflow ** const workflow)
if (w->ndpi_struct != NULL) {
ndpi_exit_detection_module(w->ndpi_struct);
}
- for(size_t i = 0; i < w->max_active_flows; i++) {
+ for(i = 0; i < w->max_active_flows; i++) {
ndpi_tdestroy(w->ndpi_flows_active[i], ndpi_flow_info_freer);
}
ndpi_free(w->ndpi_flows_active);
@@ -272,6 +273,7 @@ static int setup_reader_threads(char const * const file_or_device)
{
char * file_or_default_device;
char pcap_error_buffer[PCAP_ERRBUF_SIZE];
+ int i;
if (reader_thread_count > MAX_READER_THREADS) {
return 1;
@@ -290,7 +292,7 @@ static int setup_reader_threads(char const * const file_or_device)
}
}
- for (int i = 0; i < reader_thread_count; ++i) {
+ for (i = 0; i < reader_thread_count; ++i) {
reader_threads[i].workflow = init_workflow(file_or_default_device);
if (reader_threads[i].workflow == NULL)
{
@@ -500,8 +502,10 @@ static int ndpi_workflow_node_cmp(void const * const A, void const * const B) {
static void check_for_idle_flows(struct nDPI_workflow * const workflow)
{
+ size_t idle_scan_index;
+
if (workflow->last_idle_scan_time + IDLE_SCAN_PERIOD < workflow->last_time) {
- for (size_t idle_scan_index = 0; idle_scan_index < workflow->max_active_flows; ++idle_scan_index) {
+ for (idle_scan_index = 0; idle_scan_index < workflow->max_active_flows; ++idle_scan_index) {
ndpi_twalk(workflow->ndpi_flows_active[idle_scan_index], ndpi_idle_scan_walker, workflow);
while (workflow->cur_idle_flows > 0) {
@@ -530,7 +534,7 @@ static void ndpi_process_packet(uint8_t * const args,
struct nDPI_reader_thread * const reader_thread =
(struct nDPI_reader_thread *)args;
struct nDPI_workflow * workflow;
- struct nDPI_flow_info flow = {};
+ struct nDPI_flow_info flow;
size_t hashed_index;
void * tree_result;
@@ -551,6 +555,8 @@ static void ndpi_process_packet(uint8_t * const args,
uint16_t type;
uint32_t thread_index = INITIAL_THREAD_HASH; // generated with `dd if=/dev/random bs=1024 count=1 |& hd'
+ memset(&flow, '\0', sizeof(flow));
+
if (reader_thread == NULL) {
return;
}
@@ -1028,7 +1034,9 @@ static void * processing_thread(void * const ndpi_thread_arg)
static int processing_threads_error_or_eof(void)
{
- for (int i = 0; i < reader_thread_count; ++i) {
+ int i;
+
+ for (i = 0; i < reader_thread_count; ++i) {
if (__sync_fetch_and_add(&reader_threads[i].workflow->error_or_eof, 0) == 0) {
return 0;
}
@@ -1038,6 +1046,8 @@ static int processing_threads_error_or_eof(void)
static int start_reader_threads(void)
{
+ int i;
+
#ifndef WIN32
sigset_t thread_signal_set, old_signal_set;
@@ -1050,7 +1060,7 @@ static int start_reader_threads(void)
}
#endif
- for (int i = 0; i < reader_thread_count; ++i) {
+ for (i = 0; i < reader_thread_count; ++i) {
reader_threads[i].array_index = i;
if (reader_threads[i].workflow == NULL) {
@@ -1076,6 +1086,7 @@ static int start_reader_threads(void)
static int stop_reader_threads(void)
{
+ int i;
unsigned long long int total_packets_captured = 0;
unsigned long long int total_packets_processed = 0;
unsigned long long int total_l4_data_len = 0;
@@ -1083,13 +1094,13 @@ static int stop_reader_threads(void)
unsigned long long int total_flows_idle = 0;
unsigned long long int total_flows_detected = 0;
- for (int i = 0; i < reader_thread_count; ++i) {
+ for (i = 0; i < reader_thread_count; ++i) {
break_pcap_loop(&reader_threads[i]);
}
printf("------------------------------------ Stopping reader threads\n");
- for (int i = 0; i < reader_thread_count; ++i) {
+ for (i = 0; i < reader_thread_count; ++i) {
if (reader_threads[i].workflow == NULL) {
continue;
}
@@ -1114,7 +1125,7 @@ static int stop_reader_threads(void)
/* total packets captured: same value for all threads as packet2thread distribution happens later */
total_packets_captured = reader_threads[0].workflow->packets_captured;
- for (int i = 0; i < reader_thread_count; ++i) {
+ for (i = 0; i < reader_thread_count; ++i) {
if (reader_threads[i].workflow == NULL) {
continue;
}