summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-08-29 19:06:09 -0400
committerirungentoo <irungentoo@gmail.com>2013-08-29 19:06:09 -0400
commitdf4b1c6ee5b4981369bb8163aa94e0261e0c036e (patch)
treeacba7259fbf64ba91e12bea4c3f095a0ae338d51 /toxcore/DHT.c
parentea994606fe4ee57f2d6ac1ddfb2225f8a1aacef0 (diff)
Removed packet structs.
They were causing problems on certain compiler configurations.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 0e0ead52..937e6196 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -24,7 +24,6 @@
24/*----------------------------------------------------------------------------------*/ 24/*----------------------------------------------------------------------------------*/
25 25
26#include "DHT.h" 26#include "DHT.h"
27#include "packets.h"
28#include "ping.h" 27#include "ping.h"
29 28
30/* The number of seconds for a non responsive node to become bad. */ 29/* The number of seconds for a non responsive node to become bad. */
@@ -563,7 +562,7 @@ static int handle_getnodes(void *object, IP_Port source, uint8_t *packet, uint32
563 memcpy(&ping_id, plain, sizeof(ping_id)); 562 memcpy(&ping_id, plain, sizeof(ping_id));
564 sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); 563 sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id);
565 564
566 // send_ping_request(dht, source, (clientid_t*) (packet + 1)); /* TODO: make this smarter? */ 565 //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */
567 566
568 return 0; 567 return 0;
569} 568}
@@ -606,7 +605,7 @@ static int handle_sendnodes(void *object, IP_Port source, uint8_t *packet, uint3
606 uint32_t i; 605 uint32_t i;
607 606
608 for (i = 0; i < num_nodes; ++i) { 607 for (i = 0; i < num_nodes; ++i) {
609 send_ping_request(dht->ping, dht->c, nodes_list[i].ip_port, (clientid_t *) &nodes_list[i].client_id); 608 send_ping_request(dht->ping, dht->c, nodes_list[i].ip_port, nodes_list[i].client_id);
610 returnedip_ports(dht, nodes_list[i].ip_port, nodes_list[i].client_id, packet + 1); 609 returnedip_ports(dht, nodes_list[i].ip_port, nodes_list[i].client_id, packet + 1);
611 } 610 }
612 611
@@ -713,7 +712,7 @@ static void do_DHT_friends(DHT *dht)
713 if (!is_timeout(temp_time, dht->friends_list[i].client_list[j].timestamp, Kill_NODE_TIMEOUT)) { 712 if (!is_timeout(temp_time, dht->friends_list[i].client_list[j].timestamp, Kill_NODE_TIMEOUT)) {
714 if ((dht->friends_list[i].client_list[j].last_pinged + PING_INTERVAL) <= temp_time) { 713 if ((dht->friends_list[i].client_list[j].last_pinged + PING_INTERVAL) <= temp_time) {
715 send_ping_request(dht->ping, dht->c, dht->friends_list[i].client_list[j].ip_port, 714 send_ping_request(dht->ping, dht->c, dht->friends_list[i].client_list[j].ip_port,
716 (clientid_t *) &dht->friends_list[i].client_list[j].client_id ); 715 dht->friends_list[i].client_list[j].client_id );
717 dht->friends_list[i].client_list[j].last_pinged = temp_time; 716 dht->friends_list[i].client_list[j].last_pinged = temp_time;
718 } 717 }
719 718
@@ -751,7 +750,7 @@ static void do_Close(DHT *dht)
751 if (!is_timeout(temp_time, dht->close_clientlist[i].timestamp, Kill_NODE_TIMEOUT)) { 750 if (!is_timeout(temp_time, dht->close_clientlist[i].timestamp, Kill_NODE_TIMEOUT)) {
752 if ((dht->close_clientlist[i].last_pinged + PING_INTERVAL) <= temp_time) { 751 if ((dht->close_clientlist[i].last_pinged + PING_INTERVAL) <= temp_time) {
753 send_ping_request(dht->ping, dht->c, dht->close_clientlist[i].ip_port, 752 send_ping_request(dht->ping, dht->c, dht->close_clientlist[i].ip_port,
754 (clientid_t *) &dht->close_clientlist[i].client_id ); 753 dht->close_clientlist[i].client_id );
755 dht->close_clientlist[i].last_pinged = temp_time; 754 dht->close_clientlist[i].last_pinged = temp_time;
756 } 755 }
757 756
@@ -775,7 +774,7 @@ static void do_Close(DHT *dht)
775void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key) 774void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key)
776{ 775{
777 getnodes(dht, ip_port, public_key, dht->c->self_public_key); 776 getnodes(dht, ip_port, public_key, dht->c->self_public_key);
778 send_ping_request(dht->ping, dht->c, ip_port, (clientid_t *) public_key); 777 send_ping_request(dht->ping, dht->c, ip_port, public_key);
779} 778}
780 779
781/* Send the given packet to node with client_id 780/* Send the given packet to node with client_id
@@ -1042,7 +1041,7 @@ static void punch_holes(DHT *dht, IP ip, uint16_t *port_list, uint16_t numports,
1042 /* TODO: improve port guessing algorithm */ 1041 /* TODO: improve port guessing algorithm */
1043 uint16_t port = port_list[(i / 2) % numports] + (i / (2 * numports)) * ((i % 2) ? -1 : 1); 1042 uint16_t port = port_list[(i / 2) % numports] + (i / (2 * numports)) * ((i % 2) ? -1 : 1);
1044 IP_Port pinging = {ip, htons(port)}; 1043 IP_Port pinging = {ip, htons(port)};
1045 send_ping_request(dht->ping, dht->c, pinging, (clientid_t *) &dht->friends_list[friend_num].client_id); 1044 send_ping_request(dht->ping, dht->c, pinging, dht->friends_list[friend_num].client_id);
1046 } 1045 }
1047 1046
1048 dht->friends_list[friend_num].punching_index = i; 1047 dht->friends_list[friend_num].punching_index = i;
@@ -1143,7 +1142,7 @@ static void do_toping(DHT *dht)
1143 if (dht->toping[i].ip_port.ip.i == 0) 1142 if (dht->toping[i].ip_port.ip.i == 0)
1144 return; 1143 return;
1145 1144
1146 send_ping_request(dht->ping, dht->c, dht->toping[i].ip_port, (clientid_t *) dht->toping[i].client_id); 1145 send_ping_request(dht->ping, dht->c, dht->toping[i].ip_port, dht->toping[i].client_id);
1147 dht->toping[i].ip_port.ip.i = 0; 1146 dht->toping[i].ip_port.ip.i = 0;
1148 } 1147 }
1149} 1148}