From 0ce46b644ed1033955c0b783a190f6bfdd9d762f Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 20 Dec 2023 15:11:23 +0000 Subject: [PATCH] refactor: Change the `TCP_PACKET_*` defines into an enum. --- toxcore/TCP_common.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/toxcore/TCP_common.h b/toxcore/TCP_common.h index 60e4f16c..778962f8 100644 --- a/toxcore/TCP_common.h +++ b/toxcore/TCP_common.h @@ -24,18 +24,20 @@ void wipe_priority_list(const Memory *mem, TCP_Priority_List *p); #define NUM_RESERVED_PORTS 16 #define NUM_CLIENT_CONNECTIONS (256 - NUM_RESERVED_PORTS) -#define TCP_PACKET_ROUTING_REQUEST 0 -#define TCP_PACKET_ROUTING_RESPONSE 1 -#define TCP_PACKET_CONNECTION_NOTIFICATION 2 -#define TCP_PACKET_DISCONNECT_NOTIFICATION 3 -#define TCP_PACKET_PING 4 -#define TCP_PACKET_PONG 5 -#define TCP_PACKET_OOB_SEND 6 -#define TCP_PACKET_OOB_RECV 7 -#define TCP_PACKET_ONION_REQUEST 8 -#define TCP_PACKET_ONION_RESPONSE 9 -#define TCP_PACKET_FORWARD_REQUEST 10 -#define TCP_PACKET_FORWARDING 11 +typedef enum Tcp_Packet { + TCP_PACKET_ROUTING_REQUEST = 0, + TCP_PACKET_ROUTING_RESPONSE = 1, + TCP_PACKET_CONNECTION_NOTIFICATION = 2, + TCP_PACKET_DISCONNECT_NOTIFICATION = 3, + TCP_PACKET_PING = 4, + TCP_PACKET_PONG = 5, + TCP_PACKET_OOB_SEND = 6, + TCP_PACKET_OOB_RECV = 7, + TCP_PACKET_ONION_REQUEST = 8, + TCP_PACKET_ONION_RESPONSE = 9, + TCP_PACKET_FORWARD_REQUEST = 10, + TCP_PACKET_FORWARDING = 11, +} Tcp_Packet; #define TCP_HANDSHAKE_PLAIN_SIZE (CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE) #define TCP_SERVER_HANDSHAKE_SIZE (CRYPTO_NONCE_SIZE + TCP_HANDSHAKE_PLAIN_SIZE + CRYPTO_MAC_SIZE)