summaryrefslogtreecommitdiff
path: root/core/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/DHT.h')
-rw-r--r--core/DHT.h64
1 files changed, 32 insertions, 32 deletions
diff --git a/core/DHT.h b/core/DHT.h
index edc4d344..68d181e8 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -28,66 +28,66 @@
28 28
29#include "net_crypto.h" 29#include "net_crypto.h"
30 30
31//Current time, unix format 31/* Current time, unix format */
32#define unix_time() ((uint32_t)time(NULL)) 32#define unix_time() ((uint32_t)time(NULL))
33 33
34//size of the client_id in bytes 34/* size of the client_id in bytes */
35#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES 35#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES
36 36
37 37
38 38
39//Add a new friend to the friends list 39/* Add a new friend to the friends list
40//client_id must be CLIENT_ID_SIZE bytes long. 40 client_id must be CLIENT_ID_SIZE bytes long.
41//returns 0 if success 41 returns 0 if success
42//returns 1 if failure (friends list is full) 42 returns 1 if failure (friends list is full) */
43int DHT_addfriend(uint8_t * client_id); 43int DHT_addfriend(uint8_t * client_id);
44 44
45//Delete a friend from the friends list 45/* Delete a friend from the friends list
46//client_id must be CLIENT_ID_SIZE bytes long. 46 client_id must be CLIENT_ID_SIZE bytes long.
47//returns 0 if success 47 returns 0 if success
48//returns 1 if failure (client_id not in friends list) 48 returns 1 if failure (client_id not in friends list) */
49int DHT_delfriend(uint8_t * client_id); 49int DHT_delfriend(uint8_t * client_id);
50 50
51 51
52//Get ip of friend 52/* Get ip of friend
53//client_id must be CLIENT_ID_SIZE bytes long. 53 client_id must be CLIENT_ID_SIZE bytes long.
54//ip must be 4 bytes long. 54 ip must be 4 bytes long.
55//port must be 2 bytes long. 55 port must be 2 bytes long.
56//returns ip if success 56 returns ip if success
57//returns ip of 0 if failure (This means the friend is either offline or we have not found him yet.) 57 returns ip of 0 if failure (This means the friend is either offline or we have not found him yet.)
58//returns ip of 1 if friend is not in list. 58 returns ip of 1 if friend is not in list. */
59IP_Port DHT_getfriendip(uint8_t * client_id); 59IP_Port DHT_getfriendip(uint8_t * client_id);
60 60
61 61
62//Run this function at least a couple times per second (It's the main loop) 62/* Run this function at least a couple times per second (It's the main loop) */
63void doDHT(); 63void doDHT();
64 64
65//if we receive a DHT packet we call this function so it can be handled. 65/* if we receive a DHT packet we call this function so it can be handled.
66//Return 0 if packet is handled correctly. 66 return 0 if packet is handled correctly.
67//return 1 if it didn't handle the packet or if the packet was shit. 67 return 1 if it didn't handle the packet or if the packet was shit. */
68int DHT_handlepacket(uint8_t * packet, uint32_t length, IP_Port source); 68int DHT_handlepacket(uint8_t * packet, uint32_t length, IP_Port source);
69 69
70//Use this function to bootstrap the client 70/* Use this function to bootstrap the client
71//Sends a get nodes request to the given node with ip port and public_key 71 Sends a get nodes request to the given node with ip port and public_key */
72void DHT_bootstrap(IP_Port ip_port, uint8_t * public_key); 72void DHT_bootstrap(IP_Port ip_port, uint8_t * public_key);
73 73
74 74
75//SAVE/LOAD functions 75/* SAVE/LOAD functions */
76 76
77//get the size of the DHT (for saving) 77/* get the size of the DHT (for saving) */
78uint32_t DHT_size(); 78uint32_t DHT_size();
79 79
80 80
81//save the DHT in data where data is an array of size DHT_size() 81/* save the DHT in data where data is an array of size DHT_size() */
82void DHT_save(uint8_t * data); 82void DHT_save(uint8_t * data);
83 83
84//load the DHT from data of size size; 84/* load the DHT from data of size size;
85//return -1 if failure 85 return -1 if failure
86//return 0 if success 86 return 0 if success */
87int DHT_load(uint8_t * data, uint32_t size); 87int DHT_load(uint8_t * data, uint32_t size);
88 88
89//returns 0 if we are not connected to the DHT 89/* returns 0 if we are not connected to the DHT
90//returns 1 if we are 90 returns 1 if we are */
91int DHT_isconnected(); 91int DHT_isconnected();
92 92
93#endif 93#endif