summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2014-02-15 20:44:33 +0100
committermannol <eniz_vukovic@hotmail.com>2014-02-16 19:11:55 -0500
commit393433ce9910c3dffed9090c7965654f23a8e7a8 (patch)
treeb96e08543fa3a647099cb6f3a9e55836453f51bc /toxcore/DHT.c
parent292708c33634ee0b9a2243a2181018565558bc5c (diff)
Public header ready to go
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 02175c2a..982b06c4 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -379,6 +379,7 @@ static int get_somewhat_close_nodes(DHT *dht, uint8_t *client_id, Node_format *n
379int get_close_nodes(DHT *dht, uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN, 379int get_close_nodes(DHT *dht, uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN,
380 uint8_t want_good) 380 uint8_t want_good)
381{ 381{
382 memset(nodes_list, 0, MAX_SENT_NODES * sizeof(Node_format));
382#ifdef ENABLE_ASSOC_DHT 383#ifdef ENABLE_ASSOC_DHT
383 384
384 if (!dht->assoc) 385 if (!dht->assoc)
@@ -1249,9 +1250,9 @@ int DHT_delfriend(DHT *dht, uint8_t *client_id)
1249 --dht->num_friends; 1250 --dht->num_friends;
1250 1251
1251 if (dht->num_friends != i) { 1252 if (dht->num_friends != i) {
1252 memcpy( dht->friends_list[i].client_id, 1253 memcpy( &dht->friends_list[i],
1253 dht->friends_list[dht->num_friends].client_id, 1254 &dht->friends_list[dht->num_friends],
1254 CLIENT_ID_SIZE ); 1255 sizeof(DHT_Friend) );
1255 } 1256 }
1256 1257
1257 if (dht->num_friends == 0) { 1258 if (dht->num_friends == 0) {
@@ -1553,7 +1554,7 @@ int route_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint32_t lengt
1553 IP_Port ip_list[MAX_FRIEND_CLIENTS]; 1554 IP_Port ip_list[MAX_FRIEND_CLIENTS];
1554 int ip_num = friend_iplist(dht, ip_list, num); 1555 int ip_num = friend_iplist(dht, ip_list, num);
1555 1556
1556 if (ip_num < (MAX_FRIEND_CLIENTS / 2)) 1557 if (ip_num < (MAX_FRIEND_CLIENTS / 4))
1557 return 0; /* Reason for that? */ 1558 return 0; /* Reason for that? */
1558 1559
1559 DHT_Friend *friend = &dht->friends_list[num]; 1560 DHT_Friend *friend = &dht->friends_list[num];
@@ -2394,7 +2395,6 @@ static int dht_load_state_callback(void *outer, uint8_t *data, uint32_t length,
2394 num = length / sizeof(DHT_Friend); 2395 num = length / sizeof(DHT_Friend);
2395 2396
2396 for (i = 0; i < num; ++i) { 2397 for (i = 0; i < num; ++i) {
2397 DHT_addfriend(dht, friend_list[i].client_id);
2398 2398
2399 for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) { 2399 for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) {
2400 Client_data *client = &friend_list[i].client_list[j]; 2400 Client_data *client = &friend_list[i].client_list[j];