mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
receive incoming SSU2 packets
This commit is contained in:
parent
b3c2e86436
commit
7b72d91549
2 changed files with 45 additions and 1 deletions
|
@ -24,6 +24,7 @@ namespace transport
|
|||
const int SSU2_TERMINATION_TIMEOUT = 330; // 5.5 minutes
|
||||
const size_t SSU2_SOCKET_RECEIVE_BUFFER_SIZE = 0x1FFFF; // 128K
|
||||
const size_t SSU2_SOCKET_SEND_BUFFER_SIZE = 0x1FFFF; // 128K
|
||||
const size_t SSU2_MTU = 1488;
|
||||
|
||||
enum SSU2MessageType
|
||||
{
|
||||
|
@ -78,6 +79,13 @@ namespace transport
|
|||
|
||||
class SSU2Server: private i2p::util::RunnableServiceWithWork
|
||||
{
|
||||
struct Packet
|
||||
{
|
||||
uint8_t buf[SSU2_MTU];
|
||||
size_t len;
|
||||
boost::asio::ip::udp::endpoint from;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
SSU2Server ();
|
||||
|
@ -96,6 +104,8 @@ namespace transport
|
|||
private:
|
||||
|
||||
void OpenSocket (int port);
|
||||
void Receive ();
|
||||
void HandleReceivedFrom (const boost::system::error_code& ecode, size_t bytes_transferred, Packet * packet);
|
||||
void ProcessNextPacket (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
||||
|
||||
private:
|
||||
|
@ -103,6 +113,7 @@ namespace transport
|
|||
boost::asio::ip::udp::socket m_Socket;
|
||||
std::unordered_map<uint64_t, std::shared_ptr<SSU2Session> > m_Sessions;
|
||||
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSU2Session> > m_PendingOutgoingSessions;
|
||||
i2p::util::MemoryPoolMt<Packet> m_PacketsPool;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue