ScummVM API documentation
protocol.h
1 
5 #ifndef __ENET_PROTOCOL_H__
6 #define __ENET_PROTOCOL_H__
7 
8 #include "types.h"
9 
10 enum
11 {
12  ENET_PROTOCOL_MINIMUM_MTU = 576,
13  ENET_PROTOCOL_MAXIMUM_MTU = 4096,
14  ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32,
15  ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096,
16  ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536,
17  ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1,
18  ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255,
19  ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF,
20  ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024
21 };
22 
23 typedef enum _ENetProtocolCommand
24 {
25  ENET_PROTOCOL_COMMAND_NONE = 0,
26  ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
27  ENET_PROTOCOL_COMMAND_CONNECT = 2,
28  ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
29  ENET_PROTOCOL_COMMAND_DISCONNECT = 4,
30  ENET_PROTOCOL_COMMAND_PING = 5,
31  ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
32  ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
33  ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
34  ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
35  ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
36  ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
37  ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
38  ENET_PROTOCOL_COMMAND_COUNT = 13,
39 
40  ENET_PROTOCOL_COMMAND_MASK = 0x0F
41 } ENetProtocolCommand;
42 
43 typedef enum _ENetProtocolFlag
44 {
45  ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7),
46  ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6),
47 
48  ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14),
49  ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15),
50  ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME,
51 
52  ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12),
53  ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12
54 } ENetProtocolFlag;
55 
56 #ifdef _MSC_VER
57 #pragma pack(push, 1)
58 #define ENET_PACKED
59 #elif defined(__GNUC__) || defined(__clang__)
60 #define ENET_PACKED __attribute__ ((packed))
61 #else
62 #define ENET_PACKED
63 #endif
64 
65 typedef struct _ENetProtocolHeader
66 {
67  enet_uint16 peerID;
68  enet_uint16 sentTime;
69 } ENET_PACKED ENetProtocolHeader;
70 
72 {
73  enet_uint8 command;
74  enet_uint8 channelID;
75  enet_uint16 reliableSequenceNumber;
76 } ENET_PACKED ENetProtocolCommandHeader;
77 
79 {
80  ENetProtocolCommandHeader header;
81  enet_uint16 receivedReliableSequenceNumber;
82  enet_uint16 receivedSentTime;
83 } ENET_PACKED ENetProtocolAcknowledge;
84 
85 typedef struct _ENetProtocolConnect
86 {
87  ENetProtocolCommandHeader header;
88  enet_uint16 outgoingPeerID;
89  enet_uint8 incomingSessionID;
90  enet_uint8 outgoingSessionID;
91  enet_uint32 mtu;
92  enet_uint32 windowSize;
93  enet_uint32 channelCount;
94  enet_uint32 incomingBandwidth;
95  enet_uint32 outgoingBandwidth;
96  enet_uint32 packetThrottleInterval;
97  enet_uint32 packetThrottleAcceleration;
98  enet_uint32 packetThrottleDeceleration;
99  enet_uint32 connectID;
100  enet_uint32 data;
101 } ENET_PACKED ENetProtocolConnect;
102 
104 {
105  ENetProtocolCommandHeader header;
106  enet_uint16 outgoingPeerID;
107  enet_uint8 incomingSessionID;
108  enet_uint8 outgoingSessionID;
109  enet_uint32 mtu;
110  enet_uint32 windowSize;
111  enet_uint32 channelCount;
112  enet_uint32 incomingBandwidth;
113  enet_uint32 outgoingBandwidth;
114  enet_uint32 packetThrottleInterval;
115  enet_uint32 packetThrottleAcceleration;
116  enet_uint32 packetThrottleDeceleration;
117  enet_uint32 connectID;
118 } ENET_PACKED ENetProtocolVerifyConnect;
119 
121 {
122  ENetProtocolCommandHeader header;
123  enet_uint32 incomingBandwidth;
124  enet_uint32 outgoingBandwidth;
125 } ENET_PACKED ENetProtocolBandwidthLimit;
126 
128 {
129  ENetProtocolCommandHeader header;
130  enet_uint32 packetThrottleInterval;
131  enet_uint32 packetThrottleAcceleration;
132  enet_uint32 packetThrottleDeceleration;
133 } ENET_PACKED ENetProtocolThrottleConfigure;
134 
136 {
137  ENetProtocolCommandHeader header;
138  enet_uint32 data;
139 } ENET_PACKED ENetProtocolDisconnect;
140 
141 typedef struct _ENetProtocolPing
142 {
143  ENetProtocolCommandHeader header;
144 } ENET_PACKED ENetProtocolPing;
145 
147 {
148  ENetProtocolCommandHeader header;
149  enet_uint16 dataLength;
150 } ENET_PACKED ENetProtocolSendReliable;
151 
153 {
154  ENetProtocolCommandHeader header;
155  enet_uint16 unreliableSequenceNumber;
156  enet_uint16 dataLength;
157 } ENET_PACKED ENetProtocolSendUnreliable;
158 
160 {
161  ENetProtocolCommandHeader header;
162  enet_uint16 unsequencedGroup;
163  enet_uint16 dataLength;
164 } ENET_PACKED ENetProtocolSendUnsequenced;
165 
167 {
168  ENetProtocolCommandHeader header;
169  enet_uint16 startSequenceNumber;
170  enet_uint16 dataLength;
171  enet_uint32 fragmentCount;
172  enet_uint32 fragmentNumber;
173  enet_uint32 totalLength;
174  enet_uint32 fragmentOffset;
175 } ENET_PACKED ENetProtocolSendFragment;
176 
177 typedef union _ENetProtocol
178 {
179  ENetProtocolCommandHeader header;
180  ENetProtocolAcknowledge acknowledge;
181  ENetProtocolConnect connect;
182  ENetProtocolVerifyConnect verifyConnect;
183  ENetProtocolDisconnect disconnect;
184  ENetProtocolPing ping;
185  ENetProtocolSendReliable sendReliable;
186  ENetProtocolSendUnreliable sendUnreliable;
187  ENetProtocolSendUnsequenced sendUnsequenced;
188  ENetProtocolSendFragment sendFragment;
189  ENetProtocolBandwidthLimit bandwidthLimit;
190  ENetProtocolThrottleConfigure throttleConfigure;
191 } ENET_PACKED ENetProtocol;
192 
193 #ifdef _MSC_VER
194 #pragma pack(pop)
195 #endif
196 
197 #endif /* __ENET_PROTOCOL_H__ */
198 
Definition: protocol.h:141
Definition: protocol.h:120
Definition: protocol.h:152
Definition: protocol.h:71
Definition: protocol.h:146
Definition: protocol.h:135
Definition: protocol.h:166
Definition: protocol.h:65
Definition: protocol.h:85
Definition: protocol.h:177
Definition: protocol.h:103
Definition: protocol.h:78
Definition: protocol.h:127
Definition: protocol.h:159