aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheadshog <craaaaaachind@gmail.com>2023-05-16 19:05:48 +0300
committerIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2023-05-20 15:09:51 +0200
commitdd7198fcafb419779ab8803a99528d7609bac53d (patch)
treed07fb46adfc0d5697474fae2c194b6ac4406c47d
parent5ca6f0ac62d6b2c346bc99d2a1b1200fe9df7917 (diff)
fixed numeric truncation error
-rw-r--r--example/reader_util.c6
-rw-r--r--src/include/ndpi_api.h2
-rw-r--r--src/lib/ndpi_analyze.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index 97b5cce7e..5d0f4f7f3 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -1505,7 +1505,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
if(flow->iat_flow
&& (tdiff.tv_sec >= 0) /* Discard backward time */
) {
- u_int32_t ms = ndpi_timeval_to_milliseconds(tdiff);
+ u_int64_t ms = ndpi_timeval_to_milliseconds(tdiff);
if(ms > 0)
ndpi_data_add_value(flow->iat_flow, ms);
@@ -1521,7 +1521,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
if(flow->iat_c_to_s
&& (tdiff.tv_sec >= 0) /* Discard backward time */
) {
- u_int32_t ms = ndpi_timeval_to_milliseconds(tdiff);
+ u_int64_t ms = ndpi_timeval_to_milliseconds(tdiff);
ndpi_data_add_value(flow->iat_c_to_s, ms);
}
@@ -1540,7 +1540,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
ndpi_timer_sub(&when, &flow->dst2src_last_pkt_time, &tdiff);
if(flow->iat_s_to_c) {
- u_int32_t ms = ndpi_timeval_to_milliseconds(tdiff);
+ u_int64_t ms = ndpi_timeval_to_milliseconds(tdiff);
ndpi_data_add_value(flow->iat_s_to_c, ms);
}
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index ecb6c8271..0a420accb 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -1698,7 +1698,7 @@ extern "C" {
void ndpi_init_data_analysis(struct ndpi_analyze_struct *s, u_int16_t _max_series_len);
void ndpi_free_data_analysis(struct ndpi_analyze_struct *d, u_int8_t free_pointer);
void ndpi_reset_data_analysis(struct ndpi_analyze_struct *d);
- void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value);
+ void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int64_t value);
/* Sliding-window only */
float ndpi_data_window_average(struct ndpi_analyze_struct *s);
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c
index 1b3b9cc4f..75b650db5 100644
--- a/src/lib/ndpi_analyze.c
+++ b/src/lib/ndpi_analyze.c
@@ -93,7 +93,7 @@ void ndpi_reset_data_analysis(struct ndpi_analyze_struct *d) {
/*
Add a new point to analyze
*/
-void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value) {
+void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int64_t value) {
if(!s)
return;