summaryrefslogtreecommitdiff
path: root/toxcore/ping.h
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-09-21 15:39:15 +0200
committerCoren[m] <Break@Ocean>2013-09-21 15:39:15 +0200
commit88678e584aaf3956a0c88c80fa65efc505773f7d (patch)
treec20a7a2d364280275ff8788f79723613fcd706b4 /toxcore/ping.h
parent20b6900fb181f71eca4577a5f1e1f5f3ecd6a28b (diff)
moved stuff that belongs into ping.[ch] there
DHT.*, ping.*: - moved stuff from struct DHT into struct PING: toping, last_toping - moved functions add_toping(), do_toping() - made id_closest() publicly accessible - send_ping_request(): killed (Net_Crypto *c) parameter in favor of copying it into (PING *) on new_ping() group_chats.c: - killed local 1:1 copy in favor of DHT.c::id_closest()
Diffstat (limited to 'toxcore/ping.h')
-rw-r--r--toxcore/ping.h33
1 files changed, 25 insertions, 8 deletions
diff --git a/toxcore/ping.h b/toxcore/ping.h
index 5d080e34..fabb1afd 100644
--- a/toxcore/ping.h
+++ b/toxcore/ping.h
@@ -4,14 +4,31 @@
4 * This file is donated to the Tox Project. 4 * This file is donated to the Tox Project.
5 * Copyright 2013 plutooo 5 * Copyright 2013 plutooo
6 */ 6 */
7#ifndef __PING_H__
8#define __PING_H__
7 9
8#include <stdbool.h> 10#include <stdbool.h>
9 11
10void *new_ping(void); 12#ifndef __PING_C__
11void kill_ping(void *ping); 13typedef struct PING PING;
12uint64_t add_ping(void *ping, IP_Port ipp); 14#endif
13bool is_pinging(void *ping, IP_Port ipp, uint64_t ping_id); 15
14int send_ping_request(void *ping, Net_Crypto *c, IP_Port ipp, uint8_t *client_id); 16/* Add nodes to the toping list.
15int send_ping_response(Net_Crypto *c, IP_Port ipp, uint8_t *client_id, uint64_t ping_id); 17 * All nodes in this list are pinged every TIME_TOPING seconds
16int handle_ping_request(void *object, IP_Port source, uint8_t *packet, uint32_t length); 18 * and are then removed from the list.
17int handle_ping_response(void *object, IP_Port source, uint8_t *packet, uint32_t length); 19 * If the list is full the nodes farthest from our client_id are replaced.
20 * The purpose of this list is to enable quick integration of new nodes into the
21 * network while preventing amplification attacks.
22 *
23 * return 0 if node was added.
24 * return -1 if node was not added.
25 */
26int add_toping(PING *ping, uint8_t *client_id, IP_Port ip_port);
27void do_toping(PING *ping);
28
29PING *new_ping(DHT *dht, Net_Crypto *c);
30void kill_ping(PING *ping);
31
32int send_ping_request(PING *ping, IP_Port ipp, uint8_t *client_id);
33
34#endif /* __PING_H__ */