summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/net_crypto.h')
-rw-r--r--toxcore/net_crypto.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index e41e7e1d..14b14229 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -61,7 +61,13 @@
61 61
62#define CRYPTO_RESERVED_PACKETS 16 62#define CRYPTO_RESERVED_PACKETS 16
63 63
64#define MAX_TCP_CONNECTIONS 8 64#define MAX_TCP_CONNECTIONS 32
65#define MAX_TCP_RELAYS_PEER 4
66
67#define STATUS_TCP_NULL 0
68#define STATUS_TCP_OFFLINE 1
69#define STATUS_TCP_INVISIBLE 2 /* we know the other peer is connected to this relay but he isn't appearing online */
70#define STATUS_TCP_ONLINE 3
65 71
66typedef struct { 72typedef struct {
67 uint64_t time; 73 uint64_t time;
@@ -127,8 +133,11 @@ typedef struct {
127 133
128 uint8_t killed; /* set to 1 to kill the connection. */ 134 uint8_t killed; /* set to 1 to kill the connection. */
129 135
130 uint8_t status_tcp[MAX_TCP_CONNECTIONS]; 136 uint8_t status_tcp[MAX_TCP_CONNECTIONS]; /* set to one of STATUS_TCP_* */
131 uint8_t con_number_tcp[MAX_TCP_CONNECTIONS]; 137 uint8_t con_number_tcp[MAX_TCP_CONNECTIONS];
138
139 Node_format tcp_relays[MAX_TCP_RELAYS_PEER];
140 uint16_t num_tcp_relays;
132} Crypto_Connection; 141} Crypto_Connection;
133 142
134typedef struct { 143typedef struct {
@@ -244,6 +253,13 @@ uint32_t crypto_num_free_sendqueue_slots(Net_Crypto *c, int crypt_connection_id)
244 */ 253 */
245int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length); 254int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length);
246 255
256/* Add a tcp relay, associating it to a crypt_connection_id.
257 *
258 * return 0 if it was added.
259 * return -1 if it wasn't.
260 */
261int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, uint8_t *public_key);
262
247/* Add a tcp relay to the array. 263/* Add a tcp relay to the array.
248 * 264 *
249 * return 0 if it was added. 265 * return 0 if it was added.