diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index e6be5481..f977e741 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -31,10 +31,11 @@ | |||
31 | #define CRYPTO_CONN_NO_CONNECTION 0 | 31 | #define CRYPTO_CONN_NO_CONNECTION 0 |
32 | #define CRYPTO_CONN_COOKIE_REQUESTING 1 //send cookie request packets | 32 | #define CRYPTO_CONN_COOKIE_REQUESTING 1 //send cookie request packets |
33 | #define CRYPTO_CONN_HANDSHAKE_SENT 2 //send handshake packets | 33 | #define CRYPTO_CONN_HANDSHAKE_SENT 2 //send handshake packets |
34 | #define CRYPTO_CONN_NOT_CONFIRMED 3 //send handshake packets | 34 | #define CRYPTO_CONN_NOT_CONFIRMED 3 //send handshake packets, we have received one from the other |
35 | #define CRYPTO_CONN_ESTABLISHED 4 | 35 | #define CRYPTO_CONN_ESTABLISHED 4 |
36 | #define CRYPTO_CONN_TIMED_OUT 5 | 36 | #define CRYPTO_CONN_TIMED_OUT 5 |
37 | 37 | ||
38 | /* Maximum size of receiving and sending packet buffers. */ | ||
38 | #define CRYPTO_PACKET_BUFFER_SIZE 16384 /* Must be a power of 2 */ | 39 | #define CRYPTO_PACKET_BUFFER_SIZE 16384 /* Must be a power of 2 */ |
39 | 40 | ||
40 | /* Minimum packet rate per second. */ | 41 | /* Minimum packet rate per second. */ |
@@ -43,15 +44,17 @@ | |||
43 | /* Minimum packet queue max length. */ | 44 | /* Minimum packet queue max length. */ |
44 | #define CRYPTO_MIN_QUEUE_LENGTH 64 | 45 | #define CRYPTO_MIN_QUEUE_LENGTH 64 |
45 | 46 | ||
47 | /* Maximum total size of packets that net_crypto sends. */ | ||
46 | #define MAX_CRYPTO_PACKET_SIZE 1400 | 48 | #define MAX_CRYPTO_PACKET_SIZE 1400 |
47 | 49 | ||
48 | #define CRYPTO_DATA_PACKET_MIN_SIZE (1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + crypto_box_MACBYTES) | 50 | #define CRYPTO_DATA_PACKET_MIN_SIZE (1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + crypto_box_MACBYTES) |
49 | 51 | ||
50 | /* Max size of data in packets TODO*/ | 52 | /* Max size of data in packets */ |
51 | #define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE) | 53 | #define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE) |
52 | 54 | ||
53 | /* Interval in ms between sending cookie request/handshake packets. */ | 55 | /* Interval in ms between sending cookie request/handshake packets. */ |
54 | #define CRYPTO_SEND_PACKET_INTERVAL 500 | 56 | #define CRYPTO_SEND_PACKET_INTERVAL 500 |
57 | |||
55 | /* The maximum number of times we try to send the cookie request and handshake | 58 | /* The maximum number of times we try to send the cookie request and handshake |
56 | before giving up. */ | 59 | before giving up. */ |
57 | #define MAX_NUM_SENDPACKET_TRIES 8 | 60 | #define MAX_NUM_SENDPACKET_TRIES 8 |
@@ -59,10 +62,11 @@ | |||
59 | /* The timeout of no received UDP packets before the direct UDP connection is considered dead. */ | 62 | /* The timeout of no received UDP packets before the direct UDP connection is considered dead. */ |
60 | #define UDP_DIRECT_TIMEOUT (MAX_NUM_SENDPACKET_TRIES * CRYPTO_SEND_PACKET_INTERVAL * 2) | 63 | #define UDP_DIRECT_TIMEOUT (MAX_NUM_SENDPACKET_TRIES * CRYPTO_SEND_PACKET_INTERVAL * 2) |
61 | 64 | ||
62 | #define PACKET_ID_PADDING 0 | 65 | #define PACKET_ID_PADDING 0 /* Denotes padding */ |
63 | #define PACKET_ID_REQUEST 1 | 66 | #define PACKET_ID_REQUEST 1 /* Used to request unreceived packets */ |
64 | #define PACKET_ID_KILL 2 | 67 | #define PACKET_ID_KILL 2 /* Used to kill connection */ |
65 | 68 | ||
69 | /* Packet ids 0 to CRYPTO_RESERVED_PACKETS - 1 are reserved for use by net_crypto. */ | ||
66 | #define CRYPTO_RESERVED_PACKETS 16 | 70 | #define CRYPTO_RESERVED_PACKETS 16 |
67 | 71 | ||
68 | #define MAX_TCP_CONNECTIONS 32 | 72 | #define MAX_TCP_CONNECTIONS 32 |
@@ -79,7 +83,8 @@ | |||
79 | 83 | ||
80 | #define CRYPTO_MAX_PADDING 8 /* All packets will be padded a number of bytes based on this number. */ | 84 | #define CRYPTO_MAX_PADDING 8 /* All packets will be padded a number of bytes based on this number. */ |
81 | 85 | ||
82 | 86 | /* Base current transfer speed on last CONGESTION_QUEUE_ARRAY_SIZE number of points taken | |
87 | at the dT defined in net_crypto.c */ | ||
83 | #define CONGESTION_QUEUE_ARRAY_SIZE 8 | 88 | #define CONGESTION_QUEUE_ARRAY_SIZE 8 |
84 | 89 | ||
85 | typedef struct { | 90 | typedef struct { |