summaryrefslogtreecommitdiff
path: root/core/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/DHT.h')
-rw-r--r--core/DHT.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/DHT.h b/core/DHT.h
index 0acc6602..7493761a 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -21,8 +21,11 @@
21//Current time, unix format 21//Current time, unix format
22#define unix_time() ((uint32_t)time(NULL)) 22#define unix_time() ((uint32_t)time(NULL))
23 23
24//size of the client_id in bytes
24#define CLIENT_ID_SIZE 32 25#define CLIENT_ID_SIZE 32
25 26
27#define MAX_UDP_PACKET_SIZE 65507
28
26typedef union 29typedef union
27{ 30{
28 uint8_t c[4]; 31 uint8_t c[4];
@@ -100,7 +103,9 @@ IP_Port getfriendip(char * client_id);
100void doDHT(); 103void doDHT();
101 104
102//if we recieve a DHT packet we call this function so it can be handled. 105//if we recieve a DHT packet we call this function so it can be handled.
103void DHT_recvpacket(char * packet, uint32_t length, IP_Port source); 106//Return 0 if packet is handled correctly or if the packet was shit.
107//return 1 if it didn't handle the packet.
108int DHT_recvpacket(char * packet, uint32_t length, IP_Port source);
104 109
105//Use this function to bootstrap the client 110//Use this function to bootstrap the client
106//Sends a get nodes request to the given ip port 111//Sends a get nodes request to the given ip port
@@ -139,3 +144,13 @@ Pinged pings[LPING_ARRAY];
139Pinged send_nodes[LSEND_NODES_ARRAY]; 144Pinged send_nodes[LSEND_NODES_ARRAY];
140 145
141 146
147//Basic network functions:
148//TODO: put them somewhere else than here
149
150//Function to send packet(data) of length length to ip_port
151int sendpacket(IP_Port ip_port, char * data, uint32_t length);
152
153//Function to recieve data, ip and port of sender is put into ip_port
154//the packet data into data
155//the packet length into length.
156int recievepacket(IP_Port * ip_port, char * data, uint32_t * length); \ No newline at end of file