GNUnet 0.28.1-dev.2-13-g57ceb9dfb
 
Loading...
Searching...
No Matches
Time library

Time and time calculations. More...

Collaboration diagram for Time library:

Data Structures

struct  GNUNET_TIME_Absolute
 Time for absolute times used by GNUnet, in microseconds. More...
 
struct  GNUNET_TIME_Timestamp
 Time for timestamps used by GNUnet, in microseconds rounded to seconds. More...
 
struct  GNUNET_TIME_Relative
 Time for relative time used by GNUnet, in microseconds. More...
 
struct  GNUNET_TIME_RelativeNBO
 Time for relative time used by GNUnet, in microseconds and in network byte order. More...
 
struct  GNUNET_TIME_AbsoluteNBO
 Time for absolute time used by GNUnet, in microseconds and in network byte order. More...
 
struct  GNUNET_TIME_TimestampNBO
 Time for timestamps used by GNUnet, in seconds and in network byte order. More...
 

Macros

#define GNUNET_TIME_UNIT_ZERO   ((struct GNUNET_TIME_Relative){0})
 Relative time zero.
 
#define GNUNET_TIME_UNIT_ZERO_ABS   ((struct GNUNET_TIME_Absolute){0})
 Absolute time zero.
 
#define GNUNET_TIME_UNIT_ZERO_TS   ((struct GNUNET_TIME_Timestamp){{0}})
 Timestamp of zero.
 
#define GNUNET_TIME_UNIT_MICROSECONDS   GNUNET_TIME_relative_get_unit_ ()
 One microsecond, our basic time unit.
 
#define GNUNET_TIME_UNIT_MILLISECONDS   GNUNET_TIME_relative_get_millisecond_ ()
 One millisecond.
 
#define GNUNET_TIME_UNIT_SECONDS   GNUNET_TIME_relative_get_second_ ()
 One second.
 
#define GNUNET_TIME_UNIT_MINUTES   GNUNET_TIME_relative_get_minute_ ()
 One minute.
 
#define GNUNET_TIME_UNIT_HOURS   GNUNET_TIME_relative_get_hour_ ()
 One hour.
 
#define GNUNET_TIME_UNIT_DAYS
 One day.
 
#define GNUNET_TIME_UNIT_WEEKS
 One week.
 
#define GNUNET_TIME_UNIT_MONTHS
 One month (30 days).
 
#define GNUNET_TIME_UNIT_YEARS
 One year (365 days).
 
#define GNUNET_TIME_UNIT_FOREVER_REL    ((struct GNUNET_TIME_Relative){UINT64_MAX})
 Constant used to specify "forever".
 
#define GNUNET_TIME_UNIT_FOREVER_ABS    ((struct GNUNET_TIME_Absolute){UINT64_MAX})
 Constant used to specify "forever".
 
#define GNUNET_TIME_UNIT_NEVER_ABS    ((struct GNUNET_TIME_Absolute){UINT64_MAX})
 
#define GNUNET_TIME_UNIT_FOREVER_TS    ((struct GNUNET_TIME_Timestamp){{UINT64_MAX}})
 Constant used to specify "forever".
 
#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 Threshold after which exponential backoff should not increase (15 m).
 
#define GNUNET_TIME_STD_BACKOFF(r)
 Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of 2 up unto a maximum of 15 m.
 
#define GNUNET_TIME_absolute_cmp(t1, op, t2)    ((void) (1 op 2), (t1).abs_value_us op (t2).abs_value_us)
 Compare two absolute times.
 
#define GNUNET_TIME_timestamp_cmp(t1, op, t2)    GNUNET_TIME_absolute_cmp ((t1).abs_time,op,(t2).abs_time)
 Compare two timestamps.
 
#define GNUNET_TIME_relative_cmp(t1, op, t2)    ((void) (1 op 2), (t1).rel_value_us op (t2).rel_value_us)
 Compare two relative times.
 

Enumerations

enum  GNUNET_TIME_RounderInterval {
  GNUNET_TIME_RI_NONE = 0 , GNUNET_TIME_RI_SECOND , GNUNET_TIME_RI_MINUTE , GNUNET_TIME_RI_HOUR ,
  GNUNET_TIME_RI_DAY , GNUNET_TIME_RI_WEEK , GNUNET_TIME_RI_MONTH , GNUNET_TIME_RI_QUARTER ,
  GNUNET_TIME_RI_YEAR
}
 Quantities by which we support round up absolute time values. More...
 

Functions

enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
 Convert a given fancy human-readable time to our internal representation.
 
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_timestamp (const char *fancy_time, struct GNUNET_TIME_Timestamp *atime)
 Convert a given fancy human-readable time to our internal representation.
 
const char * GNUNET_STRINGS_timestamp_to_string (struct GNUNET_TIME_Timestamp t)
 Like asctime, except for GNUnet time.
 
const char * GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
 Like asctime, except for GNUnet time.
 
const char * GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, int do_round)
 Give relative time in human-readable fancy format.
 
enum GNUNET_TIME_RounderInterval GNUNET_TIME_relative_to_round_interval (struct GNUNET_TIME_Relative rel)
 Convert a relative time to the corresponding rounding interval.
 
enum GNUNET_GenericReturnValue GNUNET_TIME_string_to_round_interval (const char *ri_str, enum GNUNET_TIME_RounderInterval *ri)
 Convert rounding interval given as a string to the enum value.
 
const char * GNUNET_TIME_round_interval2s (enum GNUNET_TIME_RounderInterval ri)
 Convert rounding interval to string.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_round_up (struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
 Round up the given at to the interval ri.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_round_up_utc (struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
 Round up the given at to the interval ri, using UTC calendar boundaries.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_round_down (struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
 Round @at down to the start of the next interval ri.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_round_down_utc (struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
 Round @at down to the start of the next interval ri, using UTC calendar boundaries.
 
const char * GNUNET_TIME_timestamp2s (struct GNUNET_TIME_Timestamp ts)
 Convert ts to human-readable timestamp.
 
const char * GNUNET_TIME_absolute2s (struct GNUNET_TIME_Absolute ts)
 Like asctime, except for GNUnet time.
 
const char * GNUNET_TIME_relative2s (struct GNUNET_TIME_Relative delta, bool do_round)
 Give relative time in human-readable fancy format.
 
struct GNUNET_TIME_Relative GNUNET_TIME_randomized_backoff (struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold)
 Randomized exponential back-off, starting at 1 ms and going up by a factor of 2+r, where 0 <= r <= 0.5, up to a maximum of the given threshold.
 
struct GNUNET_TIME_Relative GNUNET_TIME_randomize (struct GNUNET_TIME_Relative r)
 Return a random time value between 0.5*r and 1.5*r.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_ (void)
 Return relative time of 0ms.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_ (void)
 Return absolute time of 0ms.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit_ (void)
 Return relative time of 1 microsecond.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_millisecond_ (void)
 Return relative time of 1ms.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_second_ (void)
 Return relative time of 1s.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_minute_ (void)
 Return relative time of 1 minute.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_hour_ (void)
 Return relative time of 1 hour.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_ (void)
 Return "forever".
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_ (void)
 Return "forever".
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get (void)
 Get the current time.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
 Convert relative time to an absolute time in the future.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp (struct GNUNET_TIME_Relative rel)
 Convert relative time to a timestamp in the future.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at)
 Round an absolute time to a timestamp.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_get (void)
 Get timestamp representing the current time.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
 Return the minimum of two relative time values.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
 Return the maximum of two relative time values.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
 Return the minimum of two absolute time values.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
 Return the maximum of two absolute time values.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_round_down (struct GNUNET_TIME_Absolute at, struct GNUNET_TIME_Relative rt)
 Round down absolute time at to multiple of rt.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_max (struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2)
 Return the maximum of two timestamps.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_min (struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2)
 Return the minimum of two timestamps.
 
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future)
 Given a timestamp in the future, how much time remains until then?
 
bool GNUNET_TIME_absolute_approx_eq (struct GNUNET_TIME_Absolute a1, struct GNUNET_TIME_Absolute a2, struct GNUNET_TIME_Relative t)
 Test if a1 and a2 are equal within a margin of error of t.
 
struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total)
 Calculate the estimate time of arrival/completion for an operation.
 
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
 Compute the time difference between the given start and end times.
 
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence)
 Get the duration of an operation as the difference of the current time and the given start time "hence".
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
 Add a given relative duration to the given start time.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
 Subtract a given relative duration from the given start time.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply_double (struct GNUNET_TIME_Relative rel, double factor)
 Multiply relative time by a given factor.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, unsigned long long factor)
 Multiply relative time by a given factor.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply (struct GNUNET_TIME_Relative rel, unsigned long long factor)
 Saturating multiply relative time by a given factor.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, unsigned long long factor)
 Divide relative time by a given factor.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
 Add relative times together.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
 Subtract relative timestamp from the other.
 
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a)
 Convert relative time to network byte order.
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a)
 Convert relative time from network byte order.
 
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a)
 Convert absolute time to network byte order.
 
struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton (struct GNUNET_TIME_Timestamp t)
 Convert timestamp to network byte order.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch)
 Convert milliseconds after the UNIX epoch to absolute time.
 
bool GNUNET_TIME_absolute_is_never (struct GNUNET_TIME_Absolute abs)
 Test if abs is never.
 
bool GNUNET_TIME_absolute_is_past (struct GNUNET_TIME_Absolute abs)
 Test if abs is truly in the past (excluding now).
 
bool GNUNET_TIME_absolute_is_zero (struct GNUNET_TIME_Absolute abs)
 Test if abs is truly zero.
 
bool GNUNET_TIME_absolute_is_future (struct GNUNET_TIME_Absolute abs)
 Test if abs is truly in the future (excluding now).
 
bool GNUNET_TIME_relative_is_forever (struct GNUNET_TIME_Relative rel)
 Test if rel is forever.
 
bool GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel)
 Test if rel is zero.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s (uint64_t s_after_epoch)
 Convert seconds after the UNIX epoch to absolute time.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_from_s (uint64_t s_after_epoch)
 Convert seconds after the UNIX epoch to timestamp.
 
uint64_t GNUNET_TIME_timestamp_to_s (struct GNUNET_TIME_Timestamp ts)
 Convert timestamp to number of seconds after the UNIX epoch.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a)
 Convert absolute time from network byte order.
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_ntoh (struct GNUNET_TIME_TimestampNBO tn)
 Convert timestamp from network byte order.
 
void GNUNET_TIME_set_offset (long long offset)
 Set the timestamp offset for this instance.
 
long long GNUNET_TIME_get_offset (void)
 Get the timestamp offset for this instance.
 
unsigned int GNUNET_TIME_get_current_year (void)
 Return the current year (e.g.
 
struct GNUNET_TIME_Absolute GNUNET_TIME_year_to_time (unsigned int year)
 Convert a year to an expiration time of January 1st of that year.
 
unsigned int GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at)
 Convert an expiration time to the respective year (rounds)
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Obtain the current time and make sure it is monotonically increasing.
 

Detailed Description

Time and time calculations.

Macro Definition Documentation

◆ GNUNET_TIME_UNIT_ZERO

#define GNUNET_TIME_UNIT_ZERO   ((struct GNUNET_TIME_Relative){0})

Relative time zero.

Definition at line 131 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_ZERO_ABS

#define GNUNET_TIME_UNIT_ZERO_ABS   ((struct GNUNET_TIME_Absolute){0})

Absolute time zero.

Definition at line 136 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_ZERO_TS

#define GNUNET_TIME_UNIT_ZERO_TS   ((struct GNUNET_TIME_Timestamp){{0}})

Timestamp of zero.

Definition at line 141 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MICROSECONDS

#define GNUNET_TIME_UNIT_MICROSECONDS   GNUNET_TIME_relative_get_unit_ ()

One microsecond, our basic time unit.

Definition at line 146 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MILLISECONDS

#define GNUNET_TIME_UNIT_MILLISECONDS   GNUNET_TIME_relative_get_millisecond_ ()

One millisecond.

Definition at line 151 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_SECONDS

#define GNUNET_TIME_UNIT_SECONDS   GNUNET_TIME_relative_get_second_ ()

One second.

Definition at line 156 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MINUTES

#define GNUNET_TIME_UNIT_MINUTES   GNUNET_TIME_relative_get_minute_ ()

One minute.

Definition at line 161 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_HOURS

#define GNUNET_TIME_UNIT_HOURS   GNUNET_TIME_relative_get_hour_ ()

One hour.

Definition at line 166 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_DAYS

#define GNUNET_TIME_UNIT_DAYS
Value:
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486

One day.

Definition at line 171 of file gnunet_time_lib.h.

