summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/DHT.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/core/DHT.c b/core/DHT.c
new file mode 100644
index 00000000..1b82b860
--- /dev/null
+++ b/core/DHT.c
@@ -0,0 +1,86 @@
1#include "DHT.h"
2
3//send a getnodes request
4int getnodes()
5{
6
7
8
9
10}
11
12//send a ping request
13//Currently incomplete: missing the ping_id part
14int ping(IP_Port ip_port)
15{
16 char data[37];
17 data[0] = 00;
18 memcpy(data + 5, self_client_id, 32);
19 ADDR addr = {.family = AF_INET, .ip = ip_port.ip, .port = ip_port.port};
20
21 return sendto(sock, data, sizeof(data) - 1, 0, (struct sockaddr *)&addr, addrlen);
22 //sendto(int socket_descriptor, char *buffer, int buffer_length, int flags, struct sockaddr *destination_address, int address_length);
23}
24
25
26
27void addfriend(char * client_id)
28{
29
30
31
32
33}
34
35
36
37
38
39char delfriend(char * client_id);
40{
41
42
43
44
45}
46
47
48
49
50
51IP_Port getfriendip(char * client_id)
52{
53
54
55
56}
57
58
59
60
61void DHT_recvpacket(char * packet, uint32_t length)
62{
63
64
65}
66
67
68
69
70void doDHT()
71{
72
73
74
75}
76
77
78
79
80void bootstrap(IP_Port ip_port)
81{
82
83
84
85
86} \ No newline at end of file