diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-13 16:50:32 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-13 23:55:08 +0000 |
commit | e775b5533b7137b18edcd6e414fd461d07018425 (patch) | |
tree | cab52d97c0e02d5d2f17b8db1da3ab3e800fb3ce /toxcore/ping.c | |
parent | 1e1efec34ad820fc65dcf98581a0d8f6fa1873a8 (diff) |
Make Ping_Array a module-private type.
Diffstat (limited to 'toxcore/ping.c')
-rw-r--r-- | toxcore/ping.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/toxcore/ping.c b/toxcore/ping.c index 72b3fe62..b99c2a8c 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c | |||
@@ -48,7 +48,7 @@ | |||
48 | struct PING { | 48 | struct PING { |
49 | DHT *dht; | 49 | DHT *dht; |
50 | 50 | ||
51 | Ping_Array ping_array; | 51 | Ping_Array *ping_array; |
52 | Node_format to_ping[MAX_TO_PING]; | 52 | Node_format to_ping[MAX_TO_PING]; |
53 | uint64_t last_to_ping; | 53 | uint64_t last_to_ping; |
54 | }; | 54 | }; |
@@ -76,7 +76,7 @@ int send_ping_request(PING *ping, IP_Port ipp, const uint8_t *public_key) | |||
76 | uint8_t data[PING_DATA_SIZE]; | 76 | uint8_t data[PING_DATA_SIZE]; |
77 | id_copy(data, public_key); | 77 | id_copy(data, public_key); |
78 | memcpy(data + CRYPTO_PUBLIC_KEY_SIZE, &ipp, sizeof(IP_Port)); | 78 | memcpy(data + CRYPTO_PUBLIC_KEY_SIZE, &ipp, sizeof(IP_Port)); |
79 | ping_id = ping_array_add(&ping->ping_array, data, sizeof(data)); | 79 | ping_id = ping_array_add(ping->ping_array, data, sizeof(data)); |
80 | 80 | ||
81 | if (ping_id == 0) { | 81 | if (ping_id == 0) { |
82 | return 1; | 82 | return 1; |
@@ -217,7 +217,7 @@ static int handle_ping_response(void *object, IP_Port source, const uint8_t *pac | |||
217 | memcpy(&ping_id, ping_plain + 1, sizeof(ping_id)); | 217 | memcpy(&ping_id, ping_plain + 1, sizeof(ping_id)); |
218 | uint8_t data[PING_DATA_SIZE]; | 218 | uint8_t data[PING_DATA_SIZE]; |
219 | 219 | ||
220 | if (ping_array_check(data, sizeof(data), &ping->ping_array, ping_id) != sizeof(data)) { | 220 | if (ping_array_check(ping->ping_array, data, sizeof(data), ping_id) != sizeof(data)) { |
221 | return 1; | 221 | return 1; |
222 | } | 222 | } |
223 | 223 | ||
@@ -359,7 +359,9 @@ PING *new_ping(DHT *dht) | |||
359 | return NULL; | 359 | return NULL; |
360 | } | 360 | } |
361 | 361 | ||
362 | if (ping_array_init(&ping->ping_array, PING_NUM_MAX, PING_TIMEOUT) != 0) { | 362 | ping->ping_array = ping_array_new(PING_NUM_MAX, PING_TIMEOUT); |
363 | |||
364 | if (ping->ping_array == NULL) { | ||
363 | free(ping); | 365 | free(ping); |
364 | return NULL; | 366 | return NULL; |
365 | } | 367 | } |
@@ -375,7 +377,7 @@ void kill_ping(PING *ping) | |||
375 | { | 377 | { |
376 | networking_registerhandler(ping->dht->net, NET_PACKET_PING_REQUEST, NULL, NULL); | 378 | networking_registerhandler(ping->dht->net, NET_PACKET_PING_REQUEST, NULL, NULL); |
377 | networking_registerhandler(ping->dht->net, NET_PACKET_PING_RESPONSE, NULL, NULL); | 379 | networking_registerhandler(ping->dht->net, NET_PACKET_PING_RESPONSE, NULL, NULL); |
378 | ping_array_free_all(&ping->ping_array); | 380 | ping_array_kill(ping->ping_array); |
379 | 381 | ||
380 | free(ping); | 382 | free(ping); |
381 | } | 383 | } |