196 {UINT64_MAX})
197
203 ((struct GNUNET_TIME_Absolute){UINT64_MAX})
205 ((struct GNUNET_TIME_Absolute){UINT64_MAX})
206
212 ((struct GNUNET_TIME_Timestamp){{UINT64_MAX}})
213
214
220
221
228#define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min ( \
229 GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, \
230 GNUNET_TIME_relative_multiply ( \
231 GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, (r)), 2))
232
233
238{
243
248
253
258
263
268
273
278
283};
284
285
297
298
307GNUNET_TIME_string_to_round_interval (const char *ri_str,
309
310
317const char *
319
320
336
337
354
355
371
372
389
390
399const char *
401
402
413const char *
415
416
427const char *
429 bool do_round);
430
431
443 struct GNUNET_TIME_Relative threshold);
444
445
454
455
461
462
468
469
475
476
482
483
489
490
496
497
503
504
510
511
517
518
526
527
537
538
548
549
558
559
567
568
577#define GNUNET_TIME_absolute_cmp(t1,op,t2) \
578 ((void) (1 op 2), (t1).abs_value_us op (t2).abs_value_us)
579
580
589#define GNUNET_TIME_timestamp_cmp(t1,op,t2) \
590 GNUNET_TIME_absolute_cmp ((t1).abs_time,op,(t2).abs_time)
591
592
601#define GNUNET_TIME_relative_cmp(t1,op,t2) \
602 ((void) (1 op 2), (t1).rel_value_us op (t2).rel_value_us)
603
604
614 struct GNUNET_TIME_Relative t2);
615
616
626 struct GNUNET_TIME_Relative t2);
627
628
638 struct GNUNET_TIME_Absolute t2);
639
640
650 struct GNUNET_TIME_Absolute t2);
651
652
662 struct GNUNET_TIME_Relative rt);
663
664
674 struct GNUNET_TIME_Timestamp t2);
675
676
686 struct GNUNET_TIME_Timestamp t2);
687
688
698
699
709bool
711 struct GNUNET_TIME_Absolute a2,
712 struct GNUNET_TIME_Relative t);
713
714
727 uint64_t finished,
728 uint64_t total);
729
730
743
744
754
755
767
768
780
781
791 double factor);
792
802 unsigned long long factor);
803
804
814 unsigned long long factor);
815
816
826 unsigned long long factor);
827
828
838 struct GNUNET_TIME_Relative a2);
839
840
850 struct GNUNET_TIME_Relative a2);
851
852
861
862
871
872
881
882
891
892
900GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch);
901
902
908bool
910
911
917bool
919
920
926bool
928
929
935bool
937
938
944bool
946
947
953bool
955
956
964GNUNET_TIME_absolute_from_s (uint64_t s_after_epoch);
965
966
974GNUNET_TIME_timestamp_from_s (uint64_t s_after_epoch);
975
976
983uint64_t
985
986
995
996
1005
1006
1012void
1013GNUNET_TIME_set_offset (long long offset);
1014
1015
1021long long
1023
1024
1028unsigned int
1030
1031
1039GNUNET_TIME_year_to_time (unsigned int year);
1040
1041
1048unsigned int
1050
1051
1056
1057
1078 const struct GNUNET_CONFIGURATION_Handle *cfg);
1079
1080
1081#if 0 /* keep Emacsens' auto-indent happy */
1082{
1083#endif
1084#ifdef __cplusplus
1085}
1086#endif
1087
1088/* ifndef GNUNET_TIME_LIB_H */
1089#endif
1090
/* end of group time */
1092
/* end of group addition */
1094
1095/* end of gnunet_time_lib.h */
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static int end
Set if we are to shutdown all services (including ARM).
Definition gnunet-arm.c:33
static bool finished
Set to true once we are finished and should exit after sending our final message to the parent.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static void do_round(void *cls)
Send out PUSHes and PULLs, possibly update #view, samplers.
static struct GNUNET_TIME_Relative duration
Option '-d': duration of the mapping.
Definition gnunet-vpn.c:90
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_TIME_Absolute GNUNET_TIME_year_to_time(unsigned int year)
Convert a year to an expiration time of January 1st of that year.
Definition time.c:801
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition time.c:344
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition time.c:133
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_hour_(void)
Return relative time of 1 hour.
Definition time.c:187
const char * GNUNET_TIME_relative2s(struct GNUNET_TIME_Relative delta, bool do_round)
Give relative time in human-readable fancy format.
Definition time.c:264
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s(uint64_t s_after_epoch)
Convert seconds after the UNIX epoch to absolute time.
Definition time.c:701
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition time.c:626
bool GNUNET_TIME_absolute_is_future(struct GNUNET_TIME_Absolute abs)
Test if abs is truly in the future (excluding now).
Definition time.c:677
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_millisecond_(void)
Return relative time of 1ms.
Definition time.c:160
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
Definition time.c:529
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
Definition time.c:352
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_minute_(void)
Return relative time of 1 minute.
Definition time.c:178
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_min(struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2)
Return the minimum of two timestamps.
Definition time.c:384
enum GNUNET_GenericReturnValue GNUNET_TIME_string_to_round_interval(const char *ri_str, enum GNUNET_TIME_RounderInterval *ri)
Convert rounding interval given as a string to the enum value.
Definition time.c:1375
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_(void)
Return absolute time of 0ms.
Definition time.c:142
struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp(struct GNUNET_TIME_Relative rel)
Convert relative time to a timestamp in the future.
Definition time.c:336
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_from_s(uint64_t s_after_epoch)
Convert seconds after the UNIX epoch to timestamp.
Definition time.c:714
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition time.c:406
GNUNET_TIME_RounderInterval
Quantities by which we support round up absolute time values.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the maximum of two absolute time values.
Definition time.c:368
unsigned int GNUNET_TIME_get_current_year(void)
Return the current year (e.g.
Definition time.c:747
bool GNUNET_TIME_absolute_is_zero(struct GNUNET_TIME_Absolute abs)
Test if abs is truly zero.
Definition time.c:844
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_ms(uint64_t ms_after_epoch)
Convert milliseconds after the UNIX epoch to absolute time.
Definition time.c:687
bool GNUNET_TIME_relative_is_zero(struct GNUNET_TIME_Relative rel)
Test if rel is zero.
Definition time.c:660
bool GNUNET_TIME_absolute_is_never(struct GNUNET_TIME_Absolute abs)
Test if abs is never.
Definition time.c:646
struct GNUNET_TIME_Relative GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold)
Randomized exponential back-off, starting at 1 ms and going up by a factor of 2+r,...
Definition time.c:830
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition time.c:601
const char * GNUNET_TIME_absolute2s(struct GNUNET_TIME_Absolute ts)
Like asctime, except for GNUnet time.
Definition time.c:239
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_(void)
Return "forever".
Definition time.c:205
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_(void)
Return "forever".
Definition time.c:196
#define GNUNET_TIME_UNIT_NEVER_ABS
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_get(void)
Get timestamp representing the current time.
Definition time.c:125
uint64_t GNUNET_TIME_timestamp_to_s(struct GNUNET_TIME_Timestamp ts)
Convert timestamp to number of seconds after the UNIX epoch.
Definition time.c:728
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply_double(struct GNUNET_TIME_Relative rel, double factor)
Multiply relative time by a given factor.
Definition time.c:506
bool GNUNET_TIME_relative_is_forever(struct GNUNET_TIME_Relative rel)
Test if rel is forever.
Definition time.c:653
struct GNUNET_TIME_Absolute GNUNET_TIME_round_down_utc(struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
Round @at down to the start of the next interval ri, using UTC calendar boundaries.
Definition time.c:1302
long long GNUNET_TIME_get_offset(void)
Get the timestamp offset for this instance.
Definition time.c:56
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition time.c:737
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_round_down(struct GNUNET_TIME_Absolute at, struct GNUNET_TIME_Relative rt)
Round down absolute time at to multiple of rt.
Definition time.c:392
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition time.c:583
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
Definition time.c:49
struct GNUNET_TIME_Relative GNUNET_TIME_randomize(struct GNUNET_TIME_Relative r)
Return a random time value between 0.5*r and 1.5*r.
Definition time.c:851
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Subtract a given relative duration from the given start time.
Definition time.c:471
unsigned int GNUNET_TIME_time_to_year(struct GNUNET_TIME_Absolute at)
Convert an expiration time to the respective year (rounds)
Definition time.c:761
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_second_(void)
Return relative time of 1s.
Definition time.c:169
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit_(void)
Return relative time of 1 microsecond.
Definition time.c:151
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition time.c:316
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
Definition time.c:360
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition time.c:616
#define GNUNET_TIME_UNIT_FOREVER_TS
Constant used to specify "forever".
enum GNUNET_TIME_RounderInterval GNUNET_TIME_relative_to_round_interval(struct GNUNET_TIME_Relative rel)
Convert a relative time to the corresponding rounding interval.
Definition time.c:1312
bool GNUNET_TIME_absolute_approx_eq(struct GNUNET_TIME_Absolute a1, struct GNUNET_TIME_Absolute a2, struct GNUNET_TIME_Relative t)
Test if a1 and a2 are equal within a margin of error of t.
Definition time.c:63
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition time.c:452
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_max(struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2)
Return the maximum of two timestamps.
Definition time.c:376
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_monotonic(const struct GNUNET_CONFIGURATION_Handle *cfg)
Obtain the current time and make sure it is monotonically increasing.
Definition time.c:860
struct GNUNET_TIME_Absolute GNUNET_TIME_round_down(struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
Round @at down to the start of the next interval ri.
Definition time.c:1292
struct GNUNET_TIME_Absolute GNUNET_TIME_round_up(struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
Round up the given at to the interval ri.
Definition time.c:1272
struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton(struct GNUNET_TIME_Timestamp t)
Convert timestamp to network byte order.
Definition time.c:91
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition time.c:548
const char * GNUNET_TIME_round_interval2s(enum GNUNET_TIME_RounderInterval ri)
Convert rounding interval to string.
Definition time.c:1400
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition time.c:423
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636
#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD
Threshold after which exponential backoff should not increase (15 m).
bool GNUNET_TIME_absolute_is_past(struct GNUNET_TIME_Absolute abs)
Test if abs is truly in the past (excluding now).
Definition time.c:667
struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta(struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total)
Calculate the estimate time of arrival/completion for an operation.
Definition time.c:562
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_ntoh(struct GNUNET_TIME_TimestampNBO tn)
Convert timestamp from network byte order.
Definition time.c:101
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_TIME_Absolute GNUNET_TIME_round_up_utc(struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri)
Round up the given at to the interval ri, using UTC calendar boundaries.
Definition time.c:1282
const char * GNUNET_TIME_timestamp2s(struct GNUNET_TIME_Timestamp ts)
Convert ts to human-readable timestamp.
Definition time.c:214
struct GNUNET_TIME_Timestamp GNUNET_TIME_absolute_to_timestamp(struct GNUNET_TIME_Absolute at)
Round an absolute time to a timestamp.
Definition time.c:79
@ GNUNET_TIME_RI_NONE
No rounding up.
@ GNUNET_TIME_RI_MINUTE
Round up to the next minute.
@ GNUNET_TIME_RI_QUARTER
Round up to the next quarter.
@ GNUNET_TIME_RI_HOUR
Round up to the next hour.
@ GNUNET_TIME_RI_SECOND
Round up to a multiple of seconds.
@ GNUNET_TIME_RI_WEEK
Round up to the next calendar week.
@ GNUNET_TIME_RI_DAY
Round up to the next day.
@ GNUNET_TIME_RI_YEAR
Round up to the next year.
@ GNUNET_TIME_RI_MONTH
Round up to the next month.
static struct GNUNET_TIME_Relative delta
Definition speedup.c:36
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds and in network byte order.
Time for relative time used by GNUnet, in microseconds.
Time for timestamps used by GNUnet, in seconds and in network byte order.
Time for timestamps used by GNUnet, in microseconds rounded to seconds.
enum GNUNET_TIME_RounderInterval ri
Definition time.c:1358

◆ GNUNET_TIME_UNIT_WEEKS

#define GNUNET_TIME_UNIT_WEEKS
Value:

One week.

Definition at line 177 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MONTHS

#define GNUNET_TIME_UNIT_MONTHS
Value:

One month (30 days).

Definition at line 183 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_YEARS

#define GNUNET_TIME_UNIT_YEARS
Value:

One year (365 days).

Definition at line 189 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_FOREVER_REL

#define GNUNET_TIME_UNIT_FOREVER_REL    ((struct GNUNET_TIME_Relative){UINT64_MAX})

Constant used to specify "forever".

This constant will be treated specially in all time operations.

Definition at line 196 of file gnunet_time_lib.h.

197 {UINT64_MAX})

◆ GNUNET_TIME_UNIT_FOREVER_ABS

#define GNUNET_TIME_UNIT_FOREVER_ABS    ((struct GNUNET_TIME_Absolute){UINT64_MAX})

Constant used to specify "forever".

This constant will be treated specially in all time operations.

Definition at line 203 of file gnunet_time_lib.h.

204 {UINT64_MAX})

◆ GNUNET_TIME_UNIT_NEVER_ABS

#define GNUNET_TIME_UNIT_NEVER_ABS    ((struct GNUNET_TIME_Absolute){UINT64_MAX})

Definition at line 205 of file gnunet_time_lib.h.

206 {UINT64_MAX})

◆ GNUNET_TIME_UNIT_FOREVER_TS

#define GNUNET_TIME_UNIT_FOREVER_TS    ((struct GNUNET_TIME_Timestamp){{UINT64_MAX}})

Constant used to specify "forever".

This constant will be treated specially in all time operations.

Definition at line 212 of file gnunet_time_lib.h.

213 {{UINT64_MAX}})

◆ GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD

#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)

