From e71413d8f1fab4928be0e024821d58147f6f1b0e Mon Sep 17 00:00:00 2001 From: plutooo Date: Mon, 5 Aug 2013 15:04:38 -0700 Subject: core: Move send ping packets functions to ping.c --- core/util.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'core/util.c') 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 @@ #include #include -#include "network.h" +#include "DHT.h" +#include "packets.h" -uint64_t now() { - return time(NULL); +uint64_t now() +{ + return time(NULL); } -uint64_t random_64b() { - uint64_t r; +uint64_t random_64b() +{ + uint64_t r; - // This is probably not random enough? - r = random_int(); - r <<= 32; - r |= random_int(); + // This is probably not random enough? + r = random_int(); + r <<= 32; + r |= random_int(); - return r; + return r; } -bool ipp_eq(IP_Port a, IP_Port b) { - return (a.ip.i == b.ip.i) && (a.port == b.port); +bool ipp_eq(IP_Port a, IP_Port b) +{ + return (a.ip.i == b.ip.i) && (a.port == b.port); +} + +bool id_eq(clientid_t* dest, clientid_t* src) +{ + return memcmp(dest, src, sizeof(clientid_t)) == 0; +} + +void id_cpy(clientid_t* dest, clientid_t* src) +{ + memcpy(dest, src, sizeof(clientid_t)); } -- cgit v1.2.3