diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-05 18:48:34 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-05 18:48:34 -0400 |
commit | c9a597b794291492a6ac5251119615951b5b2f5d (patch) | |
tree | 59dc0e1a9472cc535d48a281f2bbbba6f395ac55 /core/util.c | |
parent | 8618662e29a49c9412e296a1d7c6749e944431e5 (diff) | |
parent | 071ac463082646189ade6e31bb3f6051516f81b2 (diff) |
Merge branch 'master' of https://github.com/plutooo/ProjectTox-Core into plutooo-master
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 | } | ||