Restore protocol extraction to original method.
Add microseconds to time series if milliseconds returns 0. Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
This commit is contained in:
@@ -664,13 +664,13 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
|
|||||||
|
|
||||||
l4_offset = iph->ihl * 4;
|
l4_offset = iph->ihl * 4;
|
||||||
l3 = (const u_int8_t*)iph;
|
l3 = (const u_int8_t*)iph;
|
||||||
*proto = iph->protocol;
|
|
||||||
} else {
|
} else {
|
||||||
l4_offset = sizeof(struct ndpi_ipv6hdr);
|
l4_offset = sizeof(struct ndpi_ipv6hdr);
|
||||||
l3 = (const u_int8_t*)iph6;
|
l3 = (const u_int8_t*)iph6;
|
||||||
*proto = iph6->ip6_hdr.ip6_un1_nxt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*proto = iph->protocol;
|
||||||
|
|
||||||
if(l4_packet_len < 64)
|
if(l4_packet_len < 64)
|
||||||
workflow->stats.packet_len[0]++;
|
workflow->stats.packet_len[0]++;
|
||||||
else if(l4_packet_len >= 64 && l4_packet_len < 128)
|
else if(l4_packet_len >= 64 && l4_packet_len < 128)
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ unsigned int ndpi_timer_lt(const struct timeval *a, const struct timeval *b);
|
|||||||
void ndpi_timer_sub(const struct timeval *a, const struct timeval *b, struct timeval *result);
|
void ndpi_timer_sub(const struct timeval *a, const struct timeval *b, struct timeval *result);
|
||||||
void ndpi_timer_clear(struct timeval *a);
|
void ndpi_timer_clear(struct timeval *a);
|
||||||
unsigned int ndpi_timeval_to_milliseconds(struct timeval ts);
|
unsigned int ndpi_timeval_to_milliseconds(struct timeval ts);
|
||||||
|
unsigned int ndpi_timeval_to_microseconds(struct timeval ts);
|
||||||
void ndpi_log_timestamp(char *log_ts, u_int log_ts_len);
|
void ndpi_log_timestamp(char *log_ts, u_int log_ts_len);
|
||||||
|
|
||||||
#endif /* NDPI_CLASSIFY_H */
|
#endif /* NDPI_CLASSIFY_H */
|
||||||
|
|||||||
+30
-8
@@ -299,6 +299,8 @@ ndpi_merge_splt_arrays (const uint16_t *pkt_len, const struct timeval *pkt_time,
|
|||||||
tmp = pkt_time_twin[r];
|
tmp = pkt_time_twin[r];
|
||||||
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
||||||
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
||||||
|
if (merged_times[s+r] == 0)
|
||||||
|
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
|
||||||
ts_start = tmp;
|
ts_start = tmp;
|
||||||
r++;
|
r++;
|
||||||
} else if (r >= r_idx) {
|
} else if (r >= r_idx) {
|
||||||
@@ -306,27 +308,35 @@ ndpi_merge_splt_arrays (const uint16_t *pkt_len, const struct timeval *pkt_time,
|
|||||||
tmp = pkt_time[s];
|
tmp = pkt_time[s];
|
||||||
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
||||||
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
||||||
|
if (merged_times[s+r] == 0)
|
||||||
|
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
|
||||||
ts_start = tmp;
|
ts_start = tmp;
|
||||||
s++;
|
s++;
|
||||||
} else {
|
} else {
|
||||||
if (ndpi_timer_lt(&pkt_time[s], &pkt_time_twin[r])) {
|
if (ndpi_timer_lt(&pkt_time[s], &pkt_time_twin[r])) {
|
||||||
merged_lens[s+r] = pkt_len[s];
|
merged_lens[s+r] = pkt_len[s];
|
||||||
tmp = pkt_time[s];
|
tmp = pkt_time[s];
|
||||||
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
||||||
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
||||||
ts_start = tmp;
|
if (merged_times[s+r] == 0)
|
||||||
|
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
|
||||||
|
ts_start = tmp;
|
||||||
s++;
|
s++;
|
||||||
} else {
|
} else {
|
||||||
merged_lens[s+r] = pkt_len_twin[r];
|
merged_lens[s+r] = pkt_len_twin[r];
|
||||||
tmp = pkt_time_twin[r];
|
tmp = pkt_time_twin[r];
|
||||||
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
|
||||||
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
|
||||||
ts_start = tmp;
|
if (merged_times[s+r] == 0)
|
||||||
|
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
|
||||||
|
ts_start = tmp;
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
merged_times[0] = ndpi_timeval_to_milliseconds(start_m);
|
merged_times[0] = ndpi_timeval_to_milliseconds(start_m);
|
||||||
|
if (merged_times[0] == 0)
|
||||||
|
merged_times[0] = ndpi_timeval_to_microseconds(start_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* transform lens array to Markov chain */
|
/* transform lens array to Markov chain */
|
||||||
@@ -656,6 +666,18 @@ ndpi_timeval_to_milliseconds(struct timeval ts)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Calculate the microseconds representation of a timeval.
|
||||||
|
* \param ts Timeval
|
||||||
|
* \return unsigned int - Milliseconds
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
ndpi_timeval_to_microseconds(struct timeval ts)
|
||||||
|
{
|
||||||
|
unsigned int result = ts.tv_usec + ts.tv_sec * 1000 * 1000;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ndpi_log_timestamp(char *log_ts, u_int log_ts_len)
|
ndpi_log_timestamp(char *log_ts, u_int log_ts_len)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user