diff --git a/src/util-time.c b/src/util-time.c index 12d174f0f6..ce226fca2d 100644 --- a/src/util-time.c +++ b/src/util-time.c @@ -593,3 +593,8 @@ uint64_t SCGetSecondsUntil (const char *str, time_t epoch) return seconds; } + +uint64_t SCTimespecAsEpochMillis(const struct timespec* ts) +{ + return ts->tv_sec * 1000L + ts->tv_nsec / 1000000L; +} diff --git a/src/util-time.h b/src/util-time.h index 4b2c82e176..00c254b97b 100644 --- a/src/util-time.h +++ b/src/util-time.h @@ -62,6 +62,6 @@ int SCTimeToStringPattern (time_t epoch, const char *pattern, char *str, size_t size); uint64_t SCParseTimeSizeString (const char *str); uint64_t SCGetSecondsUntil (const char *str, time_t epoch); - +uint64_t SCTimespecAsEpochMillis(const struct timespec *ts); #endif /* __UTIL_TIME_H__ */