From 23359fd5d5a89360b22e986c9bdbeb2c370a4bcb Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Thu, 17 Jun 2021 00:04:36 +0200 Subject: Add tests and test running --- src/routing.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/routing.h (limited to 'src/routing.h') diff --git a/src/routing.h b/src/routing.h new file mode 100644 index 0000000..dc40aa9 --- /dev/null +++ b/src/routing.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include +#include +#include + +#define dbg(format, ...) \ + dbgl(format "\n", ## __VA_ARGS__) + +#define dbgl(format, ...) \ + printf(format, ## __VA_ARGS__); \ + fflush(stderr) + +#define err(format, ...) \ + printf(format "\n", ## __VA_ARGS__); \ + fflush(stderr) + + +struct addr { + uint32_t ip; + uint16_t port; +}; + +struct nodeid { + uint32_t inner[5]; +}; + +struct entry { + bool set; + struct nodeid id; + time_t last; + struct addr addr; +}; + +void routing_init(struct nodeid* myid); +bool routing_offer(struct nodeid* id, struct entry **dest); +size_t rounting_closest(struct nodeid* needle, size_t n, struct entry** res); -- cgit v1.2.3