Threshold after which exponential backoff should not increase (15 m).

Definition at line 219 of file gnunet_time_lib.h.

◆ GNUNET_TIME_STD_BACKOFF

#define GNUNET_TIME_STD_BACKOFF (   r)
Value:

Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of 2 up unto a maximum of 15 m.

Parameters
rcurrent backoff time, initially zero

Definition at line 229 of file gnunet_time_lib.h.

◆ GNUNET_TIME_absolute_cmp

#define GNUNET_TIME_absolute_cmp (   t1,
  op,
  t2 
)     ((void) (1 op 2), (t1).abs_value_us op (t2).abs_value_us)

Compare two absolute times.

Parameters
t1first time
opcompare operator
t2second time
Returns
true if t1 op t2

Definition at line 578 of file gnunet_time_lib.h.

◆ GNUNET_TIME_timestamp_cmp

#define GNUNET_TIME_timestamp_cmp (   t1,
  op,
  t2 
)     GNUNET_TIME_absolute_cmp ((t1).abs_time,op,(t2).abs_time)

Compare two timestamps.

Parameters
t1first timestamp
opcompare operator
t2second timestamp
Returns
true if t1 op t2

Definition at line 590 of file gnunet_time_lib.h.

◆ GNUNET_TIME_relative_cmp

#define GNUNET_TIME_relative_cmp (   t1,
  op,
  t2 
)     ((void) (1 op 2), (t1).rel_value_us op (t2).rel_value_us)

Compare two relative times.

Parameters
t1first time
opcompare operator
t2second time
Returns
true if t1 op t2

Definition at line 602 of file gnunet_time_lib.h.

Enumeration Type Documentation

◆ GNUNET_TIME_RounderInterval

Quantities by which we support round up absolute time values.

Enumerator
GNUNET_TIME_RI_NONE 

No rounding up.

GNUNET_TIME_RI_SECOND 

Round up to a multiple of seconds.

GNUNET_TIME_RI_MINUTE 

Round up to the next minute.

GNUNET_TIME_RI_HOUR 

Round up to the next hour.

GNUNET_TIME_RI_DAY 

Round up to the next day.

GNUNET_TIME_RI_WEEK 

Round up to the next calendar week.

GNUNET_TIME_RI_MONTH 

Round up to the next month.

GNUNET_TIME_RI_QUARTER 

Round up to the next quarter.

GNUNET_TIME_RI_YEAR 

Round up to the next year.

Definition at line 238 of file gnunet_time_lib.h.

Function Documentation

◆ GNUNET_STRINGS_fancy_time_to_absolute()

enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute ( const char *  fancy_time,
struct GNUNET_TIME_Absolute atime 
)

Convert a given fancy human-readable time to our internal representation.

The human-readable time is expected to be in local time, whereas the returned value will be in UTC.

Parameters
fancy_timehuman readable string (e.g. Y-m-d H:M:S)
atimeset to the absolute time
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 303 of file strings.c.

305{
306 struct tm tv;
307 time_t t;
308 const char *eos;
309 unsigned long long l;
310 char dummy;
311
312 if (0 == strcasecmp ("end of time",
313 fancy_time))
314 {
316 return GNUNET_OK;
317 }
318 if ( (1 == sscanf (fancy_time,
319 "%llu%c",
320 &l,
321 &dummy)) &&
322 (l > 9999) )
323 {
324 /* Time given in seconds after epoch, and not a year */
325 *atime = GNUNET_TIME_absolute_from_s (l);
326 return GNUNET_OK;
327 }
328 eos = &fancy_time[strlen (fancy_time)];
329 memset (&tv, 0, sizeof(tv));
330 if ((eos != strptime (fancy_time, "%a %b %d %H:%M:%S %Y", &tv)) &&
331 (eos != strptime (fancy_time, "%c", &tv)) &&
332 (eos != strptime (fancy_time, "%Ec", &tv)) &&
333 (eos != strptime (fancy_time, "%Y-%m-%d %H:%M:%S", &tv)) &&
334 (eos != strptime (fancy_time, "%Y-%m-%d %H:%M", &tv)) &&
335 (eos != strptime (fancy_time, "%x", &tv)) &&
336 (eos != strptime (fancy_time, "%Ex", &tv)) &&
337 (eos != strptime (fancy_time, "%Y-%m-%d", &tv)) &&
338 (eos != strptime (fancy_time, "%Y-%m", &tv)) &&
339 (eos != strptime (fancy_time, "%Y", &tv)))
340 return GNUNET_SYSERR;
341 t = mktime (&tv);
342 if (((time_t) -1) == t)
343 {
345 "mktime");
346 return GNUNET_SYSERR;
347 }
349 return GNUNET_OK;
350}
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_ERROR

References dummy, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_strerror, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_from_s(), GNUNET_TIME_UNIT_FOREVER_ABS, and t.

Referenced by GNUNET_STRINGS_fancy_time_to_timestamp(), parse_expiration(), parse_expiration(), set_absolute_time(), set_timestamp(), and sign_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_STRINGS_fancy_time_to_timestamp()

enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_timestamp ( const char *  fancy_time,
struct GNUNET_TIME_Timestamp atime 
)

Convert a given fancy human-readable time to our internal representation.

The human-readable time is expected to be in local time, whereas the returned value will be in UTC.

Parameters
fancy_timehuman readable string (e.g. Y-m-d H:M:S)
atimeset to the absolute time
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 354 of file strings.c.

356{
358
359 if (GNUNET_OK !=
361 &atime->abs_time)))
362 {
363 return ret;
364 }
366 {
367 atime->abs_time = GNUNET_TIME_UNIT_FOREVER_TS.abs_time;
368 }
369 return GNUNET_OK;
370}
static int ret
Final status code.
Definition gnunet-arm.c:93
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition strings.c:303
struct GNUNET_TIME_Absolute abs_time
The actual value.

References GNUNET_TIME_Timestamp::abs_time, GNUNET_OK, GNUNET_STRINGS_fancy_time_to_absolute(), GNUNET_TIME_absolute_is_never(), GNUNET_TIME_UNIT_FOREVER_TS, and ret.

Here is the call graph for this function:

◆ GNUNET_STRINGS_timestamp_to_string()

const char * GNUNET_STRINGS_timestamp_to_string ( struct GNUNET_TIME_Timestamp  t)

Like asctime, except for GNUnet time.

Converts a GNUnet internal absolute time (which is in UTC) to a string in local time. Note that the returned value will be overwritten if this function is called again.

Parameters
tthe timestamp to convert
Returns
timestamp in human-readable form in local time

Definition at line 657 of file strings.c.

658{
659 struct GNUNET_TIME_Absolute av;
660
661 if (t.abs_time.abs_value_us == GNUNET_TIME_UNIT_FOREVER_TS.abs_time.
664 ;
665 av.abs_value_us = t.abs_time.abs_value_us;
667}
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:671
uint64_t abs_value_us
The actual value.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_TS, and t.

Here is the call graph for this function:

◆ GNUNET_STRINGS_absolute_time_to_string()

const char * GNUNET_STRINGS_absolute_time_to_string ( struct GNUNET_TIME_Absolute  t)

Like asctime, except for GNUnet time.

Converts a GNUnet internal absolute time (which is in UTC) to a string in local time. Note that the returned value will be overwritten if this function is called again.

Parameters
tthe absolute time to convert
Returns
timestamp in human-readable form in local time

Definition at line 671 of file strings.c.

672{
673 static GNUNET_THREAD_LOCAL char buf[255];
674 time_t tt;
675 struct tm *tp;
676
678 return "end of time";
679 tt = t.abs_value_us / 1000LL / 1000LL;
680 tp = localtime (&tt);
681 /* This is hacky, but i don't know a way to detect libc character encoding.
682 * Just expect utf8 from glibc these days.
683 * As for msvcrt, use the wide variant, which always returns utf16
684 * (otherwise we'd have to detect current codepage or use W32API character
685 * set conversion routines to convert to UTF8).
686 */
687 strftime (buf, sizeof(buf), "%a %b %d %H:%M:%S %Y", tp);
688
689 return buf;
690}
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
#define GNUNET_THREAD_LOCAL
Definition platform.h:252

References GNUNET_THREAD_LOCAL, GNUNET_TIME_absolute_is_never(), t, and tt.

Referenced by block_decrypt_ecdsa(), block_decrypt_eddsa(), dispatch_job(), display_record(), do_rekey(), do_rekey(), execute_get(), get_resp_callback(), get_transmit_delay(), GNUNET_FS_meta_data_add_publication_date(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_PEERSTORE_hello_add(), GNUNET_STRINGS_timestamp_to_string(), got_hello(), handle_dht_response(), handle_estimate(), handle_namecache_block_response(), handle_p2p_estimate(), handle_validation_response(), hello_add_iter(), hello_iter(), inject_rekey(), inject_rekey(), learn_dv_path(), monitor_cb(), namecache_sqlite_cache_block(), ns_lookup_result_cb(), parse_expiration(), parse_expiration(), printer(), printer_watch(), process_queue(), process_record(), put_callback(), select_loop(), sqlite_plugin_put(), store_pi(), timeout_cb(), transmit_item(), transmit_on_queue(), transmit_task_cb(), update_pm_next_attempt(), and warn_monitor_slow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_STRINGS_relative_time_to_string()

const char * GNUNET_STRINGS_relative_time_to_string ( struct GNUNET_TIME_Relative  delta,
int  do_round 
)

Give relative time in human-readable fancy format.

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
deltatime in milli seconds
do_roundare we allowed to round a bit?
Returns
string in human-readable form

Definition at line 610 of file strings.c.

612{
613 static GNUNET_THREAD_LOCAL char buf[128];
614 const char *unit = /* time unit */ "µs";
615 uint64_t dval = delta.rel_value_us;
616
618 return "forever";
619 if (0 == delta.rel_value_us)
620 return "0 ms";
621 if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
622 {
623 dval = dval / 1000;
624 unit = /* time unit */ "ms";
625 if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
626 {
627 dval = dval / 1000;
628 unit = /* time unit */ "s";
629 if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
630 {
631 dval = dval / 60;
632 unit = /* time unit */ "m";
633 if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
634 {
635 dval = dval / 60;
636 unit = /* time unit */ "h";
637 if (((GNUNET_YES == do_round) && (dval > 5 * 24)) ||
638 (0 == (dval % 24)))
639 {
640 dval = dval / 24;
641 if (1 == dval)
642 unit = /* time unit */ "day";
643 else
644 unit = /* time unit */ "days";
645 }
646 }
647 }
648 }
649 }
650 GNUNET_snprintf (buf, sizeof(buf), "%llu %s",
651 (unsigned long long) dval, unit);
652 return buf;
653}
@ GNUNET_YES
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
uint64_t rel_value_us
The actual value.

References delta, do_round(), GNUNET_snprintf(), GNUNET_THREAD_LOCAL, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, and GNUNET_TIME_Relative::rel_value_us.

Referenced by channel_open_sent_cb(), check_link_down(), check_peer_alive(), connect_fail_continuation(), consider_sending_fc(), core_fc_stalled(), data_sent_cb(), delay_warning(), delayed_restart_task(), disconnect_and_schedule_reconnect(), disconnect_and_schedule_reconnect(), display_record(), do_disconnect(), do_shutdown(), do_shutdown(), do_speedup(), expired_processor(), find_proof(), flush_bulk(), get_delay_randomization(), get_transmit_delay(), GNUNET_BANDWIDTH_tracker_get_delay(), GNUNET_BANDWIDTH_value_get_available_until(), GNUNET_BANDWIDTH_value_get_delay_for(), GNUNET_DATASTORE_put(), GNUNET_HOSTLIST_client_start(), GNUNET_SCHEDULER_do_work(), GNUNET_SPEEDUP_start_(), GNUNET_TESTING_interpreter_next_(), GSC_CLIENTS_solicit_request(), GSF_block_peer_migration_(), handle_announce(), handle_client_join(), handle_client_send(), handle_data(), handle_dv_learn(), handle_p2p_migration_stop(), handle_p2p_put(), handle_test(), handler_advertisement(), link_cb(), list_callback(), maint_child_death(), manage_first_hop_mq(), monitor_cb(), odc_warn_delay_task(), parse_expiration(), parse_expiration(), plan(), print_link_verbose(), process_job_queue(), process_lookup_result(), process_stat(), process_stdin(), process_stdin(), progress_cb(), progress_cb(), progress_cb(), put_migration_continuation(), queue_read(), queue_read(), queue_timeout(), quota_processor(), read_send(), RECLAIM_TICKETS_init(), reconnect(), regex_found_handler(), reschedule_connect(), run(), run(), run(), run(), run(), run(), run(), run_iteration_round(), schedule_peer_transmission(), search_timed_out(), sqlite_plugin_put(), sqlite_plugin_put(), start_dv_learn(), store_completed_cb(), task_check(), task_hostlist_saving(), test_master(), timeout_cb(), transmit_item(), transmit_on_queue(), try_reconnect(), try_transmission(), update_excess(), update_tracker(), update_velocity(), validation_start_cb(), warn_delay(), warn_delay_task(), warn_no_client_continue(), and zone_iteration_finished().

Here is the call graph for this function:

◆ GNUNET_TIME_relative_to_round_interval()

enum GNUNET_TIME_RounderInterval GNUNET_TIME_relative_to_round_interval ( struct GNUNET_TIME_Relative  rel)

Convert a relative time to the corresponding rounding interval.

Parameters
relrelative time to convert
Returns
rounding interval, GNUNET_TIME_RI_NONE if either rel is zero or if the input does not match exactly any of the supported rounding intervals

Definition at line 1312 of file time.c.

1313{
1315 ==,
1316 rel))
1317 return GNUNET_TIME_RI_YEAR;
1320 3),
1321 ==,
1322 rel))
1325 ==,
1326 rel))
1327 return GNUNET_TIME_RI_MONTH;
1329 ==,
1330 rel))
1331 return GNUNET_TIME_RI_WEEK;
1333 ==,
1334 rel))
1335 return GNUNET_TIME_RI_DAY;
1337 ==,
1338 rel))
1339 return GNUNET_TIME_RI_HOUR;
1341 ==,
1342 rel))
1343 return GNUNET_TIME_RI_MINUTE;
1345 ==,
1346 rel))
1347 return GNUNET_TIME_RI_SECOND;
1349 return GNUNET_TIME_RI_NONE;
1350}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_TIME_relative_cmp(t1, op, t2)
Compare two relative times.
#define GNUNET_TIME_UNIT_SECONDS
One second.
#define GNUNET_TIME_UNIT_MONTHS
One month (30 days).
#define GNUNET_TIME_UNIT_WEEKS
One week.
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).

