From 071ac463082646189ade6e31bb3f6051516f81b2 Mon Sep 17 00:00:00 2001 From: plutooo Date: Mon, 5 Aug 2013 12:51:58 -0700 Subject: core: Rewrote ping-module, better performance and cleaner code. --- core/util.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/util.c (limited to 'core/util.c') 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 @@ +/* + * util.c -- Utilities. + * + * This file is donated to the Tox Project. + * Copyright 2013 plutooo + */ + +#include +#include +#include + +#include "network.h" + +uint64_t now() { + return time(NULL); +} + +uint64_t random_64b() { + uint64_t r; + + // This is probably not random enough? + r = random_int(); + r <<= 32; + r |= random_int(); + + return r; +} + +bool ipp_eq(IP_Port a, IP_Port b) { + return (a.ip.i == b.ip.i) && (a.port == b.port); +} -- cgit v1.2.3