summaryrefslogtreecommitdiff
path: root/core/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/DHT.h')
-rw-r--r--core/DHT.h54
1 files changed, 21 insertions, 33 deletions
diff --git a/core/DHT.h b/core/DHT.h
index fdb89de6..966645f5 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -1,27 +1,25 @@
1/* DHT.h 1/* DHT.h
2* 2 *
3* An implementation of the DHT as seen in docs/DHT.txt 3 * An implementation of the DHT as seen in docs/DHT.txt
4* 4 *
5 5 * Copyright (C) 2013 Tox project All Rights Reserved.
6 Copyright (C) 2013 Tox project All Rights Reserved. 6 *
7 7 * This file is part of Tox.
8 This file is part of Tox. 8 *
9 9 * Tox is free software: you can redistribute it and/or modify
10 Tox is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by
11 it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or
12 the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version.
13 (at your option) any later version. 13 *
14 14 * Tox is distributed in the hope that it will be useful,
15 Tox is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details.
18 GNU General Public License for more details. 18 *
19 19 * You should have received a copy of the GNU General Public License
20 You should have received a copy of the GNU General Public License 20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 along with Tox. If not, see <http://www.gnu.org/licenses/>. 21 *
22 22 */
23*/
24
25 23
26#ifndef DHT_H 24#ifndef DHT_H
27#define DHT_H 25#define DHT_H
@@ -38,8 +36,6 @@ extern "C" {
38/* size of the client_id in bytes */ 36/* size of the client_id in bytes */
39#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES 37#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES
40 38
41
42
43/* Add a new friend to the friends list 39/* Add a new friend to the friends list
44 client_id must be CLIENT_ID_SIZE bytes long. 40 client_id must be CLIENT_ID_SIZE bytes long.
45 returns 0 if success 41 returns 0 if success
@@ -52,7 +48,6 @@ int DHT_addfriend(uint8_t * client_id);
52 returns 1 if failure (client_id not in friends list) */ 48 returns 1 if failure (client_id not in friends list) */
53int DHT_delfriend(uint8_t * client_id); 49int DHT_delfriend(uint8_t * client_id);
54 50
55
56/* Get ip of friend 51/* Get ip of friend
57 client_id must be CLIENT_ID_SIZE bytes long. 52 client_id must be CLIENT_ID_SIZE bytes long.
58 ip must be 4 bytes long. 53 ip must be 4 bytes long.
@@ -62,7 +57,6 @@ int DHT_delfriend(uint8_t * client_id);
62 returns ip of 1 if friend is not in list. */ 57 returns ip of 1 if friend is not in list. */
63IP_Port DHT_getfriendip(uint8_t * client_id); 58IP_Port DHT_getfriendip(uint8_t * client_id);
64 59
65
66/* Run this function at least a couple times per second (It's the main loop) */ 60/* Run this function at least a couple times per second (It's the main loop) */
67void doDHT(); 61void doDHT();
68 62
@@ -75,8 +69,6 @@ int DHT_handlepacket(uint8_t * packet, uint32_t length, IP_Port source);
75 Sends a get nodes request to the given node with ip port and public_key */ 69 Sends a get nodes request to the given node with ip port and public_key */
76void DHT_bootstrap(IP_Port ip_port, uint8_t * public_key); 70void DHT_bootstrap(IP_Port ip_port, uint8_t * public_key);
77 71
78
79
80/* ROUTING FUNCTIONS */ 72/* ROUTING FUNCTIONS */
81 73
82/* send the given packet to node with client_id 74/* send the given packet to node with client_id
@@ -87,8 +79,6 @@ int route_packet(uint8_t * client_id, uint8_t * packet, uint32_t length);
87 returns the number of nodes it sent the packet to */ 79 returns the number of nodes it sent the packet to */
88int route_tofriend(uint8_t * friend_id, uint8_t * packet, uint32_t length); 80int route_tofriend(uint8_t * friend_id, uint8_t * packet, uint32_t length);
89 81
90
91
92/* NAT PUNCHING FUNCTIONS */ 82/* NAT PUNCHING FUNCTIONS */
93 83
94/* Puts all the different ips returned by the nodes for a friend_id into array ip_portlist 84/* Puts all the different ips returned by the nodes for a friend_id into array ip_portlist
@@ -97,8 +87,6 @@ int route_tofriend(uint8_t * friend_id, uint8_t * packet, uint32_t length);
97 returns -1 if no such friend*/ 87 returns -1 if no such friend*/
98int friend_ips(IP_Port * ip_portlist, uint8_t * friend_id); 88int friend_ips(IP_Port * ip_portlist, uint8_t * friend_id);
99 89
100
101
102/* SAVE/LOAD functions */ 90/* SAVE/LOAD functions */
103 91
104/* get the size of the DHT (for saving) */ 92/* get the size of the DHT (for saving) */