diff options
Diffstat (limited to 'src/lib/ndpi_analyze.c')
-rw-r--r-- | src/lib/ndpi_analyze.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 7d4aa5f47..a2fe557ae 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -75,6 +75,14 @@ void ndpi_free_data_analysis(struct ndpi_analyze_struct *d) { /* ********************************************************************************* */ +void ndpi_reset_data_analysis(struct ndpi_analyze_struct *d) { + memset(d, 0, sizeof(struct ndpi_analyze_struct)); + memset(d->values, 0, sizeof(u_int32_t)*d->num_values_array_len); + d->num_data_entries = 0; +} + +/* ********************************************************************************* */ + /* Add a new point to analyze */ @@ -112,6 +120,16 @@ float ndpi_data_average(struct ndpi_analyze_struct *s) { /* ********************************************************************************* */ +u_int32_t ndpi_data_last(struct ndpi_analyze_struct *s) { + if((s->num_data_entries == 0) || (s->sum_total == 0)) + return(0); + + if(s->next_value_insert_index == 0) + return(s->values[s->num_values_array_len-1]); + else + return(s->values[s->next_value_insert_index-1]); +} + /* Return min/max on all values */ u_int32_t ndpi_data_min(struct ndpi_analyze_struct *s) { return(s->min_val); } u_int32_t ndpi_data_max(struct ndpi_analyze_struct *s) { return(s->max_val); } |