From d9218134e24ac2c0489e77d0a96cab16e40e5a3f Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 3 Mar 2015 15:31:49 -0500 Subject: [PATCH] pass source and destination ports to datagram receiver --- Datagram.cpp | 2 +- Datagram.h | 2 +- SAM.cpp | 6 +++--- SAM.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Datagram.cpp b/Datagram.cpp index 9a44f2d3..412ef318 100644 --- a/Datagram.cpp +++ b/Datagram.cpp @@ -83,7 +83,7 @@ namespace datagram if (verified) { if (m_Receiver != nullptr) - m_Receiver (identity, buf + headerLen, len -headerLen); + m_Receiver (identity, fromPort, toPort, buf + headerLen, len -headerLen); else LogPrint (eLogWarning, "Receiver for datagram is not set"); } diff --git a/Datagram.h b/Datagram.h index 0d8aafba..7df5e3cd 100644 --- a/Datagram.h +++ b/Datagram.h @@ -19,7 +19,7 @@ namespace datagram const size_t MAX_DATAGRAM_SIZE = 32768; class DatagramDestination { - typedef std::function Receiver; + typedef std::function Receiver; public: diff --git a/SAM.cpp b/SAM.cpp index 5f4c23af..dea72ad3 100644 --- a/SAM.cpp +++ b/SAM.cpp @@ -259,7 +259,7 @@ namespace client { auto dest = m_Session->localDestination->CreateDatagramDestination (); dest->SetReceiver (std::bind (&SAMSocket::HandleI2PDatagramReceive, shared_from_this (), - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); } SendSessionCreateReplyOk (); } @@ -577,9 +577,9 @@ namespace client LogPrint (eLogInfo, "SAM I2P acceptor has been reset"); } - void SAMSocket::HandleI2PDatagramReceive (const i2p::data::IdentityEx& ident, const uint8_t * buf, size_t len) + void SAMSocket::HandleI2PDatagramReceive (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len) { - auto base64 = ident.ToBase64 (); + auto base64 = from.ToBase64 (); #ifdef _MSC_VER size_t l = sprintf_s ((char *)m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE, SAM_DATAGRAM_RECEIVED, base64.c_str (), len); #else diff --git a/SAM.h b/SAM.h index 5bc1320a..8c364814 100644 --- a/SAM.h +++ b/SAM.h @@ -96,7 +96,7 @@ namespace client void HandleI2PReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred); void HandleI2PAccept (std::shared_ptr stream); void HandleWriteI2PData (const boost::system::error_code& ecode); - void HandleI2PDatagramReceive (const i2p::data::IdentityEx& ident, const uint8_t * buf, size_t len); + void HandleI2PDatagramReceive (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len); void ProcessSessionCreate (char * buf, size_t len); void ProcessStreamConnect (char * buf, size_t len);