summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-09-11 20:50:15 +0200
committerCoren[m] <Break@Ocean>2013-09-11 20:50:15 +0200
commit513e37815db8319dd015bf03b588380a4e3c61d3 (patch)
tree809738c8ff2370936638565ff096d387d7222f85 /toxcore/DHT.c
parentd0f5ad34ae2cb88e921cf6f6d829d611b5ea2152 (diff)
tox.h, DHT.h:
- tox_bootstrap_ex(), DHT_bootstrap_ex() renamed to tox_bootstrap_from_address(), DHT_bootstrap_from_address() - (handle_)sendnodes_ex() renamed to (handle_)sendnodes_ipv6() - only sending sendnodes_ipv6() if we're actually IPv6 enabled - changed comments to conform better nTox.c, Messenger_text.c, DHT_test.c, DHT_bootstrap.c: - fallout from *_ex() to *_from_address() DHT_bootstrap.c: - corrected a potentially wrong info message util.c: - fixed logfile name: now (funcptr) => now() (number) network.c: - addead comment about the necessity of bind() to succeed auto_test/messenger_test.c: - defaulting ipv6enabled to TOX_ENABLE_IPV6_DEFAULT LAN_discovery.c: - slight cleanup and comments for clarity
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 44f7f101..96bfd663 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -617,7 +617,7 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl
617 617
618#ifdef TOX_ENABLE_IPV6 618#ifdef TOX_ENABLE_IPV6
619/* Send a send nodes response: message for IPv6 nodes */ 619/* Send a send nodes response: message for IPv6 nodes */
620static int sendnodes_ex(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *client_id, uint64_t ping_id) 620static int sendnodes_ipv6(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *client_id, uint64_t ping_id)
621{ 621{
622 /* Check if packet is going to be sent to ourself. */ 622 /* Check if packet is going to be sent to ourself. */
623 if (id_equal(public_key, dht->c->self_public_key)) 623 if (id_equal(public_key, dht->c->self_public_key))
@@ -691,7 +691,9 @@ static int handle_getnodes(void *object, IP_Port source, uint8_t *packet, uint32
691 memcpy(&ping_id, plain, sizeof(ping_id)); 691 memcpy(&ping_id, plain, sizeof(ping_id));
692 sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); 692 sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id);
693#ifdef TOX_ENABLE_IPV6 693#ifdef TOX_ENABLE_IPV6
694 sendnodes_ex(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); 694 /* only try to send IPv6 nodes if the ipv6enabled flag was given */
695 if (dht->c->lossless_udp->net->family == AF_INET6)
696 sendnodes_ipv6(dht, source, packet + 1, plain + sizeof(ping_id), ping_id);
695#endif 697#endif
696 698
697 //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */ 699 //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */
@@ -766,7 +768,7 @@ static int handle_sendnodes(void *object, IP_Port source, uint8_t *packet, uint3
766} 768}
767 769
768#ifdef TOX_ENABLE_IPV6 770#ifdef TOX_ENABLE_IPV6
769static int handle_sendnodes_ex(void *object, IP_Port source, uint8_t *packet, uint32_t length) 771static int handle_sendnodes_ipv6(void *object, IP_Port source, uint8_t *packet, uint32_t length)
770{ 772{
771 DHT *dht = object; 773 DHT *dht = object;
772 uint64_t ping_id; 774 uint64_t ping_id;
@@ -979,7 +981,8 @@ void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key)
979 getnodes(dht, ip_port, public_key, dht->c->self_public_key); 981 getnodes(dht, ip_port, public_key, dht->c->self_public_key);
980 send_ping_request(dht->ping, dht->c, ip_port, public_key); 982 send_ping_request(dht->ping, dht->c, ip_port, public_key);
981} 983}
982int DHT_bootstrap_ex(DHT *dht, const char *address, uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) 984int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enabled,
985 uint16_t port, uint8_t *public_key)
983{ 986{
984 IP_Port ip_port; 987 IP_Port ip_port;
985 ip_init(&ip_port.ip, ipv6enabled); 988 ip_init(&ip_port.ip, ipv6enabled);
@@ -1400,7 +1403,7 @@ DHT *new_DHT(Net_Crypto *c)
1400 networking_registerhandler(c->lossless_udp->net, NET_PACKET_GET_NODES, &handle_getnodes, temp); 1403 networking_registerhandler(c->lossless_udp->net, NET_PACKET_GET_NODES, &handle_getnodes, temp);
1401 networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES, &handle_sendnodes, temp); 1404 networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES, &handle_sendnodes, temp);
1402#ifdef TOX_ENABLE_IPV6 1405#ifdef TOX_ENABLE_IPV6
1403 networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_EX, &handle_sendnodes_ex, temp); 1406 networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_EX, &handle_sendnodes_ipv6, temp);
1404#endif 1407#endif
1405 init_cryptopackets(temp); 1408 init_cryptopackets(temp);
1406 cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, temp); 1409 cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, temp);