summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-06-22 00:57:22 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-06-22 00:57:22 +0000
commit850d7eac38de09eb9deb48182d6032d164cc6e13 (patch)
tree7a587c3c6f973790c19c1fd48c1e26d716dacb68 /toxcore/net_crypto.h
parent2d2b9cfa91ee50247b0ee6a7a05ece08eb9e021d (diff)
Make the net_crypto connection state an enum.
It was a list of #defines, but clearly this is a discrete and limited set of named values, so an enum is more appropriate.
Diffstat (limited to 'toxcore/net_crypto.h')
-rw-r--r--toxcore/net_crypto.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index ec55bf6f..f6b2648e 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -31,11 +31,13 @@
31 31
32#include <pthread.h> 32#include <pthread.h>
33 33
34#define CRYPTO_CONN_NO_CONNECTION 0 34typedef enum CRYPTO_CONN_STATE {
35#define CRYPTO_CONN_COOKIE_REQUESTING 1 //send cookie request packets 35 CRYPTO_CONN_NO_CONNECTION = 0,
36#define CRYPTO_CONN_HANDSHAKE_SENT 2 //send handshake packets 36 CRYPTO_CONN_COOKIE_REQUESTING = 1, // send cookie request packets
37#define CRYPTO_CONN_NOT_CONFIRMED 3 //send handshake packets, we have received one from the other 37 CRYPTO_CONN_HANDSHAKE_SENT = 2, // send handshake packets
38#define CRYPTO_CONN_ESTABLISHED 4 38 CRYPTO_CONN_NOT_CONFIRMED = 3, // send handshake packets, we have received one from the other
39 CRYPTO_CONN_ESTABLISHED = 4,
40} CRYPTO_CONN_STATE;
39 41
40/* Maximum size of receiving and sending packet buffers. */ 42/* Maximum size of receiving and sending packet buffers. */
41#define CRYPTO_PACKET_BUFFER_SIZE 32768 /* Must be a power of 2 */ 43#define CRYPTO_PACKET_BUFFER_SIZE 32768 /* Must be a power of 2 */
@@ -47,9 +49,9 @@
47#define CRYPTO_MIN_QUEUE_LENGTH 64 49#define CRYPTO_MIN_QUEUE_LENGTH 64
48 50
49/* Maximum total size of packets that net_crypto sends. */ 51/* Maximum total size of packets that net_crypto sends. */
50#define MAX_CRYPTO_PACKET_SIZE 1400 52#define MAX_CRYPTO_PACKET_SIZE (uint16_t)1400
51 53
52#define CRYPTO_DATA_PACKET_MIN_SIZE (1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + CRYPTO_MAC_SIZE) 54#define CRYPTO_DATA_PACKET_MIN_SIZE (uint16_t)(1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + CRYPTO_MAC_SIZE)
53 55
54/* Max size of data in packets */ 56/* Max size of data in packets */
55#define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE) 57#define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE)
@@ -276,8 +278,8 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id);
276 * sets direct_connected to 1 if connection connects directly to other, 0 if it isn't. 278 * sets direct_connected to 1 if connection connects directly to other, 0 if it isn't.
277 * sets online_tcp_relays to the number of connected tcp relays this connection has. 279 * sets online_tcp_relays to the number of connected tcp relays this connection has.
278 */ 280 */
279unsigned int crypto_connection_status(const Net_Crypto *c, int crypt_connection_id, bool *direct_connected, 281CRYPTO_CONN_STATE crypto_connection_status(const Net_Crypto *c, int crypt_connection_id, bool *direct_connected,
280 unsigned int *online_tcp_relays); 282 unsigned int *online_tcp_relays);
281 283
282/* Generate our public and private keys. 284/* Generate our public and private keys.
283 * Only call this function the first time the program starts. 285 * Only call this function the first time the program starts.