Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions
nstime.h File Reference
#include <wireshark.h>
#include <time.h>

Go to the source code of this file.

Classes

struct  nstime_t
 

Macros

#define NSTIME_INIT_ZERO   {0, 0}
 
#define NSTIME_INIT_UNSET   {0, INT_MAX}
 
#define NSTIME_INIT_SECS_NSECS(secs, nsecs)   {secs, nsecs}
 
#define NSTIME_INIT_SECS_USECS(secs, usecs)   {secs, usecs*1000}
 
#define NSTIME_INIT_SECS_MSECS(secs, msecs)   {secs, msecs*1000000}
 
#define NSTIME_INIT_SECS(secs)   {secs, 0}
 
#define NSTIME_INIT_MAX   {sizeof(time_t) > sizeof(int) ? LONG_MAX : INT_MAX, INT_MAX}
 
#define nstime_add(sum, a)   nstime_sum(sum, sum, a)
 
#define nstime_subtract(sum, a)   nstime_delta(sum, sum, a)
 
#define NSTIME_ISO8601_BUFSIZE   sizeof("YYYY-MM-DDTHH:MM:SS.123456789Z")
 
#define NSTIME_UNIX_BUFSIZE   (20+10+1)
 
#define WS_TSPREC_MAX   9
 
#define NUM_WS_TSPREC_VALS   (WS_TSPREC_MAX + 1)
 

Enumerations

enum  iso8601_fmt_e { ISO8601_DATETIME , ISO8601_DATETIME_BASIC , ISO8601_DATETIME_AUTO }
 
enum  ws_tsprec_e {
  WS_TSPREC_SEC = 0 , WS_TSPREC_100_MSEC = 1 , WS_TSPREC_10_MSEC = 2 , WS_TSPREC_MSEC = 3 ,
  WS_TSPREC_100_USEC = 4 , WS_TSPREC_10_USEC = 5 , WS_TSPREC_USEC = 6 , WS_TSPREC_100_NSEC = 7 ,
  WS_TSPREC_10_NSEC = 8 , WS_TSPREC_NSEC = 9
}
 

Functions

WS_DLL_PUBLIC void nstime_set_zero (nstime_t *nstime)
 
WS_DLL_PUBLIC bool nstime_is_zero (const nstime_t *nstime)
 
WS_DLL_PUBLIC void nstime_set_unset (nstime_t *nstime)
 
WS_DLL_PUBLIC bool nstime_is_unset (const nstime_t *nstime)
 
WS_DLL_PUBLIC void nstime_copy (nstime_t *a, const nstime_t *b)
 
WS_DLL_PUBLIC void nstime_delta (nstime_t *delta, const nstime_t *b, const nstime_t *a)
 
WS_DLL_PUBLIC void nstime_sum (nstime_t *sum, const nstime_t *a, const nstime_t *b)
 
WS_DLL_PUBLIC int nstime_cmp (const nstime_t *a, const nstime_t *b)
 
WS_DLL_PUBLIC unsigned nstime_hash (const nstime_t *nstime)
 
WS_DLL_PUBLIC double nstime_to_msec (const nstime_t *nstime)
 
WS_DLL_PUBLIC double nstime_to_sec (const nstime_t *nstime)
 
WS_DLL_PUBLIC bool filetime_to_nstime (nstime_t *nstime, uint64_t filetime)
 
WS_DLL_PUBLIC bool filetime_ns_to_nstime (nstime_t *nstime, uint64_t nsfiletime)
 
WS_DLL_PUBLIC bool filetime_1sec_to_nstime (nstime_t *nstime, uint64_t filetime)
 
WS_DLL_PUBLIC const char * iso8601_to_nstime (nstime_t *nstime, const char *ptr, iso8601_fmt_e format)
 
WS_DLL_PUBLIC const char * unix_epoch_to_nstime (nstime_t *nstime, const char *ptr)
 
WS_DLL_PUBLIC size_t nstime_to_iso8601 (char *buf, size_t buf_size, const nstime_t *nstime)
 
WS_DLL_PUBLIC void nstime_to_unix (char *buf, size_t buf_size, const nstime_t *nstime)
 

