diff options
author | eihrul <eihrul> | 2010-05-20 16:55:27 +0000 |
---|---|---|
committer | eihrul <eihrul> | 2010-05-20 16:55:27 +0000 |
commit | e49aaf7a6fe63937e56f2efaebad3f37574fd93f (patch) | |
tree | 28e11eb3d8c633f81fa81f1019131b898c21b995 /protocol.c | |
parent | 72525fbca19d4a643ae1e0547947d4d6fa32f4b4 (diff) | |
download | enet-e49aaf7a6fe63937e56f2efaebad3f37574fd93f.tar.gz enet-e49aaf7a6fe63937e56f2efaebad3f37574fd93f.zip |
checksum is now a run-time option
Diffstat (limited to 'protocol.c')
-rw-r--r-- | protocol.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -245,9 +245,9 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet ENetPeer * currentPeer; ENetProtocol verifyCommand; -#ifdef USE_CRC32 + if (host -> checksum != NULL) { - enet_uint32 crc = header -> checksum; + enet_uint32 checksum = header -> checksum; ENetBuffer buffer; command -> header.reliableSequenceNumber = ENET_HOST_TO_NET_16 (command -> header.reliableSequenceNumber); @@ -257,12 +257,11 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet buffer.data = host -> receivedData; buffer.dataLength = host -> receivedDataLength; - if (enet_crc32 (& buffer, 1) != crc) + if (host -> checksum (& buffer, 1) != checksum) return NULL; command -> header.reliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> header.reliableSequenceNumber); } -#endif channelCount = ENET_NET_TO_HOST_32 (command -> connect.channelCount); @@ -834,9 +833,9 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) peer -> address.host != ENET_HOST_BROADCAST)) return 0; -#ifdef USE_CRC32 + if (host -> checksum != NULL) { - enet_uint32 crc = header -> checksum; + enet_uint32 checksum = header -> checksum; ENetBuffer buffer; header -> checksum = peer -> sessionID; @@ -844,13 +843,12 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) buffer.data = host -> receivedData; buffer.dataLength = host -> receivedDataLength; - if (enet_crc32 (& buffer, 1) != crc) + if (host -> checksum (& buffer, 1) != checksum) return 0; } -#else + else if (header -> checksum != peer -> sessionID) return 0; -#endif peer -> address.host = host -> receivedAddress.host; peer -> address.port = host -> receivedAddress.port; @@ -1415,9 +1413,8 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch else host -> buffers -> dataLength = (size_t) & ((ENetProtocolHeader *) 0) -> sentTime; -#ifdef USE_CRC32 - header.checksum = enet_crc32 (host -> buffers, host -> bufferCount); -#endif + if (host -> checksum != NULL) + header.checksum = host -> checksum (host -> buffers, host -> bufferCount); currentPeer -> lastSendTime = host -> serviceTime; |