Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weaponFS15/src/external/enet/enet.h @ 10601

Last change on this file since 10601 was 8088, checked in by adrfried, 14 years ago

Updated Enet to version 1.3.1

updated patch

  • Property svn:eol-style set to native
File size: 23.9 KB
Line 
1/**
2 @file  enet.h
3 @brief ENet public header file
4*/
5#ifndef __ENET_ENET_H__
6#define __ENET_ENET_H__
7
8#ifdef __cplusplus
9extern "C"
10{
11#endif
12
13#include <stdlib.h>
14
15#ifdef WIN32
16#include "enet/win32.h"
17#else
18#include "enet/unix.h"
19#endif
20
21#include "enet/types.h"
22#include "enet/protocol.h"
23#include "enet/list.h"
24#include "enet/callbacks.h"
25
26#define ENET_VERSION_MAJOR 1
27#define ENET_VERSION_MINOR 3
28#define ENET_VERSION_PATCH 1
29#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
30#define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH)
31
32typedef enet_uint32 ENetVersion;
33
34typedef enum _ENetSocketType
35{
36   ENET_SOCKET_TYPE_STREAM   = 1,
37   ENET_SOCKET_TYPE_DATAGRAM = 2
38} ENetSocketType;
39
40typedef enum _ENetSocketWait
41{
42   ENET_SOCKET_WAIT_NONE    = 0,
43   ENET_SOCKET_WAIT_SEND    = (1 << 0),
44   ENET_SOCKET_WAIT_RECEIVE = (1 << 1)
45} ENetSocketWait;
46
47typedef enum _ENetSocketOption
48{
49   ENET_SOCKOPT_NONBLOCK  = 1,
50   ENET_SOCKOPT_BROADCAST = 2,
51   ENET_SOCKOPT_RCVBUF    = 3,
52   ENET_SOCKOPT_SNDBUF    = 4,
53   ENET_SOCKOPT_REUSEADDR = 5
54} ENetSocketOption;
55
56typedef struct _ENetHostAddress
57{
58   enet_uint8 addr[16];
59} ENetHostAddress;
60
61#define ENET_HOST_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }                         /**< specifies the default server host (macro for variable initialization) */
62static const ENetHostAddress ENET_HOST_ANY = ENET_HOST_ANY_INIT;                           /**< specifies the default server host (global constant variable) */
63#define ENET_IPV4MAPPED_PREFIX_INIT { { 0,0,0,0,0,0,0,0,0,0,0xff,0xff,0,0,0,0 } }          /**< specifies the IPv4-mapped IPv6 prefix (macro for variable initialization) */
64static const ENetHostAddress ENET_IPV4MAPPED_PREFIX = ENET_IPV4MAPPED_PREFIX_INIT;         /**< specifies the IPv4-mapped IPv6 prefix (global constant variable) */
65#define ENET_HOST_BROADCAST_INIT { { 0,0,0,0,0,0,0,0,0,0,0xff,0xff,0xff,0xff,0xff,0xff } } /**< specifies a IPv4 subnet-wide broadcast (macro for variable initialization) */
66static const ENetHostAddress ENET_HOST_BROADCAST = ENET_HOST_BROADCAST_INIT;               /**< specifies a IPv4 subnet-wide broadcast (global constant variable) */
67enum {
68    ENET_IPV4MAPPED_PREFIX_LEN = 12,                                                       /**< specifies the length of the IPv4-mapped IPv6 prefix */
69    ENET_PORT_ANY              = 0                                                         /**< specifies that a port should be automatically chosen */
70};
71
72/**
73 * Portable internet address structure.
74 *
75 * The host must be specified in network byte-order, and the port must be in host
76 * byte-order. The constant ENET_HOST_ANY may be used to specify the default
77 * server host. The constant ENET_HOST_BROADCAST may be used to specify the
78 * broadcast address (255.255.255.255).  This makes sense for enet_host_connect,
79 * but not for enet_host_create.  Once a server responds to a broadcast, the
80 * address is updated from ENET_HOST_BROADCAST to the server's actual IP address.
81 */
82typedef struct _ENetAddress
83{
84   ENetHostAddress host;
85#ifdef WIN32
86   u_long scopeID;
87#else
88   uint32_t scopeID;
89#endif
90   enet_uint16 port;
91} ENetAddress;
92
93/**
94 * The address family type.
95 */
96typedef enum _ENetAddressFamily
97{
98    ENET_NO_ADDRESS_FAMILY = 0,
99    ENET_IPV4 = (1 << 0),
100    ENET_IPV6 = (1 << 1)
101} ENetAddressFamily;
102
103/**
104 * Packet flag bit constants.
105 *
106 * The host must be specified in network byte-order, and the port must be in
107 * host byte-order. The constant ENET_HOST_ANY may be used to specify the
108 * default server host.
109 
110   @sa ENetPacket
111*/
112typedef enum _ENetPacketFlag
113{
114   /** packet must be received by the target peer and resend attempts should be
115     * made until the packet is delivered */
116   ENET_PACKET_FLAG_RELIABLE    = (1 << 0),
117   /** packet will not be sequenced with other packets
118     * not supported for reliable packets
119     */
120   ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1),
121   /** packet will not allocate data, and user must supply it instead */
122   ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2)
123} ENetPacketFlag;
124
125struct _ENetPacket;
126typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);
127
128/**
129 * ENet packet structure.
130 *
131 * An ENet data packet that may be sent to or received from a peer. The shown
132 * fields should only be read and never modified. The data field contains the
133 * allocated data for the packet. The dataLength fields specifies the length
134 * of the allocated data.  The flags field is either 0 (specifying no flags),
135 * or a bitwise-or of any combination of the following flags:
136 *
137 *    ENET_PACKET_FLAG_RELIABLE - packet must be received by the target peer
138 *    and resend attempts should be made until the packet is delivered
139 *
140 *    ENET_PACKET_FLAG_UNSEQUENCED - packet will not be sequenced with other packets
141 *    (not supported for reliable packets)
142 *
143 *    ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead
144 
145   @sa ENetPacketFlag
146 */
147typedef struct _ENetPacket
148{
149   size_t                   referenceCount;  /**< internal use only */
150   enet_uint32              flags;           /**< bitwise-or of ENetPacketFlag constants */
151   enet_uint8 *             data;            /**< allocated data for packet */
152   size_t                   dataLength;      /**< length of data */
153   ENetPacketFreeCallback   freeCallback;    /**< function to be called when the packet is no longer in use */
154} ENetPacket;
155
156typedef struct _ENetAcknowledgement
157{
158   ENetListNode acknowledgementList;
159   enet_uint32  sentTime;
160   ENetProtocol command;
161} ENetAcknowledgement;
162
163typedef struct _ENetOutgoingCommand
164{
165   ENetListNode outgoingCommandList;
166   enet_uint16  reliableSequenceNumber;
167   enet_uint16  unreliableSequenceNumber;
168   enet_uint32  sentTime;
169   enet_uint32  roundTripTimeout;
170   enet_uint32  roundTripTimeoutLimit;
171   enet_uint32  fragmentOffset;
172   enet_uint16  fragmentLength;
173   enet_uint16  sendAttempts;
174   ENetProtocol command;
175   ENetPacket * packet;
176} ENetOutgoingCommand;
177
178typedef struct _ENetIncomingCommand
179{ 
180   ENetListNode     incomingCommandList;
181   enet_uint16      reliableSequenceNumber;
182   enet_uint16      unreliableSequenceNumber;
183   ENetProtocol     command;
184   enet_uint32      fragmentCount;
185   enet_uint32      fragmentsRemaining;
186   enet_uint32 *    fragments;
187   ENetPacket *     packet;
188} ENetIncomingCommand;
189
190typedef enum _ENetPeerState
191{
192   ENET_PEER_STATE_DISCONNECTED                = 0,
193   ENET_PEER_STATE_CONNECTING                  = 1,
194   ENET_PEER_STATE_ACKNOWLEDGING_CONNECT       = 2,
195   ENET_PEER_STATE_CONNECTION_PENDING          = 3,
196   ENET_PEER_STATE_CONNECTION_SUCCEEDED        = 4,
197   ENET_PEER_STATE_CONNECTED                   = 5,
198   ENET_PEER_STATE_DISCONNECT_LATER            = 6,
199   ENET_PEER_STATE_DISCONNECTING               = 7,
200   ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT    = 8,
201   ENET_PEER_STATE_ZOMBIE                      = 9 
202} ENetPeerState;
203
204#ifndef ENET_BUFFER_MAXIMUM
205#define ENET_BUFFER_MAXIMUM (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS)
206#endif
207
208enum
209{
210   ENET_HOST_RECEIVE_BUFFER_SIZE          = 256 * 1024,
211   ENET_HOST_SEND_BUFFER_SIZE             = 256 * 1024,
212   ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL  = 1000,
213   ENET_HOST_DEFAULT_MTU                  = 1400,
214
215   ENET_PEER_DEFAULT_ROUND_TRIP_TIME      = 500,
216   ENET_PEER_DEFAULT_PACKET_THROTTLE      = 32,
217   ENET_PEER_PACKET_THROTTLE_SCALE        = 32,
218   ENET_PEER_PACKET_THROTTLE_COUNTER      = 7, 
219   ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2,
220   ENET_PEER_PACKET_THROTTLE_DECELERATION = 2,
221   ENET_PEER_PACKET_THROTTLE_INTERVAL     = 5000,
222   ENET_PEER_PACKET_LOSS_SCALE            = (1 << 16),
223   ENET_PEER_PACKET_LOSS_INTERVAL         = 10000,
224   ENET_PEER_WINDOW_SIZE_SCALE            = 64 * 1024,
225   ENET_PEER_TIMEOUT_LIMIT                = 32,
226   ENET_PEER_TIMEOUT_MINIMUM              = 5000,
227   ENET_PEER_TIMEOUT_MAXIMUM              = 30000,
228   ENET_PEER_PING_INTERVAL                = 500,
229   ENET_PEER_UNSEQUENCED_WINDOWS          = 64,
230   ENET_PEER_UNSEQUENCED_WINDOW_SIZE      = 1024,
231   ENET_PEER_FREE_UNSEQUENCED_WINDOWS     = 32,
232   ENET_PEER_RELIABLE_WINDOWS             = 16,
233   ENET_PEER_RELIABLE_WINDOW_SIZE         = 0x1000,
234   ENET_PEER_FREE_RELIABLE_WINDOWS        = 8
235};
236
237typedef struct _ENetChannel
238{
239   enet_uint16  outgoingReliableSequenceNumber;
240   enet_uint16  outgoingUnreliableSequenceNumber;
241   enet_uint16  usedReliableWindows;
242   enet_uint16  reliableWindows [ENET_PEER_RELIABLE_WINDOWS];
243   enet_uint16  incomingReliableSequenceNumber;
244   ENetList     incomingReliableCommands;
245   ENetList     incomingUnreliableCommands;
246} ENetChannel;
247
248/**
249 * An ENet peer which data packets may be sent or received from.
250 *
251 * No fields should be modified unless otherwise specified.
252 */
253typedef struct _ENetPeer
254{ 
255   ENetListNode  dispatchList;
256   struct _ENetHost * host;
257   enet_uint16   outgoingPeerID;
258   enet_uint16   incomingPeerID;
259   enet_uint32   connectID;
260   enet_uint8    outgoingSessionID;
261   enet_uint8    incomingSessionID;
262   ENetAddress   address;            /**< Internet address of the peer */
263   void *        data;               /**< Application private data, may be freely modified */
264   ENetPeerState state;
265   ENetChannel * channels;
266   size_t        channelCount;       /**< Number of channels allocated for communication with peer */
267   enet_uint32   incomingBandwidth;  /**< Downstream bandwidth of the client in bytes/second */
268   enet_uint32   outgoingBandwidth;  /**< Upstream bandwidth of the client in bytes/second */
269   enet_uint32   incomingBandwidthThrottleEpoch;
270   enet_uint32   outgoingBandwidthThrottleEpoch;
271   enet_uint32   incomingDataTotal;
272   enet_uint32   outgoingDataTotal;
273   enet_uint32   lastSendTime;
274   enet_uint32   lastReceiveTime;
275   enet_uint32   nextTimeout;
276   enet_uint32   earliestTimeout;
277   enet_uint32   packetLossEpoch;
278   enet_uint32   packetsSent;
279   enet_uint32   packetsLost;
280   enet_uint32   packetLoss;          /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */
281   enet_uint32   packetLossVariance;
282   enet_uint32   packetThrottle;
283   enet_uint32   packetThrottleLimit;
284   enet_uint32   packetThrottleCounter;
285   enet_uint32   packetThrottleEpoch;
286   enet_uint32   packetThrottleAcceleration;
287   enet_uint32   packetThrottleDeceleration;
288   enet_uint32   packetThrottleInterval;
289   enet_uint32   lastRoundTripTime;
290   enet_uint32   lowestRoundTripTime;
291   enet_uint32   lastRoundTripTimeVariance;
292   enet_uint32   highestRoundTripTimeVariance;
293   enet_uint32   roundTripTime;            /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgement */
294   enet_uint32   roundTripTimeVariance;
295   enet_uint32   mtu;
296   enet_uint32   windowSize;
297   enet_uint32   reliableDataInTransit;
298   enet_uint16   outgoingReliableSequenceNumber;
299   ENetList      acknowledgements;
300   ENetList      sentReliableCommands;
301   ENetList      sentUnreliableCommands;
302   ENetList      outgoingReliableCommands;
303   ENetList      outgoingUnreliableCommands;
304   ENetList      dispatchedCommands;
305   int           needsDispatch;
306   enet_uint16   incomingUnsequencedGroup;
307   enet_uint16   outgoingUnsequencedGroup;
308   enet_uint32   unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32]; 
309   enet_uint32   eventData;
310} ENetPeer;
311
312/** An ENet packet compressor for compressing UDP packets before socket sends or receives.
313 */
314typedef struct _ENetCompressor
315{
316   /** Context data for the compressor. Must be non-NULL. */
317   void * context;
318   /** Compresses from inBuffers[0:inBufferCount-1], containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */
319   size_t (ENET_CALLBACK * compress) (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit);
320   /** Decompresses from inData, containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */
321   size_t (ENET_CALLBACK * decompress) (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit);
322   /** Destroys the context when compression is disabled or the host is destroyed. May be NULL. */
323   void (ENET_CALLBACK * destroy) (void * context);
324} ENetCompressor;
325
326/** Callback that computes the checksum of the data held in buffers[0:bufferCount-1] */
327typedef enet_uint32 (ENET_CALLBACK * ENetChecksumCallback) (const ENetBuffer * buffers, size_t bufferCount);
328 
329/** An ENet host for communicating with peers.
330  *
331  * No fields should be modified unless otherwise stated.
332
333    @sa enet_host_create()
334    @sa enet_host_destroy()
335    @sa enet_host_connect()
336    @sa enet_host_service()
337    @sa enet_host_flush()
338    @sa enet_host_broadcast()
339    @sa enet_host_compress()
340    @sa enet_host_compress_with_range_coder()
341    @sa enet_host_channel_limit()
342    @sa enet_host_bandwidth_limit()
343    @sa enet_host_bandwidth_throttle()
344  */
345typedef struct _ENetHost
346{
347   ENetSocket           socket4;
348   ENetSocket           socket6;
349   ENetAddress          address;                     /**< Internet address of the host */
350   enet_uint32          incomingBandwidth;           /**< downstream bandwidth of the host */
351   enet_uint32          outgoingBandwidth;           /**< upstream bandwidth of the host */
352   enet_uint32          bandwidthThrottleEpoch;
353   enet_uint32          mtu;
354   enet_uint32          randomSeed;
355   int                  recalculateBandwidthLimits;
356   ENetPeer *           peers;                       /**< array of peers allocated for this host */
357   size_t               peerCount;                   /**< number of peers allocated for this host */
358   size_t               channelLimit;                /**< maximum number of channels allowed for connected peers */
359   enet_uint32          serviceTime;
360   ENetList             dispatchQueue;
361   int                  continueSending;
362   size_t               packetSize;
363   enet_uint16          headerFlags;
364   ENetProtocol         commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS];
365   size_t               commandCount;
366   ENetBuffer           buffers [ENET_BUFFER_MAXIMUM];
367   size_t               bufferCount;
368   ENetChecksumCallback checksum;                    /**< callback the user can set to enable packet checksums for this host */
369   ENetCompressor       compressor;
370   enet_uint8           packetData [2][ENET_PROTOCOL_MAXIMUM_MTU];
371   ENetAddress          receivedAddress;
372   enet_uint8 *         receivedData;
373   size_t               receivedDataLength;
374   enet_uint32          totalSentData;               /**< total data sent, user should reset to 0 as needed to prevent overflow */
375   enet_uint32          totalSentPackets;            /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */
376   enet_uint32          totalReceivedData;           /**< total data received, user should reset to 0 as needed to prevent overflow */
377   enet_uint32          totalReceivedPackets;        /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */
378} ENetHost;
379
380/**
381 * An ENet event type, as specified in @ref ENetEvent.
382 */
383typedef enum _ENetEventType
384{
385   /** no event occurred within the specified time limit */
386   ENET_EVENT_TYPE_NONE       = 0, 
387
388   /** a connection request initiated by enet_host_connect has completed. 
389     * The peer field contains the peer which successfully connected.
390     */
391   ENET_EVENT_TYPE_CONNECT    = 1, 
392
393   /** a peer has disconnected.  This event is generated on a successful
394     * completion of a disconnect initiated by enet_pper_disconnect, if
395     * a peer has timed out, or if a connection request intialized by
396     * enet_host_connect has timed out.  The peer field contains the peer
397     * which disconnected. The data field contains user supplied data
398     * describing the disconnection, or 0, if none is available.
399     */
400   ENET_EVENT_TYPE_DISCONNECT = 2, 
401
402   /** a packet has been received from a peer.  The peer field specifies the
403     * peer which sent the packet.  The channelID field specifies the channel
404     * number upon which the packet was received.  The packet field contains
405     * the packet that was received; this packet must be destroyed with
406     * enet_packet_destroy after use.
407     */
408   ENET_EVENT_TYPE_RECEIVE    = 3
409} ENetEventType;
410
411/**
412 * An ENet event as returned by enet_host_service().
413   
414   @sa enet_host_service
415 */
416typedef struct _ENetEvent
417{
418   ENetEventType        type;      /**< type of the event */
419   ENetPeer *           peer;      /**< peer that generated a connect, disconnect or receive event */
420   enet_uint8           channelID; /**< channel on the peer that generated the event, if appropriate */
421   enet_uint32          data;      /**< data associated with the event, if appropriate */
422   ENetPacket *         packet;    /**< packet associated with the event, if appropriate */
423} ENetEvent;
424
425/** @defgroup global ENet global functions
426    @{
427*/
428
429/**
430  Initializes ENet globally.  Must be called prior to using any functions in
431  ENet.
432  @returns 0 on success, < 0 on failure
433*/
434ENET_API int enet_initialize (void);
435
436/**
437  Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored.
438
439  @param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use
440  @param inits user-overriden callbacks where any NULL callbacks will use ENet's defaults
441  @returns 0 on success, < 0 on failure
442*/
443ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits);
444
445/**
446  Shuts down ENet globally.  Should be called when a program that has
447  initialized ENet exits.
448*/
449ENET_API void enet_deinitialize (void);
450
451/** @} */
452
453/** @defgroup private ENet private implementation functions */
454
455/**
456  Returns the wall-time in milliseconds.  Its initial value is unspecified
457  unless otherwise set.
458  */
459ENET_API enet_uint32 enet_time_get (void);
460/**
461  Sets the current wall-time in milliseconds.
462  */
463ENET_API void enet_time_set (enet_uint32);
464
465/** @defgroup socket ENet socket functions
466    @{
467*/
468ENET_API ENetSocket enet_socket_create (ENetSocketType, ENetAddressFamily);
469ENET_API int        enet_socket_bind (ENetSocket, const ENetAddress *, ENetAddressFamily);
470ENET_API int        enet_socket_listen (ENetSocket, int);
471ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *, ENetAddressFamily);
472ENET_API int        enet_socket_connect (ENetSocket, const ENetAddress *, ENetAddressFamily);
473ENET_API int        enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t, ENetAddressFamily);
474ENET_API int        enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t, ENetAddressFamily);
475ENET_API int        enet_socket_wait (ENetSocket, ENetSocket, enet_uint32 *, enet_uint32);
476ENET_API int        enet_socket_set_option (ENetSocket, ENetSocketOption, int);
477ENET_API void       enet_socket_destroy (ENetSocket);
478ENET_API int        enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32);
479
480/** @} */
481
482/** @defgroup Address ENet address functions
483    @{
484*/
485/** Attempts to resolve the host named by the parameter hostName and sets
486    the host field in the address parameter if successful.
487    @param address destination to store resolved address
488    @param hostName host name to lookup
489    @retval 0 on success
490    @retval < 0 on failure
491    @returns the address of the given hostName in address on success
492*/
493ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);
494
495/** Gives the printable form of the ip address specified in the address parameter.
496    @param address    address printed
497    @param hostName   destination for name, must not be NULL
498    @param nameLength maximum length of hostName.
499    @returns the null-terminated name of the host in hostName on success
500    @retval 0 on success
501    @retval < 0 on failure
502*/
503ENET_API int enet_address_get_host_ip (const ENetAddress * address, char * hostName, size_t nameLength);
504
505/** Attempts to do a reverse lookup of the host field in the address parameter.
506    @param address    address used for reverse lookup
507    @param hostName   destination for name, must not be NULL
508    @param nameLength maximum length of hostName.
509    @returns the null-terminated name of the host in hostName on success
510    @retval 0 on success
511    @retval < 0 on failure
512*/
513ENET_API int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength);
514
515/** Maps an IPv4 Address to an IPv6 address.
516    @param address IPv4 address in network byte order
517    @returns the IPv4-mapped IPv6 address in network byte order
518*/
519ENET_API ENetHostAddress enet_address_map4 (enet_uint32 address);
520
521/** Returns the Address family of an (IPv4-mapped) IPv6 address.
522    @param address IPv6 address
523    @returns address family
524*/
525ENET_API ENetAddressFamily enet_get_address_family (const ENetAddress * address);
526
527/** @} */
528
529ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32);
530ENET_API void         enet_packet_destroy (ENetPacket *);
531ENET_API int          enet_packet_resize  (ENetPacket *, size_t);
532extern enet_uint32    enet_crc32 (const ENetBuffer *, size_t);
533               
534ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32);
535ENET_API void       enet_host_destroy (ENetHost *);
536ENET_API ENetPeer * enet_host_connect (ENetHost *, const ENetAddress *, size_t, enet_uint32);
537ENET_API int        enet_host_check_events (ENetHost *, ENetEvent *);
538ENET_API int        enet_host_service (ENetHost *, ENetEvent *, enet_uint32);
539ENET_API void       enet_host_flush (ENetHost *);
540ENET_API void       enet_host_broadcast (ENetHost *, enet_uint8, ENetPacket *);
541ENET_API void       enet_host_compress (ENetHost *, const ENetCompressor *);
542ENET_API int        enet_host_compress_with_range_coder (ENetHost * host);
543ENET_API void       enet_host_channel_limit (ENetHost *, size_t);
544ENET_API void       enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
545extern   void       enet_host_bandwidth_throttle (ENetHost *);
546
547ENET_API int                 enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
548ENET_API ENetPacket *        enet_peer_receive (ENetPeer *, enet_uint8 * channelID);
549ENET_API void                enet_peer_ping (ENetPeer *);
550ENET_API void                enet_peer_reset (ENetPeer *);
551ENET_API void                enet_peer_disconnect (ENetPeer *, enet_uint32);
552ENET_API void                enet_peer_disconnect_now (ENetPeer *, enet_uint32);
553ENET_API void                enet_peer_disconnect_later (ENetPeer *, enet_uint32);
554ENET_API void                enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
555extern int                   enet_peer_throttle (ENetPeer *, enet_uint32);
556extern void                  enet_peer_reset_queues (ENetPeer *);
557extern void                  enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
558extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
559extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32);
560extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
561extern void                  enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
562extern void                  enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);
563
564ENET_API void * enet_range_coder_create (void);
565ENET_API void   enet_range_coder_destroy (void *);
566ENET_API size_t enet_range_coder_compress (void *, const ENetBuffer *, size_t, size_t, enet_uint8 *, size_t);
567ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, enet_uint8 *, size_t);
568   
569extern size_t enet_protocol_command_size (enet_uint8);
570
571#ifdef __cplusplus
572}
573#endif
574
575#endif /* __ENET_ENET_H__ */
576
Note: See TracBrowser for help on using the repository browser.