From 01a4e696b3d2c973cdd1fb4345d747bd10e93ad9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 8 Mar 2021 16:37:36 +0000 Subject: Do protocol decryption in-place (with CryptoAPI on Windows) (#5145) --- src/Protocol/Protocol_1_8.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Protocol/Protocol_1_8.h') diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h index e2aadf147..29bc7420c 100644 --- a/src/Protocol/Protocol_1_8.h +++ b/src/Protocol/Protocol_1_8.h @@ -36,8 +36,9 @@ public: cProtocol_1_8_0(cClientHandle * a_Client, const AString & a_ServerAddress, State a_State); - /** Called when client sends some data: */ - virtual void DataReceived(cByteBuffer & a_Buffer, const char * a_Data, size_t a_Size) override; + /** Called to process them, when client sends some data. + The protocol uses the provided buffers for storage and processing, and must have exclusive access to them. */ + virtual void DataReceived(cByteBuffer & a_Buffer, ContiguousByteBuffer && a_Data) override; /** Sending stuff to clients (alphabetically sorted): */ virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) override; @@ -146,9 +147,6 @@ protected: /** State of the protocol. */ State m_State; - /** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */ - virtual void AddReceivedData(cByteBuffer & a_Buffer, const char * a_Data, size_t a_Size); - /** Nobody inherits 1.8, so it doesn't use this method */ virtual UInt32 GetPacketID(ePacketType a_Packet) override; @@ -257,6 +255,9 @@ private: /** The logfile where the comm is logged, when g_ShouldLogComm is true */ cFile m_CommLogFile; + /** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */ + void AddReceivedData(cByteBuffer & a_Buffer, ContiguousByteBufferView a_Data); + /** Handle a complete packet stored in the given buffer. */ void HandlePacket(cByteBuffer & a_Buffer); -- cgit v1.2.3