summaryrefslogtreecommitdiff
path: root/src/routing.h
blob: 540f3f649174d5ec5953f622bea2b50f89cd7097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
#include <stdio.h>

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);
void routing_flush();
bool routing_interested(struct nodeid* id);
bool routing_offer(struct nodeid* id, struct entry **dest);
size_t routing_closest(struct nodeid* needle, size_t n, struct entry** res);