diff options
Diffstat (limited to 'core/util.c')
-rw-r--r-- | core/util.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/util.c b/core/util.c new file mode 100644 index 00000000..6b40dad7 --- /dev/null +++ b/core/util.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * util.c -- Utilities. | ||
3 | * | ||
4 | * This file is donated to the Tox Project. | ||
5 | * Copyright 2013 plutooo | ||
6 | */ | ||
7 | |||
8 | #include <time.h> | ||
9 | #include <stdint.h> | ||
10 | #include <stdbool.h> | ||
11 | |||
12 | #include "network.h" | ||
13 | |||
14 | uint64_t now() { | ||
15 | return time(NULL); | ||
16 | } | ||
17 | |||
18 | uint64_t random_64b() { | ||
19 | uint64_t r; | ||
20 | |||
21 | // This is probably not random enough? | ||
22 | r = random_int(); | ||
23 | r <<= 32; | ||
24 | r |= random_int(); | ||
25 | |||
26 | return r; | ||
27 | } | ||
28 | |||
29 | bool ipp_eq(IP_Port a, IP_Port b) { | ||
30 | return (a.ip.i == b.ip.i) && (a.port == b.port); | ||
31 | } | ||