Flowgrind
Advanced TCP traffic generator
fg_time.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2014 Alexander Zimmermann <alexander.zimmermann@netapp.com>
8  * Copyright (C) 2010-2013 Christian Samsel <christian.samsel@rwth-aachen.de>
9  * Copyright (C) 2007-2008 Daniel Schaffrath <daniel.schaffrath@mac.com>
10  *
11  * This file is part of Flowgrind.
12  *
13  * Flowgrind is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * Flowgrind is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with Flowgrind. If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27 
28 #ifndef _FG_TIME_H_
29 #define _FG_TIME_H_
30 
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif /* HAVE_CONFIG_H */
34 
35 #include <sys/time.h>
36 #include <time.h>
37 #include <stdbool.h>
38 
39 #ifndef NSEC_PER_SEC
40 
41 #define NSEC_PER_SEC 1000000000L
42 #endif /* NSEC_PER_SEC */
43 
54 const char *ctimenow_r(char *buf, size_t size, bool ns);
55 
56 
67 const char *ctimenow(bool ns);
68 
80 const char *ctimespec_r(const struct timespec *tp, char *buf, size_t size,
81  bool ns);
82 
94 const char *ctimespec(const struct timespec *tp, bool ns);
95 
106 double time_diff(const struct timespec *tp1, const struct timespec *tp2);
107 
114 double time_diff_now(const struct timespec *tp);
115 
124 bool time_is_after(const struct timespec *tp1, const struct timespec *tp2);
125 
135 bool normalize_tp(struct timespec *tp);
136 
143 void time_add(struct timespec *tp, double seconds);
144 
156 int gettime(struct timespec *tp);
157 
158 #endif /* _FG_TIME_H_ */
time_diff_now
double time_diff_now(const struct timespec *tp)
Returns time difference between now and the specific point in time tp.
Definition: fg_time.c:101
time_is_after
bool time_is_after(const struct timespec *tp1, const struct timespec *tp2)
Returns true if second point in time tp2 is chronologically after the first point in time tp1.
Definition: fg_time.c:110
ctimenow_r
const char * ctimenow_r(char *buf, size_t size, bool ns)
Returns the current wall-clock time as null-terminated string.
Definition: fg_time.c:47
ctimespec_r
const char * ctimespec_r(const struct timespec *tp, char *buf, size_t size, bool ns)
Converts timespec struct tp into a null-terminated string.
Definition: fg_time.c:66
normalize_tp
bool normalize_tp(struct timespec *tp)
Normalizes timespec struct tp.
Definition: fg_time.c:119
ctimespec
const char * ctimespec(const struct timespec *tp, bool ns)
Converts timespec struct tp into a null-terminated string.
Definition: fg_time.c:86
ctimenow
const char * ctimenow(bool ns)
Returns the current wall-clock time as null-terminated string.
Definition: fg_time.c:56
time_diff
double time_diff(const struct timespec *tp1, const struct timespec *tp2)
Returns the time difference between two the specific points in time tp1 and tp2.
Definition: fg_time.c:95
gettime
int gettime(struct timespec *tp)
Returns the current wall-clock time with nanosecond precision.
Definition: fg_time.c:145
config.h
time_add
void time_add(struct timespec *tp, double seconds)
Add an amount of time seconds to a specific point in time tp.
Definition: fg_time.c:136