summaryrefslogtreecommitdiff
path: root/core/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/DHT.h')
-rw-r--r--core/DHT.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/core/DHT.h b/core/DHT.h
index f0ccd184..2e6dde6f 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -59,6 +59,19 @@ typedef struct
59}Pinged; 59}Pinged;
60 60
61 61
62typedef struct
63{
64 int16_t family;
65 uint16_t port;
66 IP ip;
67 uint8_t zeroes[8];
68 #ifdef ENABLE_IPV6
69 uint8_t zeroes2[12];
70 #endif
71}ADDR;
72
73
74
62//Add a new friend to the friends list 75//Add a new friend to the friends list
63//client_id must be 32 bytes long. 76//client_id must be 32 bytes long.
64void addfriend(char * client_id); 77void addfriend(char * client_id);
@@ -83,7 +96,7 @@ IP_Port getfriendip(char * client_id);
83void doDHT(); 96void doDHT();
84 97
85//if we recieve a DHT packet we call this function so it can be handled. 98//if we recieve a DHT packet we call this function so it can be handled.
86void DHT_recvpacket(char * packet, uint32_t length); 99void DHT_recvpacket(char * packet, uint32_t length, IP_Port source);
87 100
88//Use this function to bootstrap the client 101//Use this function to bootstrap the client
89//Sends a get nodes request to the given ip port 102//Sends a get nodes request to the given ip port
@@ -103,7 +116,9 @@ char self_client_id[32];
103//We only use one so it's much easier to have it as a global variable 116//We only use one so it's much easier to have it as a global variable
104int sock; 117int sock;
105 118
106Client_data client_list[32]; 119#define LCLIENT_LIST 32
120
121Client_data client_list[LCLIENT_LIST];
107 122
108//Let's start with a static array for testing. 123//Let's start with a static array for testing.
109Friend friends_list[256]; 124Friend friends_list[256];
@@ -111,8 +126,12 @@ uint16_t num_friends;
111 126
112//The list of ip ports along with the ping_id of what we sent them and a timestamp 127//The list of ip ports along with the ping_id of what we sent them and a timestamp
113//TODO: make this more efficient looping up to 128 times is a bit... 128//TODO: make this more efficient looping up to 128 times is a bit...
114Pinged pings[128]; 129#define LPING_ARRAY 128
130
131Pinged pings[LPING_ARRAY];
132
133#define LSEND_NODES_ARRAY LPING_ARRAY/2
115 134
116Pinged send_nodes[64]; 135Pinged send_nodes[LSEND_NODES_ARRAY];
117 136
118 137