Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/waypoints/src/external/enet/protocol.h @ 10241

Last change on this file since 10241 was 7459, checked in by adrfried, 14 years ago

Merged ipv6 branch

Orxonox now includes a modified version of ENet 1.3.0

  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
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         = 0xFFF
20};
21
22typedef enum _ENetProtocolCommand
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 _ENetProtocolFlag
42{
43   ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7),
44   ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6),
45
46   ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14),
47   ENET_PROTOCOL_HEADER_FLAG_SENT_TIME  = (1 << 15),
48   ENET_PROTOCOL_HEADER_FLAG_MASK       = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME,
49
50   ENET_PROTOCOL_HEADER_SESSION_MASK    = (3 << 12),
51   ENET_PROTOCOL_HEADER_SESSION_SHIFT   = 12
52} ENetProtocolFlag;
53
54#ifdef _MSC_VER_
55#pragma pack(push, 1)
56#define ENET_PACKED
57#elif defined(__GNUC__)
58#define ENET_PACKED __attribute__ ((packed))
59#else
60#define ENET_PACKED
61#endif
62
63typedef struct _ENetProtocolHeader
64{
65   enet_uint16 peerID;
66   enet_uint16 sentTime;
67} ENET_PACKED ENetProtocolHeader;
68
69typedef struct _ENetProtocolCommandHeader
70{
71   enet_uint8 command;
72   enet_uint8 channelID;
73   enet_uint16 reliableSequenceNumber;
74} ENET_PACKED ENetProtocolCommandHeader;
75
76typedef struct _ENetProtocolAcknowledge
77{
78   ENetProtocolCommandHeader header;
79   enet_uint16 receivedReliableSequenceNumber;
80   enet_uint16 receivedSentTime;
81} ENET_PACKED ENetProtocolAcknowledge;
82
83typedef struct _ENetProtocolConnect
84{
85   ENetProtocolCommandHeader header;
86   enet_uint16 outgoingPeerID;
87   enet_uint8  incomingSessionID;
88   enet_uint8  outgoingSessionID;
89   enet_uint32 mtu;
90   enet_uint32 windowSize;
91   enet_uint32 channelCount;
92   enet_uint32 incomingBandwidth;
93   enet_uint32 outgoingBandwidth;
94   enet_uint32 packetThrottleInterval;
95   enet_uint32 packetThrottleAcceleration;
96   enet_uint32 packetThrottleDeceleration;
97   enet_uint32 connectID;
98   enet_uint32 data;
99} ENET_PACKED ENetProtocolConnect;
100
101typedef struct _ENetProtocolVerifyConnect
102{
103   ENetProtocolCommandHeader header;
104   enet_uint16 outgoingPeerID;
105   enet_uint8  incomingSessionID;
106   enet_uint8  outgoingSessionID;
107   enet_uint32 mtu;
108   enet_uint32 windowSize;
109   enet_uint32 channelCount;
110   enet_uint32 incomingBandwidth;
111   enet_uint32 outgoingBandwidth;
112   enet_uint32 packetThrottleInterval;
113   enet_uint32 packetThrottleAcceleration;
114   enet_uint32 packetThrottleDeceleration;
115   enet_uint32 connectID;
116} ENET_PACKED ENetProtocolVerifyConnect;
117
118typedef struct _ENetProtocolBandwidthLimit
119{
120   ENetProtocolCommandHeader header;
121   enet_uint32 incomingBandwidth;
122   enet_uint32 outgoingBandwidth;
123} ENET_PACKED ENetProtocolBandwidthLimit;
124
125typedef struct _ENetProtocolThrottleConfigure
126{
127   ENetProtocolCommandHeader header;
128   enet_uint32 packetThrottleInterval;
129   enet_uint32 packetThrottleAcceleration;
130   enet_uint32 packetThrottleDeceleration;
131} ENET_PACKED ENetProtocolThrottleConfigure;
132
133typedef struct _ENetProtocolDisconnect
134{
135   ENetProtocolCommandHeader header;
136   enet_uint32 data;
137} ENET_PACKED ENetProtocolDisconnect;
138
139typedef struct _ENetProtocolPing
140{
141   ENetProtocolCommandHeader header;
142} ENET_PACKED ENetProtocolPing;
143
144typedef struct _ENetProtocolSendReliable
145{
146   ENetProtocolCommandHeader header;
147   enet_uint16 dataLength;
148} ENET_PACKED ENetProtocolSendReliable;
149
150typedef struct _ENetProtocolSendUnreliable
151{
152   ENetProtocolCommandHeader header;
153   enet_uint16 unreliableSequenceNumber;
154   enet_uint16 dataLength;
155} ENET_PACKED ENetProtocolSendUnreliable;
156
157typedef struct _ENetProtocolSendUnsequenced
158{
159   ENetProtocolCommandHeader header;
160   enet_uint16 unsequencedGroup;
161   enet_uint16 dataLength;
162} ENET_PACKED ENetProtocolSendUnsequenced;
163
164typedef struct _ENetProtocolSendFragment
165{
166   ENetProtocolCommandHeader header;
167   enet_uint16 startSequenceNumber;
168   enet_uint16 dataLength;
169   enet_uint32 fragmentCount;
170   enet_uint32 fragmentNumber;
171   enet_uint32 totalLength;
172   enet_uint32 fragmentOffset;
173} ENET_PACKED ENetProtocolSendFragment;
174
175typedef union _ENetProtocol
176{
177   ENetProtocolCommandHeader header;
178   ENetProtocolAcknowledge acknowledge;
179   ENetProtocolConnect connect;
180   ENetProtocolVerifyConnect verifyConnect;
181   ENetProtocolDisconnect disconnect;
182   ENetProtocolPing ping;
183   ENetProtocolSendReliable sendReliable;
184   ENetProtocolSendUnreliable sendUnreliable;
185   ENetProtocolSendUnsequenced sendUnsequenced;
186   ENetProtocolSendFragment sendFragment;
187   ENetProtocolBandwidthLimit bandwidthLimit;
188   ENetProtocolThrottleConfigure throttleConfigure;
189} ENET_PACKED ENetProtocol;
190
191#ifdef _MSC_VER_
192#pragma pack(pop)
193#endif
194
195#endif /* __ENET_PROTOCOL_H__ */
196
Note: See TracBrowser for help on using the repository browser.