Detailed Description

Definition of data structure to hold time values with nanosecond resolution

Macro Definition Documentation

◆ nstime_add

#define nstime_add (   sum,
 
)    nstime_sum(sum, sum, a)

sum += a

◆ nstime_subtract

#define nstime_subtract (   sum,
 
)    nstime_delta(sum, sum, a)

sum -= a

Enumeration Type Documentation

◆ iso8601_fmt_e

Enumerator
ISO8601_DATETIME_BASIC 

e.g. 2014-07-04T12:34:56.789+00:00

ISO8601_DATETIME_AUTO 

ISO8601 Basic format, i.e. no - : separators

Function Documentation

◆ filetime_1sec_to_nstime()

WS_DLL_PUBLIC bool filetime_1sec_to_nstime ( nstime_t nstime,
uint64_t  filetime 
)

converts time like Windows FILETIME, but expressed in seconds rather than tenths of microseconds, to nstime, returns true on success, false on failure

◆ filetime_ns_to_nstime()

WS_DLL_PUBLIC bool filetime_ns_to_nstime ( nstime_t nstime,
uint64_t  nsfiletime 
)

converts time like Windows FILETIME, but expressed in nanoseconds rather than tenths of microseconds, to nstime, returns true on success, false on failure

◆ filetime_to_nstime()

WS_DLL_PUBLIC bool filetime_to_nstime ( nstime_t nstime,
uint64_t  filetime 
)

converts Windows FILETIME to nstime, returns true on success, false on failure

◆ iso8601_to_nstime()

WS_DLL_PUBLIC const char * iso8601_to_nstime ( nstime_t nstime,
const char *  ptr,
iso8601_fmt_e  format 
)

parse an ISO 8601 format datetime string to nstime, returns pointer to the first character after the last character, NULL on failure Note that nstime is set to unset in the case of failure

◆ nstime_cmp()

WS_DLL_PUBLIC int nstime_cmp ( const nstime_t a,
const nstime_t b 
)

compare two times are return a value similar to memcmp() or strcmp().

a > b : > 0 a = b : 0 a < b : < 0

◆ nstime_copy()

WS_DLL_PUBLIC void nstime_copy ( nstime_t a,
const nstime_t b 
)

duplicate the current time

a = b

function: nstime_copy

a = b

◆ nstime_delta()

WS_DLL_PUBLIC void nstime_delta ( nstime_t delta,
const nstime_t b,
const nstime_t a 
)

calculate the delta between two times (can be negative!)

delta = b-a

Note that it is acceptable for two or more of the arguments to point at the same structure.

◆ nstime_is_zero()

WS_DLL_PUBLIC bool nstime_is_zero ( const nstime_t nstime)

is the given nstime_t currently zero?

◆ nstime_set_unset()

WS_DLL_PUBLIC void nstime_set_unset ( nstime_t nstime)

set the given nstime_t to (0,maxint) to mark it as "unset" That way we can find the first frame even when a timestamp is zero (fix for bug 1056)

◆ nstime_set_zero()

WS_DLL_PUBLIC void nstime_set_zero ( nstime_t nstime)

set the given nstime_t to zero

◆ nstime_sum()

WS_DLL_PUBLIC void nstime_sum ( nstime_t sum,
const nstime_t a,
const nstime_t b 
)

calculate the sum of two times

sum = a+b

Note that it is acceptable for two or more of the arguments to point at the same structure.

◆ nstime_to_msec()

WS_DLL_PUBLIC double nstime_to_msec ( const nstime_t nstime)

converts nstime to double, time base is milli seconds

◆ nstime_to_sec()

WS_DLL_PUBLIC double nstime_to_sec ( const nstime_t nstime)

converts nstime to double, time base is seconds

◆ unix_epoch_to_nstime()

WS_DLL_PUBLIC const char * unix_epoch_to_nstime ( nstime_t nstime,
const char *  ptr 
)

parse an Unix epoch timestamp format datetime string to nstime, returns pointer to the first character after the last character, NULL on failure Note that nstime is set to unset in the case of failure