#endif
#include "main/thread.h"
+#include "time/timersub.h"
#include "packet_time.h"
{
return s_recent_packet.tv_sec;
}
+
+int64_t timersub_ms(const struct timeval* end, const struct timeval* start)
+{
+ if (!end)
+ end = &s_recent_packet; // use recent packet time instead when end is null
+
+ if (!start or !start->tv_sec or !end->tv_sec)
+ return 0; // can't really compare when values are not set
+
+ struct timeval difftime;
+ TIMERSUB(end, start, &difftime);
+ return difftime.tv_sec*1000 + difftime.tv_usec/1000;
+}
}
void packet_time_update(const struct timeval* cur_tv)
namespace snort
{
SO_PUBLIC time_t packet_time();
+SO_PUBLIC int64_t timersub_ms(const struct timeval* end, const struct timeval* start);
}
void packet_time_update(const struct timeval* cur_tv);