summaryrefslogtreecommitdiff
path: root/core/util.c
diff options
context:
space:
mode:
authorplutooo <tfy12vbr@student.lu.se>2013-08-06 09:31:29 -0700
committerplutooo <tfy12vbr@student.lu.se>2013-08-06 09:42:38 -0700
commit659a1a06a92e3a1230d10b0d7ac12bb09fcdaafb (patch)
treed00900d8cb8da93bd9e36b8f533faa65ba6d575d /core/util.c
parent99d9ecf74cab43ca6ae24ab5dd62a3b758b3e666 (diff)
parente71413d8f1fab4928be0e024821d58147f6f1b0e (diff)
Merge branch 'dev'
Conflicts: core/packets.h core/ping.c
Diffstat (limited to 'core/util.c')
-rw-r--r--core/util.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/core/util.c b/core/util.c
index 5b560171..d201bcb4 100644
--- a/core/util.c
+++ b/core/util.c
@@ -12,29 +12,34 @@
12#include "DHT.h" 12#include "DHT.h"
13#include "packets.h" 13#include "packets.h"
14 14
15uint64_t now() { 15uint64_t now()
16 return time(NULL); 16{
17 return time(NULL);
17} 18}
18 19
19uint64_t random_64b() { 20uint64_t random_64b()
20 uint64_t r; 21{
22 uint64_t r;
21 23
22 // This is probably not random enough? 24 // This is probably not random enough?
23 r = random_int(); 25 r = random_int();
24 r <<= 32; 26 r <<= 32;
25 r |= random_int(); 27 r |= random_int();
26 28
27 return r; 29 return r;
28} 30}
29 31
30bool ipp_eq(IP_Port a, IP_Port b) { 32bool ipp_eq(IP_Port a, IP_Port b)
31 return (a.ip.i == b.ip.i) && (a.port == b.port); 33{
34 return (a.ip.i == b.ip.i) && (a.port == b.port);
32} 35}
33 36
34bool id_eq(clientid_t* dest, clientid_t* src) { 37bool id_eq(clientid_t* dest, clientid_t* src)
35 return memcmp(dest, src, sizeof(clientid_t)) == 0; 38{
39 return memcmp(dest, src, sizeof(clientid_t)) == 0;
36} 40}
37 41
38void id_cpy(clientid_t* dest, clientid_t* src) { 42void id_cpy(clientid_t* dest, clientid_t* src)
39 memcpy(dest, src, sizeof(clientid_t)); 43{
44 memcpy(dest, src, sizeof(clientid_t));
40} 45}