Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/enet/protocol.h @ 245

Last change on this file since 245 was 134, checked in by scheusso, 17 years ago

nothing so far

File size: 4.4 KB
RevLine 
[134]1/**
2 @file  protocol.h
3 @brief ENet protocol
4*/
5#ifndef __ENET_PROTOCOL_H__
6#define __ENET_PROTOCOL_H__
7
8#include "enet/types.h"
9
10enum
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     = 32768,
17   ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT   = 1,
18   ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT   = 255,
19   ENET_PROTOCOL_MAXIMUM_PEER_ID         = 0x7FFF
20};
21
22typedef enum
23{
24   ENET_PROTOCOL_COMMAND_NONE               = 0,
25   ENET_PROTOCOL_COMMAND_ACKNOWLEDGE        = 1,
26   ENET_PROTOCOL_COMMAND_CONNECT            = 2,
27   ENET_PROTOCOL_COMMAND_VERIFY_CONNECT     = 3,
28   ENET_PROTOCOL_COMMAND_DISCONNECT         = 4,
29   ENET_PROTOCOL_COMMAND_PING               = 5,
30   ENET_PROTOCOL_COMMAND_SEND_RELIABLE      = 6,
31   ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE    = 7,
32   ENET_PROTOCOL_COMMAND_SEND_FRAGMENT      = 8,
33   ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED   = 9,
34   ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT    = 10,
35   ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
36   ENET_PROTOCOL_COMMAND_COUNT              = 12,
37
38   ENET_PROTOCOL_COMMAND_MASK               = 0x0F
39} ENetProtocolCommand;
40
41typedef enum
42{
43   ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7),
44   ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6),
45
46   ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15),
47   ENET_PROTOCOL_HEADER_FLAG_MASK      = 0x8000
48} ENetProtocolFlag;
49
50typedef struct
51{
52   enet_uint32 checksum;
53   enet_uint16 peerID;
54   enet_uint16 sentTime;
55} ENetProtocolHeader;
56
57typedef struct
58{
59   enet_uint8 command;
60   enet_uint8 channelID;
61   enet_uint16 reliableSequenceNumber;
62} ENetProtocolCommandHeader;
63
64typedef struct
65{
66   ENetProtocolCommandHeader header;
67   enet_uint16 receivedReliableSequenceNumber;
68   enet_uint16 receivedSentTime;
69} ENetProtocolAcknowledge;
70
71typedef struct
72{
73   ENetProtocolCommandHeader header;
74   enet_uint16 outgoingPeerID;
75   enet_uint16 mtu;
76   enet_uint32 windowSize;
77   enet_uint32 channelCount;
78   enet_uint32 incomingBandwidth;
79   enet_uint32 outgoingBandwidth;
80   enet_uint32 packetThrottleInterval;
81   enet_uint32 packetThrottleAcceleration;
82   enet_uint32 packetThrottleDeceleration;
83   enet_uint32 sessionID;
84} ENetProtocolConnect;
85
86typedef struct
87{
88   ENetProtocolCommandHeader header;
89   enet_uint16 outgoingPeerID;
90   enet_uint16 mtu;
91   enet_uint32 windowSize;
92   enet_uint32 channelCount;
93   enet_uint32 incomingBandwidth;
94   enet_uint32 outgoingBandwidth;
95   enet_uint32 packetThrottleInterval;
96   enet_uint32 packetThrottleAcceleration;
97   enet_uint32 packetThrottleDeceleration;
98} ENetProtocolVerifyConnect;
99
100typedef struct
101{
102   ENetProtocolCommandHeader header;
103   enet_uint32 incomingBandwidth;
104   enet_uint32 outgoingBandwidth;
105} ENetProtocolBandwidthLimit;
106
107typedef struct
108{
109   ENetProtocolCommandHeader header;
110   enet_uint32 packetThrottleInterval;
111   enet_uint32 packetThrottleAcceleration;
112   enet_uint32 packetThrottleDeceleration;
113} ENetProtocolThrottleConfigure;
114
115typedef struct
116{
117   ENetProtocolCommandHeader header;
118   enet_uint32 data;
119} ENetProtocolDisconnect;
120
121typedef struct
122{
123   ENetProtocolCommandHeader header;
124} ENetProtocolPing;
125
126typedef struct
127{
128   ENetProtocolCommandHeader header;
129   enet_uint16 dataLength;
130} ENetProtocolSendReliable;
131
132typedef struct
133{
134   ENetProtocolCommandHeader header;
135   enet_uint16 unreliableSequenceNumber;
136   enet_uint16 dataLength;
137} ENetProtocolSendUnreliable;
138
139typedef struct
140{
141   ENetProtocolCommandHeader header;
142   enet_uint16 unsequencedGroup;
143   enet_uint16 dataLength;
144} ENetProtocolSendUnsequenced;
145
146typedef struct
147{
148   ENetProtocolCommandHeader header;
149   enet_uint16 startSequenceNumber;
150   enet_uint16 dataLength;
151   enet_uint32 fragmentCount;
152   enet_uint32 fragmentNumber;
153   enet_uint32 totalLength;
154   enet_uint32 fragmentOffset;
155} ENetProtocolSendFragment;
156
157typedef union
158{
159   ENetProtocolCommandHeader header;
160   ENetProtocolAcknowledge acknowledge;
161   ENetProtocolConnect connect;
162   ENetProtocolVerifyConnect verifyConnect;
163   ENetProtocolDisconnect disconnect;
164   ENetProtocolPing ping;
165   ENetProtocolSendReliable sendReliable;
166   ENetProtocolSendUnreliable sendUnreliable;
167   ENetProtocolSendUnsequenced sendUnsequenced;
168   ENetProtocolSendFragment sendFragment;
169   ENetProtocolBandwidthLimit bandwidthLimit;
170   ENetProtocolThrottleConfigure throttleConfigure;
171} ENetProtocol;
172
173#endif /* __ENET_PROTOCOL_H__ */
174
Note: See TracBrowser for help on using the repository browser.