diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-20 07:55:21 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-20 07:55:21 -0400 |
commit | 11e94066f710a602a9a071b028036a2b35de2741 (patch) | |
tree | 0a6c037e40c0d8744516715c7b4e126d94e75841 /core/DHT.h | |
parent | 41cc5b19caae05fb751dc9b066b1ea98c263f585 (diff) | |
parent | a72777ed70ed6bfcda8a532c52e0d64241a8bb71 (diff) |
Merge branch 'master' of https://github.com/sometwo/ProjectTox-Core into sometwo-master
Conflicts:
core/Messenger.c
Diffstat (limited to 'core/DHT.h')
-rw-r--r-- | core/DHT.h | 64 |
1 files changed, 32 insertions, 32 deletions
@@ -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) */ |
43 | int DHT_addfriend(uint8_t * client_id); | 43 | int 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) */ |
49 | int DHT_delfriend(uint8_t * client_id); | 49 | int 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. */ |
59 | IP_Port DHT_getfriendip(uint8_t * client_id); | 59 | IP_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) */ |
63 | void doDHT(); | 63 | void 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. */ |
68 | int DHT_handlepacket(uint8_t * packet, uint32_t length, IP_Port source); | 68 | int 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 */ |
72 | void DHT_bootstrap(IP_Port ip_port, uint8_t * public_key); | 72 | void 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) */ |
78 | uint32_t DHT_size(); | 78 | uint32_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() */ |
82 | void DHT_save(uint8_t * data); | 82 | void 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 */ |
87 | int DHT_load(uint8_t * data, uint32_t size); | 87 | int 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 */ |
91 | int DHT_isconnected(); | 91 | int DHT_isconnected(); |
92 | 92 | ||
93 | #endif | 93 | #endif |