diff options
Diffstat (limited to 'core/util.c')
-rw-r--r-- | core/util.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/core/util.c b/core/util.c new file mode 100644 index 00000000..4ce9271e --- /dev/null +++ b/core/util.c | |||
@@ -0,0 +1,34 @@ | |||
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 | { | ||
16 | return time(NULL); | ||
17 | } | ||
18 | |||
19 | uint64_t random_64b() | ||
20 | { | ||
21 | uint64_t r; | ||
22 | |||
23 | // This is probably not random enough? | ||
24 | r = random_int(); | ||
25 | r <<= 32; | ||
26 | r |= random_int(); | ||
27 | |||
28 | return r; | ||
29 | } | ||
30 | |||
31 | bool ipp_eq(IP_Port a, IP_Port b) | ||
32 | { | ||
33 | return (a.ip.i == b.ip.i) && (a.port == b.port); | ||
34 | } | ||