Skip to content

Commit

Permalink
moved transports to 'transport' namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 21, 2014
1 parent 165af09 commit 7b768cc
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace i2p
LogPrint("HTTP Server started");
i2p::data::netdb.Start();
LogPrint("NetDB started");
i2p::transports.Start();
i2p::transport::transports.Start();
LogPrint("Transports started");
i2p::tunnel::tunnels.Start();
LogPrint("Tunnels started");
Expand All @@ -120,7 +120,7 @@ namespace i2p
LogPrint("Client stoped");
i2p::tunnel::tunnels.Stop();
LogPrint("Tunnels stoped");
i2p::transports.Stop();
i2p::transport::transports.Stop();
LogPrint("Transports stoped");
i2p::data::netdb.Stop();
LogPrint("NetDB stoped");
Expand Down
4 changes: 2 additions & 2 deletions HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ namespace util
void HTTPConnection::ShowTransports (std::stringstream& s)
{
s << "NTCP<br>";
for (auto it: i2p::transports.GetNTCPSessions ())
for (auto it: i2p::transport::transports.GetNTCPSessions ())
{
// RouterInfo of incoming connection doesn't have address
bool outgoing = it.second->GetRemoteRouterInfo ().GetNTCPAddress ();
Expand All @@ -714,7 +714,7 @@ namespace util
}
s << std::endl;
}
auto ssuServer = i2p::transports.GetSSUServer ();
auto ssuServer = i2p::transport::transports.GetSSUServer ();
if (ssuServer)
{
s << "<br>SSU<br>";
Expand Down
11 changes: 6 additions & 5 deletions I2NPProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
#include "Garlic.h"
#include "I2NPProtocol.h"

using namespace i2p::transport;

namespace i2p
{

I2NPMessage * NewI2NPMessage ()
{
return new I2NPMessageBuffer<I2NP_MAX_MESSAGE_SIZE>();
Expand Down Expand Up @@ -353,13 +354,13 @@ namespace i2p
if (clearText.flag & 0x40) // we are endpoint of outboud tunnel
{
// so we send it to reply tunnel
i2p::transports.SendMessage (clearText.nextIdent,
transports.SendMessage (clearText.nextIdent,
CreateTunnelGatewayMsg (be32toh (clearText.nextTunnel),
eI2NPVariableTunnelBuildReply, buf, len,
be32toh (clearText.nextMessageID)));
}
else
i2p::transports.SendMessage (clearText.nextIdent,
transports.SendMessage (clearText.nextIdent,
CreateI2NPMessage (eI2NPVariableTunnelBuild, buf, len, be32toh (clearText.nextMessageID)));
}
}
Expand All @@ -373,13 +374,13 @@ namespace i2p
if (clearText.flag & 0x40) // we are endpoint of outbound tunnel
{
// so we send it to reply tunnel
i2p::transports.SendMessage (clearText.nextIdent,
transports.SendMessage (clearText.nextIdent,
CreateTunnelGatewayMsg (be32toh (clearText.nextTunnel),
eI2NPTunnelBuildReply, buf, len,
be32toh (clearText.nextMessageID)));
}
else
i2p::transports.SendMessage (clearText.nextIdent,
transports.SendMessage (clearText.nextIdent,
CreateI2NPMessage (eI2NPTunnelBuild, buf, len, be32toh (clearText.nextMessageID)));
}
}
Expand Down
18 changes: 9 additions & 9 deletions NTCPSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ using namespace i2p::crypto;

namespace i2p
{
namespace ntcp
namespace transport
{
NTCPSession::NTCPSession (boost::asio::io_service& service, i2p::data::RouterInfo& in_RemoteRouterInfo):
m_Socket (service), m_TerminationTimer (service), m_IsEstablished (false),
m_RemoteRouterInfo (in_RemoteRouterInfo), m_ReceiveBufferOffset (0),
m_NextMessage (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0)
{
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
m_DHKeysPair = transports.GetNextDHKeysPair ();
m_Establisher = new Establisher;
}

Expand Down Expand Up @@ -77,12 +77,12 @@ namespace ntcp
{
m_IsEstablished = false;
m_Socket.close ();
i2p::transports.RemoveNTCPSession (this);
transports.RemoveNTCPSession (this);
int numDelayed = 0;
for (auto it :m_DelayedMessages)
{
// try to send them again
i2p::transports.SendMessage (m_RemoteRouterInfo.GetIdentHash (), it);
transports.SendMessage (m_RemoteRouterInfo.GetIdentHash (), it);
numDelayed++;
}
m_DelayedMessages.clear ();
Expand Down Expand Up @@ -119,7 +119,7 @@ namespace ntcp
void NTCPSession::ClientLogin ()
{
if (!m_DHKeysPair)
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
m_DHKeysPair = transports.GetNextDHKeysPair ();
// send Phase1
const uint8_t * x = m_DHKeysPair->publicKey;
memcpy (m_Establisher->phase1.pubKey, x, 256);
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace ntcp
void NTCPSession::SendPhase2 ()
{
if (!m_DHKeysPair)
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
m_DHKeysPair = transports.GetNextDHKeysPair ();
const uint8_t * y = m_DHKeysPair->publicKey;
memcpy (m_Establisher->phase2.pubKey, y, 256);
uint8_t xy[512];
Expand Down Expand Up @@ -238,7 +238,7 @@ namespace ntcp
if (ecode != boost::asio::error::operation_aborted)
{
GetRemoteRouterInfo ().SetUnreachable (true); // this RouterInfo is not valid
i2p::transports.ReuseDHKeysPair (m_DHKeysPair);
transports.ReuseDHKeysPair (m_DHKeysPair);
m_DHKeysPair = nullptr;
Terminate ();
}
Expand All @@ -263,7 +263,7 @@ namespace ntcp
if (memcmp (hxy, m_Establisher->phase2.encrypted.hxy, 32))
{
LogPrint ("Incorrect hash");
i2p::transports.ReuseDHKeysPair (m_DHKeysPair);
transports.ReuseDHKeysPair (m_DHKeysPair);
m_DHKeysPair = nullptr;
Terminate ();
return ;
Expand Down Expand Up @@ -635,7 +635,7 @@ namespace ntcp
{
LogPrint ("NTCP server session connected");
SetIsEstablished (true);
i2p::transports.AddNTCPSession (this);
transports.AddNTCPSession (this);

SendTimeSyncMessage ();
SendI2NPMessage (CreateDatabaseStoreMsg ()); // we tell immediately who we are
Expand Down
4 changes: 2 additions & 2 deletions NTCPSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace i2p
{
namespace ntcp
namespace transport
{

#pragma pack(1)
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace ntcp
const size_t NTCP_BUFFER_SIZE = 1040; // fits one tunnel message (1028)
const int NTCP_TERMINATION_TIMEOUT = 120; // 2 minutes

class NTCPSession: public i2p::transport::TransportSession
class NTCPSession: public TransportSession
{
public:

Expand Down
10 changes: 6 additions & 4 deletions NetDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Reseed.h"
#include "util.h"

using namespace i2p::transport;

namespace i2p
{
namespace data
Expand Down Expand Up @@ -403,7 +405,7 @@ namespace data
RequestedDestination * dest = CreateRequestedDestination (destination, false, false, pool);
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ());
if (floodfill)
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
}
}

Expand Down Expand Up @@ -655,10 +657,10 @@ namespace data
if (outbound)
outbound->SendTunnelDataMsg (buf+32, replyTunnelID, replyMsg);
else
i2p::transports.SendMessage (buf+32, i2p::CreateTunnelGatewayMsg (replyTunnelID, replyMsg));
transports.SendMessage (buf+32, i2p::CreateTunnelGatewayMsg (replyTunnelID, replyMsg));
}
else
i2p::transports.SendMessage (buf+32, replyMsg);
transports.SendMessage (buf+32, replyMsg);
}
i2p::DeleteI2NPMessage (msg);
}
Expand Down Expand Up @@ -712,7 +714,7 @@ namespace data
});
}
else
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
i2p::transport::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
}
else
DeleteRequestedDestination (dest);
Expand Down
6 changes: 3 additions & 3 deletions SSU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace i2p
{
namespace ssu
namespace transport
{

SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
Expand Down Expand Up @@ -173,7 +173,7 @@ namespace ssu
LogPrint ("Session request received");
m_RemoteEndpoint = senderEndpoint;
if (!m_DHKeysPair)
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
m_DHKeysPair = transports.GetNextDHKeysPair ();
CreateAESandMacKey (buf + sizeof (SSUHeader));
SendSessionCreated (buf + sizeof (SSUHeader));
}
Expand Down Expand Up @@ -608,7 +608,7 @@ namespace ssu
{
// set connect timer
ScheduleConnectTimer ();
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
m_DHKeysPair = transports.GetNextDHKeysPair ();
SendSessionRequest ();
}
}
Expand Down
4 changes: 2 additions & 2 deletions SSU.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace i2p
{
namespace ssu
namespace transport
{
#pragma pack(1)
struct SSUHeader
Expand Down Expand Up @@ -58,7 +58,7 @@ namespace ssu
};

class SSUServer;
class SSUSession: public i2p::transport::TransportSession
class SSUSession: public TransportSession
{
public:

Expand Down
2 changes: 1 addition & 1 deletion SSUData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace i2p
{
namespace ssu
namespace transport
{
SSUData::SSUData (SSUSession& session):
m_Session (session), m_ResendTimer (session.m_Server.GetService ())
Expand Down
2 changes: 1 addition & 1 deletion SSUData.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace i2p
{
namespace ssu
namespace transport
{

const size_t SSU_MTU = 1484;
Expand Down
2 changes: 1 addition & 1 deletion TransitTunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace tunnel
*(uint32_t *)(tunnelMsg->GetPayload ()) = htobe32 (m_NextTunnelID);
FillI2NPMessageHeader (tunnelMsg, eI2NPTunnelData);

i2p::transports.SendMessage (m_NextIdent, tunnelMsg);
i2p::transport::transports.SendMessage (m_NextIdent, tunnelMsg);
}

void TransitTunnel::SendTunnelDataMsg (i2p::I2NPMessage * msg)
Expand Down
Loading

0 comments on commit 7b768cc

Please sign in to comment.