summaryrefslogtreecommitdiff
path: root/toxcore/network.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-11-05 23:42:24 +0000
committeriphydf <iphydf@users.noreply.github.com>2016-11-06 15:46:27 +0000
commit5019a5aaf9b6e927e7b56b0f808efc01ba62d66a (patch)
tree67dff09ac7f6c0481b25f9cfa112220b6930ed7f /toxcore/network.h
parent3f53090c1d148da6ede2bbe85a58689c28289e14 (diff)
Change packet kind enum to use hex constants.
Hex constants make it clearer that you can only use 2 nibbles (the two digits of the number, displayed as two columns in the source code), i.e. 1 byte, for the packet kind. It also makes the bit representation easier to see.
Diffstat (limited to 'toxcore/network.h')
-rw-r--r--toxcore/network.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/toxcore/network.h b/toxcore/network.h
index 3f4d77da..e7cc0597 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -103,29 +103,34 @@ typedef int sock_t;
103#define MAX_UDP_PACKET_SIZE 2048 103#define MAX_UDP_PACKET_SIZE 2048
104 104
105typedef enum NET_PACKET_TYPE { 105typedef enum NET_PACKET_TYPE {
106 NET_PACKET_PING_REQUEST = 0, /* Ping request packet ID. */ 106 NET_PACKET_PING_REQUEST = 0x00, /* Ping request packet ID. */
107 NET_PACKET_PING_RESPONSE = 1, /* Ping response packet ID. */ 107 NET_PACKET_PING_RESPONSE = 0x01, /* Ping response packet ID. */
108 NET_PACKET_GET_NODES = 2, /* Get nodes request packet ID. */ 108 NET_PACKET_GET_NODES = 0x02, /* Get nodes request packet ID. */
109 NET_PACKET_SEND_NODES_IPV6 = 4, /* Send nodes response packet ID for other addresses. */ 109 NET_PACKET_SEND_NODES_IPV6 = 0x04, /* Send nodes response packet ID for other addresses. */
110 NET_PACKET_COOKIE_REQUEST = 24, /* Cookie request packet */ 110 NET_PACKET_COOKIE_REQUEST = 0x18, /* Cookie request packet */
111 NET_PACKET_COOKIE_RESPONSE = 25, /* Cookie response packet */ 111 NET_PACKET_COOKIE_RESPONSE = 0x19, /* Cookie response packet */
112 NET_PACKET_CRYPTO_HS = 26, /* Crypto handshake packet */ 112 NET_PACKET_CRYPTO_HS = 0x1a, /* Crypto handshake packet */
113 NET_PACKET_CRYPTO_DATA = 27, /* Crypto data packet */ 113 NET_PACKET_CRYPTO_DATA = 0x1b, /* Crypto data packet */
114 NET_PACKET_CRYPTO = 32, /* Encrypted data packet ID. */ 114 NET_PACKET_CRYPTO = 0x20, /* Encrypted data packet ID. */
115 NET_PACKET_LAN_DISCOVERY = 33, /* LAN discovery packet ID. */ 115 NET_PACKET_LAN_DISCOVERY = 0x21, /* LAN discovery packet ID. */
116 NET_PACKET_ONION_SEND_INITIAL = 128, 116
117 NET_PACKET_ONION_SEND_1 = 129, 117 /* See: docs/Prevent_Tracking.txt and onion.{c,h} */
118 NET_PACKET_ONION_SEND_2 = 130, 118 NET_PACKET_ONION_SEND_INITIAL = 0x80,
119 NET_PACKET_ANNOUNCE_REQUEST = 131, 119 NET_PACKET_ONION_SEND_1 = 0x81,
120 NET_PACKET_ANNOUNCE_RESPONSE = 132, 120 NET_PACKET_ONION_SEND_2 = 0x82,
121 NET_PACKET_ONION_DATA_REQUEST = 133, 121
122 NET_PACKET_ONION_DATA_RESPONSE = 134, 122 NET_PACKET_ANNOUNCE_REQUEST = 0x83,
123 NET_PACKET_ONION_RECV_3 = 140, 123 NET_PACKET_ANNOUNCE_RESPONSE = 0x84,
124 NET_PACKET_ONION_RECV_2 = 141, 124 NET_PACKET_ONION_DATA_REQUEST = 0x85,
125 NET_PACKET_ONION_RECV_1 = 142, 125 NET_PACKET_ONION_DATA_RESPONSE = 0x86,
126 BOOTSTRAP_INFO_PACKET_ID = 240, /* Only used for bootstrap nodes */ 126
127 127 NET_PACKET_ONION_RECV_3 = 0x8c,
128 NET_PACKET_MAX = 255, /* This type must remain within a single uint8. */ 128 NET_PACKET_ONION_RECV_2 = 0x8d,
129 NET_PACKET_ONION_RECV_1 = 0x8e,
130
131 BOOTSTRAP_INFO_PACKET_ID = 0xf0, /* Only used for bootstrap nodes */
132
133 NET_PACKET_MAX = 0xff, /* This type must remain within a single uint8. */
129} NET_PACKET_TYPE; 134} NET_PACKET_TYPE;
130 135
131 136