Skip to content

Commit

Permalink
Convert series of NET_PACKET_* defines into a typedef enum
Browse files Browse the repository at this point in the history
fixup! TravisCI shorten IRC message
  • Loading branch information
Gregory Mullen (grayhatter) committed Nov 5, 2016
1 parent 64870b6 commit ee3121c
Showing 1 changed file with 25 additions and 27 deletions.
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

0 comments on commit ee3121c

Please sign in to comment.