diff options
Diffstat (limited to 'toxcore/DHT.h')
-rw-r--r-- | toxcore/DHT.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index c437bbb0..a36ea252 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -104,7 +104,7 @@ typedef struct { | |||
104 | } IPPTsPng; | 104 | } IPPTsPng; |
105 | 105 | ||
106 | typedef struct { | 106 | typedef struct { |
107 | uint8_t public_key[CLIENT_ID_SIZE]; | 107 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; |
108 | IPPTsPng assoc4; | 108 | IPPTsPng assoc4; |
109 | IPPTsPng assoc6; | 109 | IPPTsPng assoc6; |
110 | } Client_data; | 110 | } Client_data; |
@@ -127,7 +127,7 @@ typedef struct { | |||
127 | #define DHT_FRIEND_MAX_LOCKS 32 | 127 | #define DHT_FRIEND_MAX_LOCKS 32 |
128 | 128 | ||
129 | typedef struct { | 129 | typedef struct { |
130 | uint8_t public_key[CLIENT_ID_SIZE]; | 130 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; |
131 | Client_data client_list[MAX_FRIEND_CLIENTS]; | 131 | Client_data client_list[MAX_FRIEND_CLIENTS]; |
132 | 132 | ||
133 | /* Time at which the last get_nodes request was sent. */ | 133 | /* Time at which the last get_nodes request was sent. */ |
@@ -182,7 +182,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed | |||
182 | #define KEYS_TIMEOUT 600 | 182 | #define KEYS_TIMEOUT 600 |
183 | typedef struct { | 183 | typedef struct { |
184 | struct { | 184 | struct { |
185 | uint8_t public_key[CLIENT_ID_SIZE]; | 185 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; |
186 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 186 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
187 | uint32_t times_requested; | 187 | uint32_t times_requested; |
188 | uint8_t stored; /* 0 if not, 1 if is */ | 188 | uint8_t stored; /* 0 if not, 1 if is */ |
@@ -257,7 +257,7 @@ void DHT_get_shared_key_sent(DHT *dht, uint8_t *shared_key, const uint8_t *publi | |||
257 | void DHT_getnodes(DHT *dht, const IP_Port *from_ipp, const uint8_t *from_id, const uint8_t *which_id); | 257 | void DHT_getnodes(DHT *dht, const IP_Port *from_ipp, const uint8_t *from_id, const uint8_t *which_id); |
258 | 258 | ||
259 | /* Add a new friend to the friends list. | 259 | /* Add a new friend to the friends list. |
260 | * client_id must be CLIENT_ID_SIZE bytes long. | 260 | * public_key must be crypto_box_PUBLICKEYBYTES bytes long. |
261 | * | 261 | * |
262 | * ip_callback is the callback of a function that will be called when the ip address | 262 | * ip_callback is the callback of a function that will be called when the ip address |
263 | * is found along with arguments data and number. | 263 | * is found along with arguments data and number. |
@@ -268,39 +268,39 @@ void DHT_getnodes(DHT *dht, const IP_Port *from_ipp, const uint8_t *from_id, con | |||
268 | * return 0 if success. | 268 | * return 0 if success. |
269 | * return -1 if failure (friends list is full). | 269 | * return -1 if failure (friends list is full). |
270 | */ | 270 | */ |
271 | int DHT_addfriend(DHT *dht, const uint8_t *client_id, void (*ip_callback)(void *data, int32_t number, IP_Port), | 271 | int DHT_addfriend(DHT *dht, const uint8_t *public_key, void (*ip_callback)(void *data, int32_t number, IP_Port), |
272 | void *data, int32_t number, uint16_t *lock_count); | 272 | void *data, int32_t number, uint16_t *lock_count); |
273 | 273 | ||
274 | /* Delete a friend from the friends list. | 274 | /* Delete a friend from the friends list. |
275 | * client_id must be CLIENT_ID_SIZE bytes long. | 275 | * public_key must be crypto_box_PUBLICKEYBYTES bytes long. |
276 | * | 276 | * |
277 | * return 0 if success. | 277 | * return 0 if success. |
278 | * return -1 if failure (client_id not in friends list). | 278 | * return -1 if failure (public_key not in friends list). |
279 | */ | 279 | */ |
280 | int DHT_delfriend(DHT *dht, const uint8_t *client_id, uint16_t lock_count); | 280 | int DHT_delfriend(DHT *dht, const uint8_t *public_key, uint16_t lock_count); |
281 | 281 | ||
282 | /* Get ip of friend. | 282 | /* Get ip of friend. |
283 | * client_id must be CLIENT_ID_SIZE bytes long. | 283 | * public_key must be crypto_box_PUBLICKEYBYTES bytes long. |
284 | * ip must be 4 bytes long. | 284 | * ip must be 4 bytes long. |
285 | * port must be 2 bytes long. | 285 | * port must be 2 bytes long. |
286 | * | 286 | * |
287 | * int DHT_getfriendip(DHT *dht, uint8_t *client_id, IP_Port *ip_port); | 287 | * int DHT_getfriendip(DHT *dht, uint8_t *public_key, IP_Port *ip_port); |
288 | * | 288 | * |
289 | * return -1, -- if client_id does NOT refer to a friend | 289 | * return -1, -- if public_key does NOT refer to a friend |
290 | * return 0, -- if client_id refers to a friend and we failed to find the friend (yet) | 290 | * return 0, -- if public_key refers to a friend and we failed to find the friend (yet) |
291 | * return 1, ip if client_id refers to a friend and we found him | 291 | * return 1, ip if public_key refers to a friend and we found him |
292 | */ | 292 | */ |
293 | int DHT_getfriendip(const DHT *dht, const uint8_t *client_id, IP_Port *ip_port); | 293 | int DHT_getfriendip(const DHT *dht, const uint8_t *public_key, IP_Port *ip_port); |
294 | 294 | ||
295 | /* Compares client_id1 and client_id2 with client_id. | 295 | /* Compares pk1 and pk2 with pk. |
296 | * | 296 | * |
297 | * return 0 if both are same distance. | 297 | * return 0 if both are same distance. |
298 | * return 1 if client_id1 is closer. | 298 | * return 1 if pk1 is closer. |
299 | * return 2 if client_id2 is closer. | 299 | * return 2 if pk2 is closer. |
300 | */ | 300 | */ |
301 | int id_closest(const uint8_t *id, const uint8_t *id1, const uint8_t *id2); | 301 | int id_closest(const uint8_t *pk, const uint8_t *pk1, const uint8_t *pk2); |
302 | 302 | ||
303 | /* Get the (maximum MAX_SENT_NODES) closest nodes to client_id we know | 303 | /* Get the (maximum MAX_SENT_NODES) closest nodes to public_key we know |
304 | * and put them in nodes_list (must be MAX_SENT_NODES big). | 304 | * and put them in nodes_list (must be MAX_SENT_NODES big). |
305 | * | 305 | * |
306 | * sa_family = family (IPv4 or IPv6) (0 if we don't care)? | 306 | * sa_family = family (IPv4 or IPv6) (0 if we don't care)? |
@@ -310,7 +310,7 @@ int id_closest(const uint8_t *id, const uint8_t *id1, const uint8_t *id2); | |||
310 | * return the number of nodes returned. | 310 | * return the number of nodes returned. |
311 | * | 311 | * |
312 | */ | 312 | */ |
313 | int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, | 313 | int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, sa_family_t sa_family, |
314 | uint8_t is_LAN, uint8_t want_good); | 314 | uint8_t is_LAN, uint8_t want_good); |
315 | 315 | ||
316 | 316 | ||
@@ -400,7 +400,7 @@ int DHT_isconnected(const DHT *dht); | |||
400 | int DHT_non_lan_connected(const DHT *dht); | 400 | int DHT_non_lan_connected(const DHT *dht); |
401 | 401 | ||
402 | 402 | ||
403 | int addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *client_id); | 403 | int addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *public_key); |
404 | 404 | ||
405 | #endif | 405 | #endif |
406 | 406 | ||