References GNUNET_break, GNUNET_TIME_relative_cmp, GNUNET_TIME_relative_is_zero(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_RI_DAY, GNUNET_TIME_RI_HOUR, GNUNET_TIME_RI_MINUTE, GNUNET_TIME_RI_MONTH, GNUNET_TIME_RI_NONE, GNUNET_TIME_RI_QUARTER, GNUNET_TIME_RI_SECOND, GNUNET_TIME_RI_WEEK, GNUNET_TIME_RI_YEAR, GNUNET_TIME_UNIT_DAYS, GNUNET_TIME_UNIT_HOURS, GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MONTHS, GNUNET_TIME_UNIT_SECONDS, GNUNET_TIME_UNIT_WEEKS, and GNUNET_TIME_UNIT_YEARS.

Here is the call graph for this function:

◆ GNUNET_TIME_string_to_round_interval()

enum GNUNET_GenericReturnValue GNUNET_TIME_string_to_round_interval ( const char *  ri_str,
enum GNUNET_TIME_RounderInterval ri 
)

Convert rounding interval given as a string to the enum value.

Parameters
ri_strrounding interval as string
[out]riset to enum value
Returns
GNUNET_OK on success, GNUNET_SYSERR on failure

Definition at line 1375 of file time.c.

1378{
1379 if (NULL == ri_str)
1380 {
1381 GNUNET_break (0);
1382 return GNUNET_SYSERR;
1383 }
1384 for (unsigned int i = 0;
1385 NULL != ri_lookup_table[i].str;
1386 i++)
1387 {
1388 if (0 == strcasecmp (ri_str,
1389 ri_lookup_table[i].str))
1390 {
1391 *ri = ri_lookup_table[i].ri;
1392 return GNUNET_OK;
1393 }
1394 }
1395 return GNUNET_SYSERR;
1396}
static const struct @44 ri_lookup_table[]
Lookup table mapping rounding interval enum values to their string representations.
const char * str
Definition time.c:1359

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, ri, ri_lookup_table, and str.

Referenced by parse_tri().

Here is the caller graph for this function:

◆ GNUNET_TIME_round_interval2s()

const char * GNUNET_TIME_round_interval2s ( enum GNUNET_TIME_RounderInterval  ri)

Convert rounding interval to string.

Parameters
rithe rounding interval
Returns
NULL on failure (invalid enum value)

Definition at line 1400 of file time.c.

1401{
1402 for (unsigned int i = 0;
1403 NULL != ri_lookup_table[i].str;
1404 i++)
1405 {
1406 if (ri == ri_lookup_table[i].ri)
1407 return ri_lookup_table[i].str;
1408 }
1409 GNUNET_break (0);
1410 return NULL;
1411}

References GNUNET_break, ri, and ri_lookup_table.

Referenced by GNUNET_JSON_pack_time_rounder_interval().

Here is the caller graph for this function:

◆ GNUNET_TIME_round_up()

struct GNUNET_TIME_Absolute GNUNET_TIME_round_up ( struct GNUNET_TIME_Absolute  at,
enum GNUNET_TIME_RounderInterval  ri 
)

Round up the given at to the interval ri.

NEVER/FOREVER always remains NEVER/FOREVER.

The calendar boundaries are those of the local time zone; use GNUNET_TIME_round_up_utc() if the result must not depend on the time zone the process happens to run in.

Parameters
atsome absolute time to round
rihow much to round up
Returns
rounded up value of at

Definition at line 1272 of file time.c.

1274{
1275 return round_up (at,
1276 ri,
1277 false);
1278}
static struct GNUNET_TIME_Absolute round_up(struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri, bool utc)
Round up the given at to the interval ri.
Definition time.c:1035

References ri, and round_up().

Here is the call graph for this function:

◆ GNUNET_TIME_round_up_utc()

struct GNUNET_TIME_Absolute GNUNET_TIME_round_up_utc ( struct GNUNET_TIME_Absolute  at,
enum GNUNET_TIME_RounderInterval  ri 
)

Round up the given at to the interval ri, using UTC calendar boundaries.

NEVER/FOREVER always remains NEVER/FOREVER.

Same as GNUNET_TIME_round_up(), except that the result does not depend on the local time zone. Use this variant whenever the result is compared against, or converted back with, other UTC-based functions such as GNUNET_TIME_time_to_year().

Parameters
atsome absolute time to round
rihow much to round up
Returns
rounded up value of at

Definition at line 1282 of file time.c.

1284{
1285 return round_up (at,
1286 ri,
1287 true);
1288}

References ri, and round_up().

Here is the call graph for this function:

◆ GNUNET_TIME_round_down()

struct GNUNET_TIME_Absolute GNUNET_TIME_round_down ( struct GNUNET_TIME_Absolute  at,
enum GNUNET_TIME_RounderInterval  ri 
)

Round @at down to the start of the next interval ri.

NEVER/FOREVER always remains NEVER/FOREVER.

The calendar boundaries are those of the local time zone; use GNUNET_TIME_round_down_utc() if the result must not depend on the time zone the process happens to run in.

Parameters
atsome absolute time to round
rihow much to round down
Returns
rounded up value of at

Definition at line 1292 of file time.c.

1294{
1295 return round_down (at,
1296 ri,
1297 false);
1298}
static struct GNUNET_TIME_Absolute round_down(struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri, bool utc)
Round at down to the start of the interval ri.
Definition time.c:1185

References ri, and round_down().

Here is the call graph for this function:

◆ GNUNET_TIME_round_down_utc()

struct GNUNET_TIME_Absolute GNUNET_TIME_round_down_utc ( struct GNUNET_TIME_Absolute  at,
enum GNUNET_TIME_RounderInterval  ri 
)

Round @at down to the start of the next interval ri, using UTC calendar boundaries.

NEVER/FOREVER always remains NEVER/FOREVER.

Same as GNUNET_TIME_round_down(), except that the result does not depend on the local time zone. Use this variant whenever the result is compared against, or converted back with, other UTC-based functions such as GNUNET_TIME_time_to_year().

Parameters
atsome absolute time to round
rihow much to round down
Returns
rounded up value of at

Definition at line 1302 of file time.c.

1304{
1305 return round_down (at,
1306 ri,
1307 true);
1308}

References ri, and round_down().

Here is the call graph for this function:

◆ GNUNET_TIME_timestamp2s()

const char * GNUNET_TIME_timestamp2s ( struct GNUNET_TIME_Timestamp  ts)

Convert ts to human-readable timestamp.

Note that the returned value will be overwritten if this function is called again.

Parameters
tsthe timestamp to convert
Returns
statically allocated string, will change on the next call

Definition at line 214 of file time.c.

215{
216 static GNUNET_THREAD_LOCAL char buf[255];
217 time_t tt;
218 struct tm *tp;
219
221 return "never";
222 tt = ts.abs_time.abs_value_us / 1000LL / 1000LL;
223 tp = localtime (&tt);
224 /* This is hacky, but i don't know a way to detect libc character encoding.
225 * Just expect utf8 from glibc these days.
226 * As for msvcrt, use the wide variant, which always returns utf16
227 * (otherwise we'd have to detect current codepage or use W32API character
228 * set conversion routines to convert to UTF8).
229 */
230 strftime (buf,
231 sizeof(buf),
232 "%a %b %d %H:%M:%S %Y",
233 tp);
234 return buf;
235}

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, GNUNET_THREAD_LOCAL, GNUNET_TIME_absolute_is_never(), and tt.

Here is the call graph for this function:

◆ GNUNET_TIME_absolute2s()

const char * GNUNET_TIME_absolute2s ( struct GNUNET_TIME_Absolute  ts)

Like asctime, except for GNUnet time.

Converts a GNUnet internal absolute time (which is in UTC) to a string in local time. Note that the returned value will be overwritten if this function is called again.

Parameters
tsthe absolute time to convert
Returns
timestamp in human-readable form in local time

Definition at line 239 of file time.c.

240{
241 static GNUNET_THREAD_LOCAL char buf[255];
242 time_t tt;
243 struct tm *tp;
244
246 return "never";
247 tt = t.abs_value_us / 1000LL / 1000LL;
248 tp = localtime (&tt);
249 /* This is hacky, but i don't know a way to detect libc character encoding.
250 * Just expect utf8 from glibc these days.
251 * As for msvcrt, use the wide variant, which always returns utf16
252 * (otherwise we'd have to detect current codepage or use W32API character
253 * set conversion routines to convert to UTF8).
254 */
255 strftime (buf,
256 sizeof(buf),
257 "%a %b %d %H:%M:%S %Y",
258 tp);
259 return buf;
260}

References GNUNET_THREAD_LOCAL, GNUNET_TIME_absolute_is_never(), t, and tt.

Here is the call graph for this function:

◆ GNUNET_TIME_relative2s()

const char * GNUNET_TIME_relative2s ( struct GNUNET_TIME_Relative  delta,
bool  do_round 
)

Give relative time in human-readable fancy format.

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
deltatime in milli seconds
do_roundare we allowed to round a bit?
Returns
string in human-readable form

Definition at line 264 of file time.c.

266{
267 static GNUNET_THREAD_LOCAL char buf[128];
268 const char *unit = /* time unit */ "µs";
269 uint64_t dval = delta.rel_value_us;
270
272 return "forever";
273 if (0 == delta.rel_value_us)
274 return "0 ms";
275 if ( ((GNUNET_YES == do_round) &&
276 (dval > 5 * 1000)) ||
277 (0 == (dval % 1000)))
278 {
279 dval = dval / 1000;
280 unit = /* time unit */ "ms";
281 if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
282 {
283 dval = dval / 1000;
284 unit = /* time unit */ "s";
285 if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
286 {
287 dval = dval / 60;
288 unit = /* time unit */ "m";
289 if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
290 {
291 dval = dval / 60;
292 unit = /* time unit */ "h";
293 if (((GNUNET_YES == do_round) && (dval > 5 * 24)) ||
294 (0 == (dval % 24)))
295 {
296 dval = dval / 24;
297 if (1 == dval)
298 unit = /* time unit */ "day";
299 else
300 unit = /* time unit */ "days";
301 }
302 }
303 }
304 }
305 }
306 GNUNET_snprintf (buf,
307 sizeof(buf),
308 "%llu %s",
309 (unsigned long long) dval,
310 unit);
311 return buf;
312}

References delta, do_round(), GNUNET_snprintf(), GNUNET_THREAD_LOCAL, GNUNET_TIME_relative_is_forever(), GNUNET_YES, and GNUNET_TIME_Relative::rel_value_us.

Referenced by free_timedout_queue_entry(), GNUNET_CURL_perform2(), and GNUNET_get_udp_socket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_randomized_backoff()

struct GNUNET_TIME_Relative GNUNET_TIME_randomized_backoff ( struct GNUNET_TIME_Relative  rt,
struct GNUNET_TIME_Relative  threshold 
)

Randomized exponential back-off, starting at 1 ms and going up by a factor of 2+r, where 0 <= r <= 0.5, up to a maximum of the given threshold.

Parameters
rtcurrent backoff time, initially zero
thresholdmaximum value for backoff
Returns
the next backoff time

Definition at line 830 of file time.c.

832{
833 double r = (rand () % 500) / 1000.0;
834 struct GNUNET_TIME_Relative t;
835
838 2 + r);
839 return GNUNET_TIME_relative_min (threshold, t);
840}

