suricata
|
Go to the source code of this file.
Macros | |
#define | FROM_TIMEVAL(timev) { .tv_sec = (timev).tv_sec, .tv_nsec = (timev).tv_usec * 1000 } |
intialize a 'struct timespec' from a 'struct timeval'. More... | |
#define | TIMEVAL_DIFF_SEC(tv_new, tv_old) |
compare two 'struct timeval' and return the difference in seconds More... | |
#define | TIMEVAL_EARLIER(tv_first, tv_second) |
compare two 'struct timeval' and return if the first is earlier than the second More... | |
Functions | |
void | TimeInit (void) |
void | TimeDeinit (void) |
void | TimeSetByThread (const int thread_id, const struct timeval *tv) |
void | TimeGet (struct timeval *) |
void | TimeSet (struct timeval *) |
void | TimeSetToCurrentTime (void) |
set the time to "gettimeofday" meant for testing More... | |
void | TimeSetIncrementTime (uint32_t) |
increment the time in the engine More... | |
bool | TimeModeIsReady (void) |
void | TimeModeSetLive (void) |
void | TimeModeSetOffline (void) |
bool | TimeModeIsLive (void) |
struct tm * | SCLocalTime (time_t timep, struct tm *result) |
void | CreateTimeString (const struct timeval *ts, char *str, size_t size) |
void | CreateIsoTimeString (const struct timeval *ts, char *str, size_t size) |
void | CreateUtcIsoTimeString (const struct timeval *ts, char *str, size_t size) |
void | CreateFormattedTimeString (const struct tm *t, const char *fmt, char *str, size_t size) |
time_t | SCMkTimeUtc (struct tm *tp) |
Convert broken-down time to seconds since Unix epoch. More... | |
int | SCStringPatternToTime (char *string, const char **patterns, int num_patterns, struct tm *time) |
Parse a date string based on specified patterns. More... | |
int | SCTimeToStringPattern (time_t epoch, const char *pattern, char *str, size_t size) |
Convert epoch time to string pattern. More... | |
uint64_t | SCParseTimeSizeString (const char *str) |
Parse string containing time size (1m, 1h, etc). More... | |
uint64_t | SCGetSecondsUntil (const char *str, time_t epoch) |
Get seconds until a time unit changes. More... | |
uint64_t | SCTimespecAsEpochMillis (const struct timespec *ts) |
Definition in file util-time.h.
#define FROM_TIMEVAL | ( | timev | ) | { .tv_sec = (timev).tv_sec, .tv_nsec = (timev).tv_usec * 1000 } |
intialize a 'struct timespec' from a 'struct timeval'.
Definition at line 35 of file util-time.h.
#define TIMEVAL_DIFF_SEC | ( | tv_new, | |
tv_old | |||
) |
compare two 'struct timeval' and return the difference in seconds
Definition at line 38 of file util-time.h.
#define TIMEVAL_EARLIER | ( | tv_first, | |
tv_second | |||
) |
compare two 'struct timeval' and return if the first is earlier than the second
Definition at line 44 of file util-time.h.
void CreateFormattedTimeString | ( | const struct tm * | t, |
const char * | fmt, | ||
char * | str, | ||
size_t | size | ||
) |
Definition at line 250 of file util-time.c.
Referenced by LogCustomFormatWriteTimestamp().
void CreateIsoTimeString | ( | const struct timeval * | ts, |
char * | str, | ||
size_t | size | ||
) |
Definition at line 213 of file util-time.c.
References likely, SCLocalTime(), str, and ts.
Referenced by CreateEveHeader(), and EveAddFlow().
void CreateTimeString | ( | const struct timeval * | ts, |
char * | str, | ||
size_t | size | ||
) |
Definition at line 276 of file util-time.c.
References likely, SCLocalTime(), str, and ts.
Referenced by AlertFastLogger().
void CreateUtcIsoTimeString | ( | const struct timeval * | ts, |
char * | str, | ||
size_t | size | ||
) |
Definition at line 234 of file util-time.c.
References likely, SCUtcTime(), str, and ts.
uint64_t SCGetSecondsUntil | ( | const char * | str, |
time_t | epoch | ||
) |
Get seconds until a time unit changes.
str | String containing time type (minute, hour, etc). |
epoch | Epoch time. |
seconds. |
Definition at line 628 of file util-time.c.
References SCLocalTime(), and str.
struct tm* SCLocalTime | ( | time_t | timep, |
struct tm * | result | ||
) |
Definition at line 271 of file util-time.c.
Referenced by CreateIsoTimeString(), CreateTimeString(), LogCustomFormatWriteTimestamp(), SCGetSecondsUntil(), and SCTimeToStringPattern().
time_t SCMkTimeUtc | ( | struct tm * | tp | ) |
Convert broken-down time to seconds since Unix epoch.
This function is based on: http://www.catb.org/esr/time-programming (released to the public domain).
tp | Pointer to broken-down time. |
Seconds | since Unix epoch. |
Definition at line 449 of file util-time.c.
References MONTHSPERYEAR.
uint64_t SCParseTimeSizeString | ( | const char * | str | ) |
Parse string containing time size (1m, 1h, etc).
str | String to parse. |
size | on success. |
0 | on failure. |
Definition at line 577 of file util-time.c.
References str.
int SCStringPatternToTime | ( | char * | string, |
const char ** | patterns, | ||
int | num_patterns, | ||
struct tm * | tp | ||
) |
Parse a date string based on specified patterns.
This function is based on GNU C library getdate.
string | Date string to parse. |
patterns | String array containing patterns. |
num_patterns | Number of patterns to check. |
tp | Pointer to broken-down time. |
0 | on success. |
1 | on failure. |
Definition at line 492 of file util-time.c.
References strptime().
uint64_t SCTimespecAsEpochMillis | ( | const struct timespec * | ts | ) |
Definition at line 646 of file util-time.c.
References ts.
int SCTimeToStringPattern | ( | time_t | epoch, |
const char * | pattern, | ||
char * | str, | ||
size_t | size | ||
) |
Convert epoch time to string pattern.
This function converts epoch time to a string based on a pattern.
epoch | Epoch time. |
pattern | String pattern. |
str | Formated string. |
size | Size of allocated string. |
0 | on success. |
1 | on failure. |
Definition at line 548 of file util-time.c.
References SCLocalTime(), str, strlcpy(), and unlikely.
void TimeDeinit | ( | void | ) |
Definition at line 85 of file util-time.c.
References SCSpinDestroy.
void TimeGet | ( | struct timeval * | ) |
Definition at line 153 of file util-time.c.
References tv.
Referenced by TimeSetIncrementTime(), UTHBuildPacketIPV6Real(), and UTHBuildPacketReal().
void TimeInit | ( | void | ) |
Definition at line 77 of file util-time.c.
References SCSpinInit.
Referenced by GlobalsInitPreConfig().
bool TimeModeIsLive | ( | void | ) |
Definition at line 109 of file util-time.c.
bool TimeModeIsReady | ( | void | ) |
Definition at line 90 of file util-time.c.
void TimeModeSetLive | ( | void | ) |
Definition at line 97 of file util-time.c.
Referenced by RunModeIdsAFPAutoFp(), RunModeIdsAFPSingle(), RunModeIdsAFPWorkers(), RunModeIdsDpdkWorkers(), RunModeIdsErfDagAutoFp(), RunModeIdsErfDagSingle(), RunModeIdsErfDagWorkers(), RunModeIdsNflogAutoFp(), RunModeIdsNflogSingle(), RunModeIdsNflogWorkers(), RunModeIdsPcapAutoFp(), RunModeIdsPcapSingle(), RunModeIdsPcapWorkers(), RunModeIdsPfringAutoFp(), RunModeIdsPfringSingle(), RunModeIdsPfringWorkers(), RunModeIpsIPFWAutoFp(), RunModeIpsIPFWWorker(), RunModeIpsNFQAutoFp(), RunModeIpsNFQWorker(), and RunModeIpsWinDivertAutoFp().
void TimeModeSetOffline | ( | void | ) |
Definition at line 103 of file util-time.c.
Referenced by RunModeErfFileAutoFp(), RunModeErfFileSingle(), RunModeFilePcapAutoFp(), and RunModeFilePcapSingle().
void TimeSet | ( | struct timeval * | ) |
Definition at line 123 of file util-time.c.
Referenced by TimeSetIncrementTime(), and TimeSetToCurrentTime().
void TimeSetByThread | ( | const int | thread_id, |
const struct timeval * | tv | ||
) |
Definition at line 114 of file util-time.c.
void TimeSetIncrementTime | ( | uint32_t | tv_sec | ) |
increment the time in the engine
tv_sec | seconds to increment the time with |
Definition at line 182 of file util-time.c.
References TimeGet(), TimeSet(), and tv.
void TimeSetToCurrentTime | ( | void | ) |
set the time to "gettimeofday" meant for testing
Definition at line 142 of file util-time.c.