2016-05-12 21:37:46 +02:00
|
|
|
#ifndef I2CP_H__
|
|
|
|
#define I2CP_H__
|
|
|
|
|
2016-05-12 22:17:10 +02:00
|
|
|
#include <inttypes.h>
|
2016-05-12 21:37:46 +02:00
|
|
|
#include <string>
|
2016-05-12 22:17:10 +02:00
|
|
|
#include <memory>
|
2016-05-12 21:37:46 +02:00
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace client
|
|
|
|
{
|
2016-05-12 22:17:10 +02:00
|
|
|
const uint8_t I2CP_PRTOCOL_BYTE = 0x2A;
|
|
|
|
const size_t I2CP_SESSION_BUFFER_SIZE = 8192;
|
|
|
|
|
|
|
|
class I2CPSession: public std::enable_shared_from_this<I2CPSession>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
I2CPSession (std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void ReadProtocolByte ();
|
|
|
|
void Receive ();
|
|
|
|
void HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
|
|
|
void Terminate ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
|
|
|
uint8_t m_Buffer[I2CP_SESSION_BUFFER_SIZE];
|
|
|
|
};
|
|
|
|
|
2016-05-12 21:37:46 +02:00
|
|
|
class I2CPServer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
I2CPServer (const std::string& interface, int port);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|