References GNUNET_TIME_relative_max(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_multiply_double(), GNUNET_TIME_UNIT_MILLISECONDS, and t.

Referenced by error_handler(), error_handler(), error_handler(), error_handler(), and validation_start_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_randomize()

struct GNUNET_TIME_Relative GNUNET_TIME_randomize ( struct GNUNET_TIME_Relative  r)

Return a random time value between 0.5*r and 1.5*r.

Parameters
rinput time for scaling
Returns
randomized time

Definition at line 851 of file time.c.

852{
853 double d = ((rand () % 1001) + 500) / 1000.0;
854
856}
static mp_limb_t d[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]

References d, and GNUNET_TIME_relative_multiply_double().

Referenced by transmit_dv_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_zero_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_ ( void  )

Return relative time of 0ms.

Definition at line 133 of file time.c.

134{
135 static struct GNUNET_TIME_Relative zero;
136
137 return zero;
138}
static const struct GNUNET_CRYPTO_BlindablePrivateKey zero
Public key of all zeros.

References zero.

Referenced by create_handle(), delayed_disconnect_channel(), get_epoch_private_key_timeout(), get_message_timeout(), handle_appeal_message(), handle_epoch_announcement(), handle_epoch_group_announcement(), handle_message(), solve_srv_room_member_collisions(), update_epoch_group(), and verify_tunnel_message().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_zero_()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_ ( void  )

Return absolute time of 0ms.

Definition at line 142 of file time.c.

143{
144 static struct GNUNET_TIME_Absolute zero;
145
146 return zero;
147}

References zero.

Referenced by create_epoch(), create_epoch_announcement(), create_epoch_group(), create_operation(), GNUNET_GNSRECORD_block_get_expiration(), send_message_to_room(), sign_srv_room_message(), and stop_operation().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_unit_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit_ ( void  )

Return relative time of 1 microsecond.

Definition at line 151 of file time.c.

152{
153 static struct GNUNET_TIME_Relative one = { 1 };
154
155 return one;
156}

◆ GNUNET_TIME_relative_get_millisecond_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_millisecond_ ( void  )

Return relative time of 1ms.

Definition at line 160 of file time.c.

161{
162 static struct GNUNET_TIME_Relative one = { 1000 };
163
164 return one;
165}

Referenced by handle_room_request_task().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_second_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_second_ ( void  )

Return relative time of 1s.

Definition at line 169 of file time.c.

170{
171 static struct GNUNET_TIME_Relative one = { 1000 * 1000LL };
172
173 return one;
174}

Referenced by login_cont(), and on_message().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_minute_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_minute_ ( void  )

Return relative time of 1 minute.

Definition at line 178 of file time.c.

179{
180 static struct GNUNET_TIME_Relative one = { 60 * 1000 * 1000LL };
181
182 return one;
183}

Referenced by get_message_timeout(), and register_receiver().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_hour_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_hour_ ( void  )

Return relative time of 1 hour.

Definition at line 187 of file time.c.

188{
189 static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 * 1000LL };
190
191 return one;
192}

Referenced by handle_epoch_announcement_access(), handle_epoch_announcement_delay(), handle_epoch_group_access(), handle_epoch_group_announcement_delay(), send_epoch_announcement(), send_epoch_announcement_appeal(), and send_epoch_group_announcement().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_forever_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_ ( void  )

Return "forever".

Definition at line 196 of file time.c.

197{
198 static struct GNUNET_TIME_Relative forever = { UINT64_MAX };
199
200 return forever;
201}

Referenced by delete_srv_room_message().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_forever_()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_ ( void  )

Return "forever".

Definition at line 205 of file time.c.

206{
207 static struct GNUNET_TIME_Absolute forever = { UINT64_MAX };
208
209 return forever;
210}

Referenced by cleanup_srv_room_discourse_messages(), store_handle_encryption_key(), and store_handle_epoch_key().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get ( void  )

Get the current time.

Returns
the current time

Definition at line 111 of file time.c.

112{
114 struct timeval tv;
115
116 gettimeofday (&tv, NULL);
117 ret.abs_value_us = (uint64_t) (((uint64_t) tv.tv_sec * 1000LL * 1000LL)
118 + ((uint64_t) tv.tv_usec))
120 return ret;
121}
static long long timestamp_offset
Variable used to simulate clock skew.
Definition time.c:46

References ret, and timestamp_offset.

