From 4831e9705c088d5a15f06592d7bf30ae6fe43d4a Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 26 Mar 2015 14:35:20 -0400 Subject: [PATCH] const buffer for ProcessPeerTest --- SSUSession.cpp | 10 +++++----- SSUSession.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SSUSession.cpp b/SSUSession.cpp index 37fd259e..5b3e9cb2 100644 --- a/SSUSession.cpp +++ b/SSUSession.cpp @@ -880,9 +880,9 @@ namespace transport } } - void SSUSession::ProcessPeerTest (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint) + void SSUSession::ProcessPeerTest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint) { - uint8_t * buf1 = buf; + const uint8_t * buf1 = buf; uint32_t nonce = bufbe32toh (buf); buf += 4; // nonce uint8_t size = *buf; @@ -892,7 +892,7 @@ namespace transport buf += size; // address uint16_t port = buf16toh(buf); // use it as is buf += 2; // port - uint8_t * introKey = buf; + const uint8_t * introKey = buf; if (port && !address) { LogPrint (eLogWarning, "Address of ", size, " bytes not supported"); @@ -935,19 +935,19 @@ namespace transport case ePeerTestParticipantBob: { LogPrint (eLogDebug, "SSU peer test from Charlie. We are Bob"); - m_Server.RemovePeerTest (nonce); // nonce has been used boost::asio::ip::udp::endpoint ep (boost::asio::ip::address_v4 (be32toh (address)), be16toh (port)); // Alice's address/port auto session = m_Server.FindSession (ep); // find session with Alice if (session) session->Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Alice + m_Server.RemovePeerTest (nonce); // nonce has been used break; } case ePeerTestParticipantCharlie: { LogPrint (eLogDebug, "SSU peer test from Alice. We are Charlie"); - m_Server.RemovePeerTest (nonce); // nonce has been used SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), senderEndpoint.port (), introKey); // to Alice with her actual address + m_Server.RemovePeerTest (nonce); // nonce has been used break; } // test not found diff --git a/SSUSession.h b/SSUSession.h index 82fa0f33..5f980784 100644 --- a/SSUSession.h +++ b/SSUSession.h @@ -115,7 +115,7 @@ namespace transport void Failed (); void ScheduleConnectTimer (); void HandleConnectTimer (const boost::system::error_code& ecode); - void ProcessPeerTest (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint); + void ProcessPeerTest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint); void SendPeerTest (uint32_t nonce, uint32_t address, uint16_t port, const uint8_t * introKey, bool toAddress = true, bool sendAddress = true); void ProcessData (uint8_t * buf, size_t len); void SendSesionDestroyed ();