diff options
author | plutooo <tfy12vbr@student.lu.se> | 2013-08-05 12:51:58 -0700 |
---|---|---|
committer | plutooo <tfy12vbr@student.lu.se> | 2013-08-05 12:51:58 -0700 |
commit | 071ac463082646189ade6e31bb3f6051516f81b2 (patch) | |
tree | b9726cb351a9bcf21a0373bd561c72d72d543c60 /core/util.c | |
parent | f0397ebb2b85100e2ac1b2d3a377ba012ab53240 (diff) |
core: Rewrote ping-module, better performance and cleaner code.
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 | } | ||