Referenced by add_without_sets(), announce_id(), block_decrypt_ecdsa(), block_decrypt_eddsa(), cache_nick(), check_vl_transmission(), cleanup_expired_records(), code_redirect(), consider_for_advertising(), consider_path_cb(), continue_store_activity(), cookie_identity_interpretation(), create_download_context(), create_member_session(), create_receiver(), cummulative_ack(), data_sent_cb(), dht_connect_cb(), expire_blocks(), expired_processor(), find_proof(), flush_bulk(), free_timedout_queue_entry(), GCC_handle_connection_create_ack(), GCC_handle_encrypted(), GCC_transmit(), GCP_set_hello(), GCT_add_inbound_connection(), GDS_ROUTING_add(), generate_id_token_body(), get_age(), get_any(), get_epoch_private_key(), get_nick_record(), get_redirect_state(), get_timeout(), get_typed(), GNUNET_BANDWIDTH_tracker_init2(), GNUNET_CRYPTO_random_timeflake(), GNUNET_FS_meta_data_add_publication_date(), GNUNET_FS_publish_main_(), GNUNET_FS_queue_(), GNUNET_FS_search_probe_progress_(), GNUNET_FS_unindex_start(), GNUNET_GNSRECORD_normalize_record_set(), GNUNET_GNSRECORD_record_data_to_rdata(), GNUNET_LOAD_update(), GNUNET_LOAD_value_init(), GNUNET_PEERSTORE_hello_add(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_run(), GNUNET_TESTING_cmd_batch_next_(), GNUNET_TESTING_interpreter_current_cmd_touch(), GNUNET_TESTING_interpreter_next_(), GNUNET_TESTING_interpreter_run_cmd_(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_is_future(), GNUNET_TIME_absolute_is_past(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_timestamp_get(), GNUNET_TIME_year_to_time(), GSF_peer_transmit_(), GSF_pending_request_create_(), GSF_pending_request_get_message_(), handle_ack(), handle_add_queue_message(), handle_client_send_request(), handle_connection_create(), handle_dht_local_get(), handle_dht_p2p_put(), handle_dht_reply(), handle_dv_learn(), handle_fragment_box(), handle_icmp_back(), handle_incoming_msg(), handle_monitor_next(), handle_p2p_estimate(), handle_p2p_put(), handle_stop(), handle_tcp_back(), handle_test(), handle_udp_back(), handler_advertisement(), insert_sorted(), iterate_zones(), lookup_authz_cb(), manage_first_hop_mq(), merge_with_nick_records(), monitor_cb(), monitor_unblock(), mylog(), namecache_postgres_expire_blocks(), namecache_sqlite_cache_block(), namecache_sqlite_expire_blocks(), parse(), peer_transmit(), pils_id_change_cb(), postgres_plugin_del(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), prepare_pending_acknowledgement(), printer(), printer_watch(), process_local_reply(), process_queue(), process_queue(), process_queue(), process_result(), process_stdin(), process_stdin(), progress_cb(), queue_send_msg(), read_start_time(), read_stdio(), RECLAIM_TICKETS_consume(), reconnect(), remove_expired(), revalidation_start_cb(), route_message(), route_packet(), route_via_neighbour(), RPS_sampler_elem_reinit(), run(), run(), run(), run(), run_iteration_round(), run_zone_iteration_round(), sampler_mod_get_rand_peer(), scan(), schedule_peer_transmission(), schedule_transmit_on_queue(), search_start(), select_best_pending_from_link(), send_epoch_announcement(), send_epoch_group_announcement(), send_kx(), send_kx_auth(), send_message_to_room(), send_simple_single(), service_client_mst_cb(), set_epoch_announcement_appeal(), set_epoch_proposing(), setup_estimate_message(), setup_job(), setup_state_record(), shutdown_task(), sign_pow_identity(), sign_srv_room_message(), sqlite_plugin_del(), sqlite_plugin_get_closest(), sqlite_plugin_get_expiration(), start_dht_request(), start_download(), start_job(), start_local_query(), start_operation(), start_process(), start_publish(), store_completed_cb(), store_skipped_key(), switch_member_session(), t_ax_encrypt(), test_exist_cb(), transmit_dv_init(), try_transmission(), update_ax_by_kx(), update_excess(), update_hostlist(), update_subscription_timing(), update_tracker(), and update_velocity().

◆ GNUNET_TIME_relative_to_absolute()

struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute ( struct GNUNET_TIME_Relative  rel)

Convert relative time to an absolute time in the future.

Parameters
relrelative time to convert
Returns
timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow)

Definition at line 316 of file time.c.

317{
319 struct GNUNET_TIME_Absolute now;
320
324
325 if (rel.rel_value_us + now.abs_value_us < rel.rel_value_us)
326 {
327 GNUNET_break (0); /* overflow... */
329 }
330 ret.abs_value_us = rel.rel_value_us + now.abs_value_us;
331 return ret;
332}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_break, GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_is_forever(), GNUNET_TIME_UNIT_FOREVER_ABS, and ret.

Referenced by add_setter_action(), add_without_sets(), boot_queue(), boot_queue(), cadet_reply_proc(), check_for_glue(), check_if_ack_or_heartbeat(), check_rekey(), cont_send_create(), core_read_finished_cb(), core_read_finished_cb(), create_proto_queue(), create_proto_queue(), create_receiver(), data_sent_cb(), decaps_dv_box_cont(), do_dht_put(), do_generate_pid(), download_hostlist(), forward_dv_box(), GNUNET_DNSPARSER_parse_record(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_HELLO_builder_to_block(), GNUNET_HELLO_builder_to_url(), GNUNET_OS_command_run(), GNUNET_PILS_feed_addresses(), GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_add_select(), GNUNET_TIME_relative_to_timestamp(), GSC_SESSIONS_transmit(), GSF_pending_request_create_(), handle_client_call_message(), handle_dht_p2p_put(), handle_dht_reply(), handle_dv_learn(), handle_find_my_hello(), handle_fragment_box(), handle_heartbeat(), handle_initiator_done(), handle_p2p_migration_stop(), handle_p2p_put(), handle_reliability_box(), handle_responder_hello_cont(), handle_validation_response(), learn_dv_path(), login_cont(), maint_child_death(), make_file(), modify_address(), mq_init(), mq_init(), ns_lookup_result_cb(), peerstore_store_own_cb(), plan(), print_record(), process_record(), process_result(), put_migration_continuation(), queue_read(), queue_read(), queue_read_kx(), queue_read_kx(), queue_write(), queue_write(), regex_iterator(), reschedule_peer_timeout(), reschedule_peer_timeout(), reschedule_queue_timeout(), reschedule_receiver_timeout(), reschedule_sender_timeout(), result_processor(), revalidate_now_cb(), run(), run(), run(), schedule_next_hello(), send_create_ack(), send_kx(), send_kx_auth(), setup_filter(), setup_out_cipher(), setup_out_cipher(), setup_queue(), setup_sender(), sign_accept_block(), start_address_validation(), store_signed_address(), transmit_on_queue(), transmit_request(), update_pm_next_attempt(), update_timeout(), validation_start_cb(), and vpn_allocation_cb().

Here is the call graph for this function:

◆ GNUNET_TIME_relative_to_timestamp()

struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp ( struct GNUNET_TIME_Relative  rel)

Convert relative time to a timestamp in the future.

Parameters
relrelative time to convert
Returns
timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow)

Definition at line 336 of file time.c.

References GNUNET_TIME_absolute_to_timestamp(), and GNUNET_TIME_relative_to_absolute().

Here is the call graph for this function:

◆ GNUNET_TIME_absolute_to_timestamp()

struct GNUNET_TIME_Timestamp GNUNET_TIME_absolute_to_timestamp ( struct GNUNET_TIME_Absolute  at)

Round an absolute time to a timestamp.

Parameters
attime to round
Returns
the result

Definition at line 79 of file time.c.

80{
81 struct GNUNET_TIME_Timestamp ts;
82
85 ts.abs_time.abs_value_us = at.abs_value_us - at.abs_value_us % 1000000;
86 return ts;
87}

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_absolute_is_never(), and GNUNET_TIME_UNIT_FOREVER_TS.

Referenced by GNUNET_TIME_relative_to_timestamp(), and GNUNET_TIME_timestamp_get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_timestamp_get()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_get ( void  )

Get timestamp representing the current time.

Returns
current time, rounded down to seconds

Definition at line 125 of file time.c.

References GNUNET_TIME_absolute_get(), and GNUNET_TIME_absolute_to_timestamp().

Here is the call graph for this function:

◆ GNUNET_TIME_relative_min()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_min ( struct GNUNET_TIME_Relative  t1,
struct GNUNET_TIME_Relative  t2 
)

Return the minimum of two relative time values.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 344 of file time.c.

346{
347 return (t1.rel_value_us < t2.rel_value_us) ? t1 : t2;
348}

Referenced by announce_id(), calculate_put_interval(), check_timeouts(), check_zone_namestore_next(), delayed_restart_task(), download_prepare(), encapsulate_for_dv(), find_advertisable_hello(), get_message_timeout(), GNUNET_TIME_absolute_approx_eq(), GNUNET_TIME_randomized_backoff(), handle_validation_response(), process_job_queue(), put_migration_continuation(), reconnect(), revalidate_now_cb(), route_control_message_without_fc(), route_via_neighbour(), schedule_next_put(), schedule_next_task(), schedule_resend(), and start_address_validation().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_max()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_max ( struct GNUNET_TIME_Relative  t1,
struct GNUNET_TIME_Relative  t2 
)

Return the maximum of two relative time values.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is larger

Definition at line 352 of file time.c.

354{
355 return (t1.rel_value_us > t2.rel_value_us) ? t1 : t2;
356}

Referenced by announce_id(), consider_gathering(), consider_sending_fc(), data_sent_cb(), do_scheduler_notify(), GNUNET_TIME_randomized_backoff(), put_migration_continuation(), reconnect(), schedule_next_task(), and send_heartbeat().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_min()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min ( struct GNUNET_TIME_Absolute  t1,
struct GNUNET_TIME_Absolute  t2 
)

Return the minimum of two absolute time values.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 360 of file time.c.

362{
363 return (t1.abs_value_us < t2.abs_value_us) ? t1 : t2;
364}

Referenced by cadet_reply_proc(), cummulative_ack(), GNUNET_GNSRECORD_record_get_expiration_time(), handle_dht_reply(), handle_p2p_put(), handle_validation_response(), ns_lookup_result_cb(), process_result(), and try_transmission().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_max()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max ( struct GNUNET_TIME_Absolute  t1,
struct GNUNET_TIME_Absolute  t2 
)

Return the maximum of two absolute time values.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 368 of file time.c.

370{
371 return (t1.abs_value_us > t2.abs_value_us) ? t1 : t2;
372}

Referenced by check_link_down(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_TIME_absolute_get_monotonic(), handle_add_queue_message(), handle_dht_result(), handle_flow_control(), learn_dv_path(), neighbour_dv_monotime_cb(), put_cb(), and update_iterator().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_round_down()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_round_down ( struct GNUNET_TIME_Absolute  at,
struct GNUNET_TIME_Relative  rt 
)

Round down absolute time at to multiple of rt.

Parameters
atabsolute time to round
rtmultiple to round to (non-zero)
Returns
rounded time

Definition at line 392 of file time.c.

394{
396
398 ret.abs_value_us
399 = at.abs_value_us
400 - at.abs_value_us % rt.rel_value_us;
401 return ret;
402}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

References GNUNET_assert, GNUNET_TIME_relative_is_zero(), and ret.

Here is the call graph for this function:

◆ GNUNET_TIME_timestamp_max()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_max ( struct GNUNET_TIME_Timestamp  t1,
struct GNUNET_TIME_Timestamp  t2 
)

Return the maximum of two timestamps.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 376 of file time.c.

378{
379 return (t1.abs_time.abs_value_us > t2.abs_time.abs_value_us) ? t1 : t2;
380}

◆ GNUNET_TIME_timestamp_min()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_min ( struct GNUNET_TIME_Timestamp  t1,
struct GNUNET_TIME_Timestamp  t2 
)

Return the minimum of two timestamps.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 384 of file time.c.

386{
387 return (t1.abs_time.abs_value_us < t2.abs_time.abs_value_us) ? t1 : t2;
388}

◆ GNUNET_TIME_absolute_get_remaining()

struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining ( struct GNUNET_TIME_Absolute  future)

Given a timestamp in the future, how much time remains until then?

Parameters
futuresome absolute time, typically in the future
Returns
future - now, or 0 if now >= future, or FOREVER if future==FOREVER.

Definition at line 406 of file time.c.

407{
409 struct GNUNET_TIME_Absolute now;
410
414
415 if (now.abs_value_us > future.abs_value_us)
417 ret.rel_value_us = future.abs_value_us - now.abs_value_us;
418 return ret;
419}
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_is_never(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, and ret.

Referenced by add_record(), announce_id(), backtalker_timeout_cb(), check_for_glue(), check_link_down(), check_timeouts(), cmd_read(), connection_ready_cb(), consider_peer_destroy(), core_read_finished_cb(), core_read_finished_cb(), data_sent_cb(), delayed_restart_task(), display_record(), do_dht_put(), download_prepare(), encapsulate_for_dv(), find_advertisable_hello(), get_epoch_private_key_timeout(), get_message_timeout(), get_transmit_delay(), GNUNET_DATASTORE_put(), GNUNET_GNSRECORD_check_pow(), GNUNET_GNSRECORD_is_expired(), GNUNET_SCHEDULER_add_at_with_priority(), GSF_block_peer_migration_(), handle_add_queue_message(), handle_cadet_ring_message(), handle_dht_response(), handle_flow_control(), handle_namecache_block_response(), is_epoch_announcement_appealed(), is_epoch_proposing(), learn_dv_path(), list_callback(), load_operation(), monitor_cb(), path_cleanup_cb(), pick_random_dv_hops(), plan(), process_job_queue(), process_lookup_result(), process_migration_content(), process_queue(), process_queue(), process_record(), proto_read_kx(), proto_read_kx(), put_migration_continuation(), queue_read(), queue_read(), queue_read_kx(), queue_read_kx(), queue_timeout(), queue_write(), queue_write(), quota_processor(), reassembly_cleanup_task(), revive_migration(), schedule_next_hello(), schedule_peer_transmission(), select_best_pending_from_link(), select_loop(), send_epoch_announcement(), send_epoch_group_announcement(), send_heartbeat(), sqlite_plugin_put(), sqlite_plugin_put(), t_ax_encrypt(), task_download(), timeout_cb(), transmit_item(), try_transmission(), update_flood_message(), update_pm_next_attempt(), and validation_start_cb().

Here is the call graph for this function:

◆ GNUNET_TIME_absolute_approx_eq()

bool GNUNET_TIME_absolute_approx_eq ( struct GNUNET_TIME_Absolute  a1,
struct GNUNET_TIME_Absolute  a2,
struct GNUNET_TIME_Relative  t 
)

Test if a1 and a2 are equal within a margin of error of t.

Parameters
a1time to compare
a2time to compare
ttolerance to apply
Returns
true if "|a1-a2|<=t" holds.

Definition at line 63 of file time.c.

References delta, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_relative_cmp, GNUNET_TIME_relative_min(), and t.

Here is the call graph for this function:

◆ GNUNET_TIME_calculate_eta()

struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta ( struct GNUNET_TIME_Absolute  start,
uint64_t  finished,
uint64_t  total 
)

Calculate the estimate time of arrival/completion for an operation.

Parameters
startwhen did the operation start?
finishedhow much has been done?
totalhow much must be done overall (same unit as for "finished")
Returns
remaining duration for the operation, assuming it continues at the same speed

Definition at line 562 of file time.c.

565{
566 struct GNUNET_TIME_Relative due;
567 double exp;
569
570 GNUNET_break (finished <= total);
571 if (finished >= total)
573 if (0 == finished)
576 exp = ((double) due.rel_value_us) * ((double) total) / ((double) finished);
577 ret.rel_value_us = ((uint64_t) exp) - due.rel_value_us;
578 return ret;
579}

References finished, GNUNET_break, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_Relative::rel_value_us, ret, and start.

Referenced by GNUNET_FS_download_make_status_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_unindex_make_status_(), and progress_proc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_difference()

struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference ( struct GNUNET_TIME_Absolute  start,
struct GNUNET_TIME_Absolute  end 
)

Compute the time difference between the given start and end times.

Use this function instead of actual subtraction to ensure that "FOREVER" and overflows are handled correctly.

Parameters
startsome absolute time
endsome absolute time (typically larger or equal to start)
Returns
0 if start >= end; FOREVER if end==FOREVER; otherwise end - start

Definition at line 423 of file time.c.

425{
427
430 if (end.abs_value_us < start.abs_value_us)
432 ret.rel_value_us = end.abs_value_us - start.abs_value_us;
433 return ret;
434}

References end, GNUNET_TIME_absolute_is_never(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_Relative::rel_value_us, ret, and start.

Referenced by expire_blocks(), expired_processor(), free_timedout_queue_entry(), GNUNET_TIME_absolute_approx_eq(), handle_client_join(), handle_test(), sampler_mod_get_rand_peer(), solve_srv_room_member_collisions(), stat_cmd(), update_subscription_timing(), update_timeout(), validation_start_cb(), and verify_tunnel_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_duration()

struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration ( struct GNUNET_TIME_Absolute  whence)

Get the duration of an operation as the difference of the current time and the given start time "hence".

Parameters
whencesome absolute time, typically in the past
Returns
0 if hence > now, otherwise now-hence.

Definition at line 438 of file time.c.

439{
440 struct GNUNET_TIME_Absolute now;
442
444 if (whence.abs_value_us > now.abs_value_us)
446 ret.rel_value_us = now.abs_value_us - whence.abs_value_us;
447 return ret;
448}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_ZERO, and ret.

Referenced by check_peer_alive(), consider_sending_fc(), disconnect_and_schedule_reconnect(), do_shutdown(), evaluate_connection(), find_proof(), flush_bulk(), forward_dv_learn(), get_network_latency(), GNUNET_BANDWIDTH_tracker_get_available(), GNUNET_CURL_perform2(), GNUNET_FS_download_make_status_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_probe_progress_(), GNUNET_FS_unindex_make_status_(), GNUNET_SCHEDULER_do_work(), GNUNET_TESTING_interpreter_next_(), GNUNET_TIME_calculate_eta(), GSC_CLIENTS_solicit_request(), GSF_peer_update_performance_(), GSF_update_datastore_delay_(), handle_acknowledged(), handle_client_send(), handle_data(), handle_dht_p2p_put(), handle_fragment_box(), handle_matching_ack(), handle_result(), handle_validation_response(), internal_update(), lookup_authz_cb(), maint_child_death(), mylog(), namecache_sqlite_cache_block(), notify_client_chk_update(), odc_warn_delay_task(), peer_transmit(), print_link_verbose(), process_parallel_lookup_result(), process_queue(), process_queue(), process_reply(), process_result(), process_result(), process_result_with_request(), process_stdin(), process_stdin(), progress_cb(), put_migration_continuation(), regex_found_handler(), run(), run(), run_iteration_round(), run_zone_iteration_round(), schedule_next_task(), signal_probe_result(), stop_job(), store_completed_cb(), test_master(), transmit_cummulative_ack_cb(), update_velocity(), warn_delay_task(), warn_no_client_continue(), and write_start_time().

Here is the call graph for this function:

◆ GNUNET_TIME_absolute_add()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add ( struct GNUNET_TIME_Absolute  start,
struct GNUNET_TIME_Relative  duration 
)

Add a given relative duration to the given start time.

Parameters
startsome absolute time
durationsome relative time to add
Returns
FOREVER if either argument is FOREVER or on overflow; start+duration otherwise

Definition at line 452 of file time.c.

454{
456
460 if (start.abs_value_us + duration.rel_value_us < start.abs_value_us)
461 {
462 GNUNET_break (0);
464 }
465 ret.abs_value_us = start.abs_value_us + duration.rel_value_us;
466 return ret;
467}

References duration, GNUNET_break, GNUNET_TIME_absolute_is_never(), GNUNET_TIME_relative_is_forever(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_Relative::rel_value_us, ret, and start.

Referenced by announce_id(), check_link_down(), create_subscription(), generate_id_token_body(), get_epoch_private_key(), get_message_timeout(), get_transmit_delay(), GNUNET_GNSRECORD_check_pow(), GNUNET_GNSRECORD_record_data_to_rdata(), pils_id_change_cb(), process_job_queue(), process_queue(), send_epoch_announcement(), send_epoch_group_announcement(), set_epoch_announcement_appeal(), set_epoch_proposing(), sign_ephemeral(), start_operation(), t_ax_encrypt(), timeout_cb(), update_ax_by_kx(), update_flood_message(), update_next_challenge_time(), and update_subscription().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_subtract()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract ( struct GNUNET_TIME_Absolute  start,
struct GNUNET_TIME_Relative  duration 
)

Subtract a given relative duration from the given start time.

Parameters
startsome absolute time
durationsome relative time to subtract
Returns
ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise

Definition at line 471 of file time.c.

473{
475
476 if (start.abs_value_us <= duration.rel_value_us)
480 ret.abs_value_us = start.abs_value_us - duration.rel_value_us;
481 return ret;
482}
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.

References GNUNET_TIME_Absolute::abs_value_us, duration, GNUNET_TIME_absolute_is_never(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_Relative::rel_value_us, ret, and start.

Referenced by GSF_pending_request_create_(), handle_validation_response(), read_start_time(), and sign_pow_identity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_relative_multiply_double()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply_double ( struct GNUNET_TIME_Relative  rel,
double  factor 
)

Multiply relative time by a given factor.

Parameters
relsome duration
factordouble to multiply with
Returns
FOREVER if rel=FOREVER or on overflow; otherwise rel*factor

Definition at line 506 of file time.c.

508{
509 struct GNUNET_TIME_Relative out;
510 double m;
511
512 GNUNET_assert (0.0 <= factor);
513 if (0.0 >= factor)
517 m = ((double) rel.rel_value_us) * factor;
519 {
520 GNUNET_break (0);
522 }
523 out.rel_value_us = (uint64_t) m;
524 return out;
525}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition gnunet-arm.c:103

References GNUNET_assert, GNUNET_break, GNUNET_TIME_relative_is_forever(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, m, and GNUNET_TIME_Relative::rel_value_us.

Referenced by GNUNET_TIME_randomize(), GNUNET_TIME_randomized_backoff(), handle_appeal_message(), handle_discourse_subscription(), handle_epoch_announcement(), and update_pm_next_attempt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_relative_multiply()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply ( struct GNUNET_TIME_Relative  rel,
unsigned long long  factor 
)

Multiply relative time by a given factor.

Parameters
relsome duration
factorinteger to multiply with
Returns
FOREVER if rel=FOREVER or on overflow; otherwise rel*factor

Definition at line 486 of file time.c.

488{
490
491 if (0 == factor)
495 ret.rel_value_us = rel.rel_value_us * factor;
496 if (ret.rel_value_us / factor != rel.rel_value_us)
497 {
498 GNUNET_break (0);
500 }
501 return ret;
502}

References GNUNET_break, GNUNET_TIME_relative_is_forever(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_Relative::rel_value_us, and ret.

Referenced by announce_next_regex(), calculate_rtt(), check_zone_namestore_next(), cleanup_expired_records(), connection_create(), connection_update_timer(), consider_gathering(), context_task(), curl_download_prepare(), do_discover_peers(), do_open_listening_socket(), download_prepare(), expire_records_continuation(), get_randomized_delay(), GNUNET_DNSPARSER_parse_record(), GNUNET_GNSRECORD_check_pow(), GNUNET_GNSRECORD_pow_start(), GNUNET_RPS_sub_start(), GNUNET_STATISTICS_destroy(), GNUNET_TIME_relative_to_round_interval(), GSF_pending_request_create_(), handle_connection_create(), handle_dht_p2p_put(), handle_dv_learn(), handle_fragment_box(), handle_msg_test(), handle_p2p_put(), handle_room_request_task(), handle_test(), handle_validation_response(), helper_read(), helper_write(), iter_finished(), login_cont(), lookup_authz_cb(), main(), plan(), process_job_queue(), read_send(), reannounce_regex(), reconnect(), register_sender(), REST_gns_process_request(), run(), run(), run_httpd(), run_with_key(), schedule_next_put(), schedule_resend(), send_epoch_announcement(), send_epoch_group_announcement(), send_find_peer_message(), start_burst(), start_closing_period(), start_draining_period(), start_dv_learn(), start_helper(), store_completed_cb(), stream_start_response(), task_check(), test_master(), timeout_cb(), and transmit_on_queue().

Here is the call graph for this function:

◆ GNUNET_TIME_relative_saturating_multiply()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply ( struct GNUNET_TIME_Relative  rel,
unsigned long long  factor 
)

Saturating multiply relative time by a given factor.

Parameters
relsome duration
factorinteger to multiply with
Returns
FOREVER if rel=FOREVER or on overflow; otherwise rel*factor

Definition at line 529 of file time.c.

531{
533
534 if (0 == factor)
538 ret.rel_value_us = rel.rel_value_us * factor;
539 if (ret.rel_value_us / factor != rel.rel_value_us)
540 {
542 }
543 return ret;
544}

References GNUNET_TIME_relative_is_forever(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_Relative::rel_value_us, and ret.

Referenced by compute_rand_delay(), daemon_started(), GNUNET_FS_search_start_probe_(), GNUNET_is_burst_ready(), process_job_queue(), put_migration_continuation(), reconnect(), schedule_next_task(), and update_excess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_relative_divide()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide ( struct GNUNET_TIME_Relative  rel,
unsigned long long  factor 
)

Divide relative time by a given factor.

Parameters
relsome duration
factorinteger to divide by
Returns
FOREVER if rel=FOREVER or factor==0; otherwise rel/factor

Definition at line 548 of file time.c.

550{
552
553 if ((0 == factor) ||
556 ret.rel_value_us = rel.rel_value_us / factor;
557 return ret;
558}

References GNUNET_TIME_relative_is_forever(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_Relative::rel_value_us, and ret.

Referenced by calculate_put_interval(), compute_rand_delay(), consider_gathering(), do_shutdown(), find_proof(), get_network_latency(), GNUNET_GNSRECORD_check_pow(), handle_dht_p2p_put(), handle_reliability_box(), handle_test(), peerstore_store_own_cb(), revalidate_now_cb(), run_zone_iteration_round(), schedule_next_put(), send_heartbeat(), start_address_validation(), store_completed_cb(), update_pm_next_attempt(), and update_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_relative_add()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_add ( struct GNUNET_TIME_Relative  a1,
struct GNUNET_TIME_Relative  a2 
)

Add relative times together.

Parameters
a1some relative time
a2some other relative time
Returns
FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise

Definition at line 583 of file time.c.

585{
587
588 if ((a1.rel_value_us == UINT64_MAX) || (a2.rel_value_us == UINT64_MAX))
590 if (a1.rel_value_us + a2.rel_value_us < a1.rel_value_us)
591 {
592 GNUNET_break (0);
594 }
595 ret.rel_value_us = a1.rel_value_us + a2.rel_value_us;
596 return ret;
597}

References GNUNET_break, GNUNET_TIME_UNIT_FOREVER_REL, and ret.

Referenced by calculate_rtt(), compute_rand_delay(), forward_dv_learn(), handle_dht_p2p_put(), handle_test(), process_queue(), process_result(), process_result(), run(), stat_cmd(), stop_job(), store_completed_cb(), update_pm_next_attempt(), and update_velocity().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_subtract()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract ( struct GNUNET_TIME_Relative  a1,
struct GNUNET_TIME_Relative  a2 
)

Subtract relative timestamp from the other.

Parameters
a1first timestamp
a2second timestamp
Returns
ZERO if a2>=a1 (including both FOREVER), FOREVER if a1 is FOREVER, a1-a2 otherwise

Definition at line 601 of file time.c.

603{
605
606 if (a2.rel_value_us >= a1.rel_value_us)
608 if (a1.rel_value_us == UINT64_MAX)
611 return ret;
612}

References GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_Relative::rel_value_us, and ret.

Referenced by check_zone_namestore_next(), get_network_latency(), GNUNET_FS_search_probe_progress_(), GNUNET_is_burst_ready(), handle_acknowledged(), learn_dv_path(), store_completed_cb(), and update_velocity().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_hton()

struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton ( struct GNUNET_TIME_Relative  a)

Convert relative time to network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 616 of file time.c.

617{
619
621 return ret;
622}
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
uint64_t rel_value_us__
The actual value (in network byte order).

References GNUNET_htonll(), GNUNET_TIME_RelativeNBO::rel_value_us__, and ret.

Referenced by announce_reconnect(), consider_sending_fc(), create_message_announcement(), create_message_appeal(), create_message_deletion(), create_message_group(), create_message_subscription(), forward_dv_learn(), GNUNET_get_burst_sync_msg(), GNUNET_GNSRECORD_pow_start(), GNUNET_RPS_sub_start(), GNUNET_TRANSPORT_communicator_receive(), GSF_block_peer_migration_(), notify_monitor(), on_message(), report_link(), send_add_address(), start_burst(), start_dv_learn(), and transmit_cummulative_ack_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_relative_ntoh()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh ( struct GNUNET_TIME_RelativeNBO  a)

Convert relative time from network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 626 of file time.c.

627{
629
631 return ret;
632}
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.

References GNUNET_ntohll(), GNUNET_TIME_Relative::rel_value_us, and ret.

Referenced by forward_dv_learn(), get_message_timeout(), get_network_latency(), GNUNET_is_burst_ready(), GNUNET_JSON_pack_time_rel_nbo(), handle_add_address(), handle_add_address(), handle_announce(), handle_client_start_sub(), handle_discourse_subscription(), handle_flow_control(), handle_link_list_response(), handle_message_subscribe(), handle_monitor_data(), handle_p2p_migration_stop(), handle_reliability_ack(), handle_start_burst(), and handle_validation_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_hton()

struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton ( struct GNUNET_TIME_Absolute  a)

Convert absolute time to network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 636 of file time.c.

637{
639
641 return ret;
642}
uint64_t abs_value_us__
The actual value (in network byte order).

References GNUNET_TIME_AbsoluteNBO::abs_value_us__, GNUNET_htonll(), and ret.

Referenced by block_create_ecdsa(), block_create_eddsa(), client_response_handler(), consider_sending_fc(), cont_send_create(), create_loc_uri(), do_dht_put(), do_generate_pid(), encapsulate_for_dv(), extract_abs_time_nbo(), forward_reply(), GDS_helper_make_put_message(), GDS_helper_sign_path(), GDS_NEIGHBOURS_handle_reply(), get_cb(), GNUNET_CONSENSUS_create(), GNUNET_DATASTORE_put(), GNUNET_DHT_put(), GNUNET_DHT_verify_path(), GNUNET_FS_uri_loc_create(), GNUNET_HELLO_builder_to_block(), GNUNET_HELLO_parser_to_block(), GNUNET_PILS_sign_hello(), GNUNET_SECRETSHARING_create_session(), GNUNET_SECRETSHARING_decrypt(), GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_timestamp_hton(), GSC_KX_handle_client_monitor_peers(), handle_client_call_message(), handle_client_loc_sign(), handle_datastore_reply(), handle_list(), handle_lookup_block_it(), handle_p2p_reply(), inject_rekey(), inject_rekey(), monitor_notify_all(), notify_monitor(), PEERSTORE_create_record_mq_envelope(), pils_sign_address(), put_action(), regex_iterator(), report_link(), response_action(), run_edkey(), run_pkey(), send_challenge(), send_challenge(), send_create(), send_lookup_response_with_filter(), send_message_to_room(), send_msg_with_kx(), send_request(), send_simple_single(), setup_estimate_message(), setup_flood_message(), sign_ephemeral(), sign_pow_identity(), sign_srv_room_message(), start_dv_learn(), transmit_content(), transmit_item(), transmit_kx(), transmit_kx(), transmit_status(), update_backtalker_monotime(), uri_loc_parse(), validation_transmit_on_queue(), and verify_hello().

Here is the call graph for this function:

◆ GNUNET_TIME_timestamp_hton()

struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton ( struct GNUNET_TIME_Timestamp  t)

Convert timestamp to network byte order.

Parameters
ttime to convert
Returns
converted time value

Definition at line 91 of file time.c.

92{
94
96 return tn;
97}
struct GNUNET_TIME_AbsoluteNBO abs_time_nbo
The actual value.

References GNUNET_TIME_TimestampNBO::abs_time_nbo, GNUNET_TIME_absolute_hton(), and t.

Referenced by extract_timestamp_nbo(), and parse_timestamp_nbo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_from_ms()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_ms ( uint64_t  ms_after_epoch)

Convert milliseconds after the UNIX epoch to absolute time.

Parameters
ms_after_epochmillisecond timestamp to convert
Returns
converted time value

Definition at line 687 of file time.c.

688{
690
692 * ms_after_epoch;
693 if (ret.abs_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us !=
694 ms_after_epoch)
696 return ret;
697}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_MILLISECONDS, and ret.

◆ GNUNET_TIME_absolute_is_never()

bool GNUNET_TIME_absolute_is_never ( struct GNUNET_TIME_Absolute  abs)

Test if abs is never.

Returns
true if it is.

Definition at line 646 of file time.c.

647{
648 return GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == abs.abs_value_us;
649}

References GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_UNIT_FOREVER_ABS.

Referenced by GNUNET_JSON_from_timestamp(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_fancy_time_to_timestamp(), GNUNET_TIME_absolute2s(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_subtract(), GNUNET_TIME_absolute_to_timestamp(), GNUNET_TIME_timestamp2s(), GNUNET_TIME_timestamp_to_s(), round_down(), and round_up().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_is_past()

bool GNUNET_TIME_absolute_is_past ( struct GNUNET_TIME_Absolute  abs)

Test if abs is truly in the past (excluding now).

Returns
true if it is.

Definition at line 667 of file time.c.

668{
669 struct GNUNET_TIME_Absolute now;
670
672 return abs.abs_value_us < now.abs_value_us;
673}

References GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_absolute_get().

Referenced by block_plugin_dns_check_block(), block_plugin_regex_check_block(), check_rekey(), datacache_get_iterator(), get_cb(), handle_dht_p2p_put(), handle_dht_p2p_result(), handle_find_local_hello(), transmit_next_request_task(), and verify_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_is_zero()

bool GNUNET_TIME_absolute_is_zero ( struct GNUNET_TIME_Absolute  abs)

Test if abs is truly zero.

Returns
true if it is.

Definition at line 844 of file time.c.

845{
846 return 0 == abs.abs_value_us;
847}

References GNUNET_TIME_Absolute::abs_value_us.

Referenced by GNUNET_JSON_pack_timestamp().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_is_future()

bool GNUNET_TIME_absolute_is_future ( struct GNUNET_TIME_Absolute  abs)

Test if abs is truly in the future (excluding now).

Returns
true if it is.

Definition at line 677 of file time.c.

678{
679 struct GNUNET_TIME_Absolute now;
680
682 return abs.abs_value_us > now.abs_value_us;
683}

References GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_absolute_get().

Here is the call graph for this function:

◆ GNUNET_TIME_relative_is_forever()

bool GNUNET_TIME_relative_is_forever ( struct GNUNET_TIME_Relative  rel)

Test if rel is forever.

Returns
true if it is.

Definition at line 653 of file time.c.

654{
655 return GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rel.rel_value_us;
656}

References GNUNET_TIME_UNIT_FOREVER_REL, and GNUNET_TIME_Relative::rel_value_us.

Referenced by GNUNET_JSON_from_time_rel(), GNUNET_TIME_absolute_add(), GNUNET_TIME_relative2s(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_multiply_double(), GNUNET_TIME_relative_saturating_multiply(), and GNUNET_TIME_relative_to_absolute().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_is_zero()

bool GNUNET_TIME_relative_is_zero ( struct GNUNET_TIME_Relative  rel)

Test if rel is zero.

Returns
true if it is.

Definition at line 660 of file time.c.

661{
662 return 0 == rel.rel_value_us;
663}

References GNUNET_TIME_Relative::rel_value_us.

Referenced by GNUNET_TIME_absolute_round_down(), GNUNET_TIME_relative_to_round_interval(), handle_appeal_message(), handle_epoch_announcement_delay(), is_epoch_announcement_appealed(), is_epoch_proposing(), run(), send_epoch_announcement(), send_epoch_group_announcement(), and set_epoch_proposal_group().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_from_s()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s ( uint64_t  s_after_epoch)

Convert seconds after the UNIX epoch to absolute time.

Parameters
s_after_epochseconds after epoch to convert
Returns
converted time value

Definition at line 701 of file time.c.

702{
704
705 ret.abs_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * s_after_epoch;
706 if (ret.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us !=
707 s_after_epoch)
709 return ret;
710}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_SECONDS, and ret.

Referenced by GNUNET_STRINGS_fancy_time_to_absolute().

Here is the caller graph for this function:

◆ GNUNET_TIME_timestamp_from_s()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_from_s ( uint64_t  s_after_epoch)

Convert seconds after the UNIX epoch to timestamp.

Parameters
s_after_epochseconds after epoch to convert
Returns
converted time value

Definition at line 714 of file time.c.

715{
717
719 = GNUNET_TIME_UNIT_SECONDS.rel_value_us * s_after_epoch;
720 if (ret.abs_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us
721 != s_after_epoch)
723 return ret;
724}

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_UNIT_FOREVER_TS, GNUNET_TIME_UNIT_SECONDS, and ret.

◆ GNUNET_TIME_timestamp_to_s()

uint64_t GNUNET_TIME_timestamp_to_s ( struct GNUNET_TIME_Timestamp  ts)

Convert timestamp to number of seconds after the UNIX epoch.

Parameters
tstimestamp to convert
Returns
converted time value

Definition at line 728 of file time.c.

729{
731 return UINT64_MAX;
732 return ts.abs_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
733}

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_absolute_is_never(), and GNUNET_TIME_UNIT_SECONDS.

Here is the call graph for this function:

◆ GNUNET_TIME_absolute_ntoh()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh ( struct GNUNET_TIME_AbsoluteNBO  a)

Convert absolute time from network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 737 of file time.c.

738{
740
742 return ret;
743}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_ntohll(), and ret.

Referenced by backtalker_monotime_cb(), bind_nbotime(), block_plugin_dns_check_block(), block_plugin_regex_check_block(), decaps_dv_box_cont(), do_dht_put(), do_rekey(), do_rekey(), GCP_check_and_update_monotime(), get_message_timeout(), get_network_latency(), GNUNET_GNSRECORD_block_get_expiration(), GNUNET_GNSRECORD_check_pow(), GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_HELLO_parser_from_block_(), GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_timestamp_ntoh(), handle_arm_list_result(), handle_cadet_ring_message(), handle_client_decrypt(), handle_client_join(), handle_client_keygen(), handle_client_loc_sign(), handle_client_redirect_to_ip(), handle_client_redirect_to_service(), handle_client_send_request(), handle_data(), handle_dht_local_put(), handle_dht_p2p_put(), handle_dht_p2p_result(), handle_dht_result(), handle_dv_learn(), handle_estimate(), handle_flow_control(), handle_link_list_response(), handle_lookup_block_response(), handle_message_id(), handle_message_join(), handle_message_subscribe(), handle_monitor_data(), handle_monitor_get_resp(), handle_monitor_put(), handle_p2p_estimate(), handle_p2p_put(), handle_put(), handle_put(), handle_receive_info(), handle_record_result(), handle_reply(), handle_result(), handle_result(), handle_signature_response(), handle_status(), handle_test(), handle_validation_response(), handshake_ack_monotime_cb(), handshake_ack_monotime_cb(), handshake_monotime_cb(), handshake_monotime_cb(), inject_rekey(), inject_rekey(), iterate_flag_for_cleanup_discourse_message(), neighbour_dv_monotime_cb(), notify_srv_handle_message(), PEERSTORE_parse_record_message(), process_client_result(), put_cb(), rekey_monotime_cb(), rekey_monotime_cb(), run(), transmit_task_cb(), update_flood_message(), and verify_tunnel_message().

Here is the call graph for this function:

◆ GNUNET_TIME_timestamp_ntoh()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_ntoh ( struct GNUNET_TIME_TimestampNBO  tn)

Convert timestamp from network byte order.

Parameters
tntime to convert
Returns
converted time value

Definition at line 101 of file time.c.

102{
104
106 return t;
107}

References GNUNET_TIME_absolute_ntoh(), and t.

Referenced by GNUNET_JSON_from_timestamp_nbo(), and GNUNET_JSON_pack_timestamp_nbo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_set_offset()

void GNUNET_TIME_set_offset ( long long  offset)

Set the timestamp offset for this instance.

Parameters
offsetthe offset to skew the locale time by

Definition at line 49 of file time.c.

50{
51 timestamp_offset = offset;
52}

References timestamp_offset.

Referenced by do_speedup(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), and set_timetravel_time().

Here is the caller graph for this function:

◆ GNUNET_TIME_get_offset()

long long GNUNET_TIME_get_offset ( void  )

Get the timestamp offset for this instance.

Returns
the offset we currently skew the locale time by

Definition at line 56 of file time.c.

57{
58 return timestamp_offset;
59}

References timestamp_offset.

Referenced by mylog().

Here is the caller graph for this function:

◆ GNUNET_TIME_get_current_year()

unsigned int GNUNET_TIME_get_current_year ( void  )

Return the current year (e.g.

'2011').

Definition at line 747 of file time.c.

748{
749 time_t tp;
750 struct tm *t;
751
752 tp = time (NULL);
753 t = gmtime (&tp);
754 if (t == NULL)
755 return 0;
756 return t->tm_year + 1900;
757}

References t.

Referenced by main().

Here is the caller graph for this function:

◆ GNUNET_TIME_year_to_time()

struct GNUNET_TIME_Absolute GNUNET_TIME_year_to_time ( unsigned int  year)

Convert a year to an expiration time of January 1st of that year.

Parameters
yeara year (after 1970, please ;-)).
Returns
absolute time for January 1st of that year.

Definition at line 801 of file time.c.

802{
804 time_t tp;
805 struct tm t;
806
807 memset (&t, 0, sizeof(t));
808 if (year < 1900)
809 {
810 GNUNET_break (0);
811 return GNUNET_TIME_absolute_get (); /* now */
812 }
813 t.tm_year = year - 1900;
814 t.tm_mday = 1;
815 t.tm_mon = 0;
816 t.tm_wday = 1;
817 t.tm_yday = 1;
818#ifndef HAVE_TIMEGM
819 tp = my_timegm (&t);
820#else
821 tp = timegm (&t);
822#endif
823 GNUNET_break (tp != (time_t) -1);
824 ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
825 return ret;
826}
static time_t my_timegm(struct tm *tm)
As suggested in the timegm() man page.
Definition time.c:779

References GNUNET_break, GNUNET_TIME_absolute_get(), my_timegm(), ret, and t.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_time_to_year()

unsigned int GNUNET_TIME_time_to_year ( struct GNUNET_TIME_Absolute  at)

Convert an expiration time to the respective year (rounds)

Parameters
atabsolute time
Returns
year a year (after 1970), 0 on error

Definition at line 761 of file time.c.

762{
763 struct tm *t;
764 time_t tp;
765
766 tp = at.abs_value_us / 1000LL / 1000LL; /* microseconds to seconds */
767 t = gmtime (&tp);
768 if (t == NULL)
769 return 0;
770 return t->tm_year + 1900;
771}

References GNUNET_TIME_Absolute::abs_value_us, and t.

◆ GNUNET_TIME_absolute_get_monotonic()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_monotonic ( const struct GNUNET_CONFIGURATION_Handle cfg)

Obtain the current time and make sure it is monotonically increasing.

Guards against systems without an RTC or clocks running backwards and other nasty surprises. Does not guarantee that the returned time is near the current time returned by GNUNET_TIME_absolute_get(). Two subsequent calls (within a short time period) may return the same value. Persists the last returned time on disk to ensure that time never goes backwards. As a result, the resulting value can be used to check if a message is the "most recent" value and replays of older messages (from the same origin) would be discarded.

Parameters
cfgconfiguration, used to determine where to store the time; user can also insist RTC is working nicely and disable the feature
Returns
monotonically increasing time

Definition at line 860 of file time.c.

862{
863 static const struct GNUNET_CONFIGURATION_Handle *last_cfg;
864 static struct GNUNET_TIME_Absolute last_time;
865 static struct GNUNET_DISK_MapHandle *map_handle;
866 static ATOMIC volatile uint64_t *map;
867 struct GNUNET_TIME_Absolute now;
868
870 if (last_cfg != cfg)
871 {
872 char *filename;
873
874 if (NULL != map_handle)
875 {
876 GNUNET_DISK_file_unmap (map_handle);
877 map_handle = NULL;
878 }
879 map = NULL;
880
881 last_cfg = cfg;
882 if ((NULL != cfg) &&
883 (GNUNET_OK ==
885 "util",
886 "MONOTONIC_TIME_FILENAME",
887 &filename)))
888 {
889 struct GNUNET_DISK_FileHandle *fh;
890
898 if (NULL == fh)
899 {
901 _ ("Failed to map `%s', cannot assure monotonic time!\n"),
902 filename);
903 }
904 else
905 {
906 off_t size;
907
908 size = 0;
910 if (size < (off_t) sizeof(*map))
911 {
913
915 if (sizeof(o) != GNUNET_DISK_file_write (fh, &o, sizeof(o)))
916 size = 0;
917 else
918 size = sizeof(o);
919 }
920 if (size == sizeof(*map))
921 {
923 &map_handle,
925 sizeof(*map));
926 if (NULL == map)
928 _ (
929 "Failed to map `%s', cannot assure monotonic time!\n")
930 ,
931 filename);
932 }
933 else
934 {
935 GNUNET_log (
937 _ (
938 "Failed to setup monotonic time file `%s', cannot assure monotonic time!\n"),
939 filename);
940 }
941 }
944 }
945 }
946 if (NULL != map)
947 {
948 struct GNUNET_TIME_AbsoluteNBO mt;
949
950#if __STDC_NO_ATOMICS__
951#if __GNUC__
952 mt.abs_value_us__ = __sync_fetch_and_or (map, 0);
953#else
954 mt.abs_value_us__ = *map; /* godspeed, pray this is atomic */
955#endif
956#else
957 mt.abs_value_us__ = atomic_load (map);
958#endif
959 last_time =
961 }
962 if (now.abs_value_us <= last_time.abs_value_us)
963 now.abs_value_us = last_time.abs_value_us + 1;
964 last_time = now;
965 if (NULL != map)
966 {
967 uint64_t val = GNUNET_TIME_absolute_hton (now).abs_value_us__;
968#if __STDC_NO_ATOMICS__
969#if __GNUC__
970 (void) __sync_lock_test_and_set (map, val);
971#else
972 *map = val; /* godspeed, pray this is atomic */
973#endif
974#else
975 atomic_store (map, val);
976#endif
977 }
978 return now;
979}
static char * filename
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition disk.c:1308
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition disk.c:745
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition disk.c:1386
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
Definition disk.c:1460
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
Definition disk.c:206
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
Definition disk.c:1491
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_MAP_TYPE_READWRITE
Read-write memory map.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Peermap of PeerIdentities to "struct PeerEntry" (for fast lookup).
Definition peer.c:63
static unsigned int size
Size of the "table".
Definition peer.c:68
#define _(String)
GNU gettext support macro.
Definition platform.h:179
Handle used to access files (and pipes).
Handle for a memory-mapping operation.
Definition disk.c:1441
#define ATOMIC
Definition time.c:37

References _, GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_AbsoluteNBO::abs_value_us__, ATOMIC, cfg, filename, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_DISK_file_close(), GNUNET_DISK_file_handle_size(), GNUNET_DISK_file_map(), GNUNET_DISK_file_open(), GNUNET_DISK_file_unmap(), GNUNET_DISK_file_write(), GNUNET_DISK_MAP_TYPE_READWRITE, GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_GROUP_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_absolute_max(), GNUNET_TIME_absolute_ntoh(), map, and size.

Referenced by __attribute__(), consider_sending_fc(), handle_validation_response(), inject_rekey(), inject_rekey(), revalidate_now_cb(), run(), send_challenge(), send_challenge(), send_create(), send_msg_with_kx(), sign_ephemeral(), start_address_validation(), start_dv_learn(), transmit_kx(), transmit_kx(), validation_start_cb(), and validation_transmit_on_queue().

Here is the call graph for this function:
Here is the caller graph for this function: