mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
32 lines
467 B
C
32 lines
467 B
C
|
/*
|
||
|
* util.c -- Utilities.
|
||
|
*
|
||
|
* This file is donated to the Tox Project.
|
||
|
* Copyright 2013 plutooo
|
||
|
*/
|
||
|
|
||
|
#include <time.h>
|
||
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
|
||
|
#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);
|
||
|
}
|