/src/middleware/enet/enet.h

https://bitbucket.org/vivkin/gam3b00bs/ · C Header · 540 lines · 326 code · 53 blank · 161 comment · 0 complexity · 5b44c9115e8f567df1ee0256f880243f MD5 · raw file

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