diff options
Diffstat (limited to 'core/util.c')
-rw-r--r-- | core/util.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/core/util.c b/core/util.c index 6b40dad7..d201bcb4 100644 --- a/core/util.c +++ b/core/util.c | |||
@@ -9,23 +9,37 @@ | |||
9 | #include <stdint.h> | 9 | #include <stdint.h> |
10 | #include <stdbool.h> | 10 | #include <stdbool.h> |
11 | 11 | ||
12 | #include "network.h" | 12 | #include "DHT.h" |
13 | #include "packets.h" | ||
13 | 14 | ||
14 | uint64_t now() { | 15 | uint64_t now() |
15 | return time(NULL); | 16 | { |
17 | return time(NULL); | ||
16 | } | 18 | } |
17 | 19 | ||
18 | uint64_t random_64b() { | 20 | uint64_t random_64b() |
19 | uint64_t r; | 21 | { |
22 | uint64_t r; | ||
20 | 23 | ||
21 | // This is probably not random enough? | 24 | // This is probably not random enough? |
22 | r = random_int(); | 25 | r = random_int(); |
23 | r <<= 32; | 26 | r <<= 32; |
24 | r |= random_int(); | 27 | r |= random_int(); |
25 | 28 | ||
26 | return r; | 29 | return r; |
27 | } | 30 | } |
28 | 31 | ||
29 | bool ipp_eq(IP_Port a, IP_Port b) { | 32 | bool ipp_eq(IP_Port a, IP_Port b) |
30 | return (a.ip.i == b.ip.i) && (a.port == b.port); | 33 | { |
34 | return (a.ip.i == b.ip.i) && (a.port == b.port); | ||
35 | } | ||
36 | |||
37 | bool id_eq(clientid_t* dest, clientid_t* src) | ||
38 | { | ||
39 | return memcmp(dest, src, sizeof(clientid_t)) == 0; | ||
40 | } | ||
41 | |||
42 | void id_cpy(clientid_t* dest, clientid_t* src) | ||
43 | { | ||
44 | memcpy(dest, src, sizeof(clientid_t)); | ||
31 | } | 45 | } |