summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-13 16:50:32 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-13 23:55:08 +0000
commite775b5533b7137b18edcd6e414fd461d07018425 (patch)
treecab52d97c0e02d5d2f17b8db1da3ab3e800fb3ce /toxcore/onion_client.c
parent1e1efec34ad820fc65dcf98581a0d8f6fa1873a8 (diff)
Make Ping_Array a module-private type.
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r--toxcore/onion_client.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index 0d1191a6..1490d78d 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -397,7 +397,7 @@ static int new_sendback(Onion_Client *onion_c, uint32_t num, const uint8_t *publ
397 memcpy(data + sizeof(uint32_t), public_key, CRYPTO_PUBLIC_KEY_SIZE); 397 memcpy(data + sizeof(uint32_t), public_key, CRYPTO_PUBLIC_KEY_SIZE);
398 memcpy(data + sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE, &ip_port, sizeof(IP_Port)); 398 memcpy(data + sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE, &ip_port, sizeof(IP_Port));
399 memcpy(data + sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE + sizeof(IP_Port), &path_num, sizeof(uint32_t)); 399 memcpy(data + sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE + sizeof(IP_Port), &path_num, sizeof(uint32_t));
400 *sendback = ping_array_add(&onion_c->announce_ping_array, data, sizeof(data)); 400 *sendback = ping_array_add(onion_c->announce_ping_array, data, sizeof(data));
401 401
402 if (*sendback == 0) { 402 if (*sendback == 0) {
403 return -1; 403 return -1;
@@ -423,7 +423,7 @@ static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, u
423 memcpy(&sback, sendback, sizeof(uint64_t)); 423 memcpy(&sback, sendback, sizeof(uint64_t));
424 uint8_t data[sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE + sizeof(IP_Port) + sizeof(uint32_t)]; 424 uint8_t data[sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE + sizeof(IP_Port) + sizeof(uint32_t)];
425 425
426 if (ping_array_check(data, sizeof(data), &onion_c->announce_ping_array, sback) != sizeof(data)) { 426 if (ping_array_check(onion_c->announce_ping_array, data, sizeof(data), sback) != sizeof(data)) {
427 return ~0; 427 return ~0;
428 } 428 }
429 429
@@ -1733,7 +1733,9 @@ Onion_Client *new_onion_client(Net_Crypto *c)
1733 return NULL; 1733 return NULL;
1734 } 1734 }
1735 1735
1736 if (ping_array_init(&onion_c->announce_ping_array, ANNOUNCE_ARRAY_SIZE, ANNOUNCE_TIMEOUT) != 0) { 1736 onion_c->announce_ping_array = ping_array_new(ANNOUNCE_ARRAY_SIZE, ANNOUNCE_TIMEOUT);
1737
1738 if (onion_c->announce_ping_array == NULL) {
1737 free(onion_c); 1739 free(onion_c);
1738 return NULL; 1740 return NULL;
1739 } 1741 }
@@ -1758,7 +1760,7 @@ void kill_onion_client(Onion_Client *onion_c)
1758 return; 1760 return;
1759 } 1761 }
1760 1762
1761 ping_array_free_all(&onion_c->announce_ping_array); 1763 ping_array_kill(onion_c->announce_ping_array);
1762 realloc_onion_friends(onion_c, 0); 1764 realloc_onion_friends(onion_c, 0);
1763 networking_registerhandler(onion_c->net, NET_PACKET_ANNOUNCE_RESPONSE, NULL, NULL); 1765 networking_registerhandler(onion_c->net, NET_PACKET_ANNOUNCE_RESPONSE, NULL, NULL);
1764 networking_registerhandler(onion_c->net, NET_PACKET_ONION_DATA_RESPONSE, NULL, NULL); 1766 networking_registerhandler(onion_c->net, NET_PACKET_ONION_DATA_RESPONSE, NULL, NULL);