From ee3121c3f6025562972c167d4db2e8ed38860479 Mon Sep 17 00:00:00 2001 From: "Gregory Mullen (grayhatter)" Date: Wed, 26 Oct 2016 00:21:07 -0700 Subject: [PATCH] Convert series of NET_PACKET_* defines into a typedef enum fixup! TravisCI shorten IRC message --- toxcore/network.h | 52 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/toxcore/network.h b/toxcore/network.h index dd654b8d2d..3f4d77daf5 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -102,33 +102,31 @@ typedef int sock_t; #define MAX_UDP_PACKET_SIZE 2048 -#define NET_PACKET_PING_REQUEST 0 /* Ping request packet ID. */ -#define NET_PACKET_PING_RESPONSE 1 /* Ping response packet ID. */ -#define NET_PACKET_GET_NODES 2 /* Get nodes request packet ID. */ -#define NET_PACKET_SEND_NODES_IPV6 4 /* Send nodes response packet ID for other addresses. */ -#define NET_PACKET_COOKIE_REQUEST 24 /* Cookie request packet */ -#define NET_PACKET_COOKIE_RESPONSE 25 /* Cookie response packet */ -#define NET_PACKET_CRYPTO_HS 26 /* Crypto handshake packet */ -#define NET_PACKET_CRYPTO_DATA 27 /* Crypto data packet */ -#define NET_PACKET_CRYPTO 32 /* Encrypted data packet ID. */ -#define NET_PACKET_LAN_DISCOVERY 33 /* LAN discovery packet ID. */ - -/* See: docs/Prevent_Tracking.txt and onion.{c, h} */ -#define NET_PACKET_ONION_SEND_INITIAL 128 -#define NET_PACKET_ONION_SEND_1 129 -#define NET_PACKET_ONION_SEND_2 130 - -#define NET_PACKET_ANNOUNCE_REQUEST 131 -#define NET_PACKET_ANNOUNCE_RESPONSE 132 -#define NET_PACKET_ONION_DATA_REQUEST 133 -#define NET_PACKET_ONION_DATA_RESPONSE 134 - -#define NET_PACKET_ONION_RECV_3 140 -#define NET_PACKET_ONION_RECV_2 141 -#define NET_PACKET_ONION_RECV_1 142 - -/* Only used for bootstrap nodes */ -#define BOOTSTRAP_INFO_PACKET_ID 240 +typedef enum NET_PACKET_TYPE { + NET_PACKET_PING_REQUEST = 0, /* Ping request packet ID. */ + NET_PACKET_PING_RESPONSE = 1, /* Ping response packet ID. */ + NET_PACKET_GET_NODES = 2, /* Get nodes request packet ID. */ + NET_PACKET_SEND_NODES_IPV6 = 4, /* Send nodes response packet ID for other addresses. */ + NET_PACKET_COOKIE_REQUEST = 24, /* Cookie request packet */ + NET_PACKET_COOKIE_RESPONSE = 25, /* Cookie response packet */ + NET_PACKET_CRYPTO_HS = 26, /* Crypto handshake packet */ + NET_PACKET_CRYPTO_DATA = 27, /* Crypto data packet */ + NET_PACKET_CRYPTO = 32, /* Encrypted data packet ID. */ + NET_PACKET_LAN_DISCOVERY = 33, /* LAN discovery packet ID. */ + NET_PACKET_ONION_SEND_INITIAL = 128, + NET_PACKET_ONION_SEND_1 = 129, + NET_PACKET_ONION_SEND_2 = 130, + NET_PACKET_ANNOUNCE_REQUEST = 131, + NET_PACKET_ANNOUNCE_RESPONSE = 132, + NET_PACKET_ONION_DATA_REQUEST = 133, + NET_PACKET_ONION_DATA_RESPONSE = 134, + NET_PACKET_ONION_RECV_3 = 140, + NET_PACKET_ONION_RECV_2 = 141, + NET_PACKET_ONION_RECV_1 = 142, + BOOTSTRAP_INFO_PACKET_ID = 240, /* Only used for bootstrap nodes */ + + NET_PACKET_MAX = 255, /* This type must remain within a single uint8. */ +} NET_PACKET_TYPE; #define TOX_PORTRANGE_FROM 33445