From: Danny Browning Date: Sat, 13 Jan 2018 14:45:25 +0000 (-0700) Subject: util-time: Add function to convert timespec to epoch millis X-Git-Tag: suricata-4.1.0-beta1~356 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aae50f8a7e7103be8ea9618edd470e797e4333d6;p=thirdparty%2Fsuricata.git util-time: Add function to convert timespec to epoch millis --- 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__ */