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.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index 9eb5e2d3..56f43cc4 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -82,8 +82,11 @@
82 at the dT defined in net_crypto.c */ 82 at the dT defined in net_crypto.c */
83#define CONGESTION_QUEUE_ARRAY_SIZE 24 83#define CONGESTION_QUEUE_ARRAY_SIZE 24
84 84
85/* Connection ping in ms. TODO: calculate it per connection. */
86#define DEFAULT_PING_CONNECTION 50
87
85typedef struct { 88typedef struct {
86 _Bool sent; 89 uint64_t sent_time;
87 uint16_t length; 90 uint16_t length;
88 uint8_t data[MAX_CRYPTO_DATA_SIZE]; 91 uint8_t data[MAX_CRYPTO_DATA_SIZE];
89} Packet_Data; 92} Packet_Data;
@@ -146,6 +149,7 @@ typedef struct {
146 uint32_t last_sendqueue_size[CONGESTION_QUEUE_ARRAY_SIZE], last_sendqueue_counter; 149 uint32_t last_sendqueue_size[CONGESTION_QUEUE_ARRAY_SIZE], last_sendqueue_counter;
147 long signed int last_num_packets_sent[CONGESTION_QUEUE_ARRAY_SIZE]; 150 long signed int last_num_packets_sent[CONGESTION_QUEUE_ARRAY_SIZE];
148 uint32_t packets_sent; 151 uint32_t packets_sent;
152 uint64_t last_congestion_event;
149 153
150 /* TCP_connection connection_number */ 154 /* TCP_connection connection_number */
151 unsigned int connection_number_tcp; 155 unsigned int connection_number_tcp;
@@ -224,10 +228,12 @@ int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key, const u
224 228
225/* Set the direct ip of the crypto connection. 229/* Set the direct ip of the crypto connection.
226 * 230 *
231 * Connected is 0 if we are not sure we are connected to that person, 1 if we are sure.
232 *
227 * return -1 on failure. 233 * return -1 on failure.
228 * return 0 on success. 234 * return 0 on success.
229 */ 235 */
230int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port); 236int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, _Bool connected);
231 237
232/* Set function to be called when connection with crypt_connection_id goes connects/disconnects. 238/* Set function to be called when connection with crypt_connection_id goes connects/disconnects.
233 * 239 *
@@ -378,10 +384,10 @@ void new_keys(Net_Crypto *c);
378 */ 384 */
379void save_keys(const Net_Crypto *c, uint8_t *keys); 385void save_keys(const Net_Crypto *c, uint8_t *keys);
380 386
381/* Load the public and private keys from the keys array. 387/* Load the secret key.
382 * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES. 388 * Length must be crypto_box_SECRETKEYBYTES.
383 */ 389 */
384void load_keys(Net_Crypto *c, const uint8_t *keys); 390void load_secret_key(Net_Crypto *c, const uint8_t *sk);
385 391
386/* Create new instance of Net_Crypto. 392/* Create new instance of Net_Crypto.
387 * Sets all the global connection variables to their default values. 393 * Sets all the global connection variables to their default values.