diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2022-02-17 19:18:08 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2022-02-18 08:43:14 +0100 |
commit | 4fe23eccc3a62b02289964391a0cd611db89ed8b (patch) | |
tree | cc4602c0022f1f523df2251ca73a52dac55f7e24 /src/ipcpd/unicast/addr-auth | |
parent | 26f9d9880cdd8392379516d795a3cabb5f412728 (diff) | |
download | ouroboros-4fe23eccc3a62b02289964391a0cd611db89ed8b.tar.gz ouroboros-4fe23eccc3a62b02289964391a0cd611db89ed8b.zip |
ipcpd: Use random buffer for flat address
Less code, and less chance of a collision.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/unicast/addr-auth')
-rw-r--r-- | src/ipcpd/unicast/addr-auth/flat.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/ipcpd/unicast/addr-auth/flat.c b/src/ipcpd/unicast/addr-auth/flat.c index af245a5d..061cb01f 100644 --- a/src/ipcpd/unicast/addr-auth/flat.c +++ b/src/ipcpd/unicast/addr-auth/flat.c @@ -29,19 +29,11 @@ #define OUROBOROS_PREFIX "flat-addr-auth" #include <ouroboros/logs.h> -#include <ouroboros/errno.h> -#include <ouroboros/time_utils.h> -#include <ouroboros/utils.h> +#include <ouroboros/random.h> #include "ipcp.h" #include "flat.h" -#include <time.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include <assert.h> - #define NAME_LEN 8 struct { @@ -75,13 +67,10 @@ int flat_fini(void) uint64_t flat_address(void) { - struct timespec t; - uint32_t addr; - - clock_gettime(CLOCK_REALTIME, &t); - srand(t.tv_nsec); + uint32_t addr = INVALID_ADDRESS; - addr = (rand() % (RAND_MAX - 1) + 1) & 0xFFFFFFFF; + while (addr == INVALID_ADDRESS) + random_buffer(&addr,sizeof(addr)); return addr; } |