Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert series of NET_PACKET_* defines into a typedef enum #212

Merged
merged 1 commit into from
Nov 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions toxcore/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down