diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-07-25 12:36:16 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-07-25 12:36:16 +0000 |
commit | 70a2b635b7107f7554e9ae5c4f3262ee6eaacb83 (patch) | |
tree | 6773092c3053281f383ec6555e8757bf9387d515 /src/util/time.c | |
parent | 00b0f3c22aab316068326a26f89219eddc7f6ef9 (diff) | |
download | gnunet-70a2b635b7107f7554e9ae5c4f3262ee6eaacb83.tar.gz gnunet-70a2b635b7107f7554e9ae5c4f3262ee6eaacb83.zip |
clockskew code
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/util/time.c b/src/util/time.c index 10e1e6ffa..5ae05b0d7 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -26,6 +26,18 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_time_lib.h" | 27 | #include "gnunet_time_lib.h" |
28 | 28 | ||
29 | static long long timestamp_offset; | ||
30 | |||
31 | /** | ||
32 | * Set the timestamp offset for this instance. | ||
33 | * | ||
34 | * @param offset the offset to skew the locale time by | ||
35 | */ | ||
36 | void | ||
37 | GNUNET_TIME_set_offset(long long offset) | ||
38 | { | ||
39 | timestamp_offset = offset; | ||
40 | } | ||
29 | 41 | ||
30 | /** | 42 | /** |
31 | * Get the current time (works just as "time", just that we use the | 43 | * Get the current time (works just as "time", just that we use the |
@@ -42,7 +54,7 @@ GNUNET_TIME_absolute_get () | |||
42 | GETTIMEOFDAY (&tv, NULL); | 54 | GETTIMEOFDAY (&tv, NULL); |
43 | ret.abs_value = | 55 | ret.abs_value = |
44 | (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + | 56 | (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + |
45 | ((uint64_t) tv.tv_usec / 1000LL)); | 57 | ((uint64_t) tv.tv_usec / 1000LL)) + timestamp_offset; |
46 | return ret; | 58 | return ret; |
47 | } | 59 | } |
48 | 60 | ||