Skip to content

Commit

Permalink
send multiple messages
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jan 20, 2014
1 parent 91199a9 commit 30ecf1e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
26 changes: 21 additions & 5 deletions Tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,29 @@ namespace tunnel
{
m_Gateway.SendTunnelDataMsg (gwHash, gwTunnel, msg);
}

void OutboundTunnel::SendTunnelDataMsg (i2p::I2NPMessage * msg)
void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
{
SendTunnelDataMsg (nullptr, 0, msg);
for (auto& it : msgs)
{
switch (it.deliveryType)
{
case eDeliveryTypeLocal:
m_Gateway.SendTunnelDataMsg (nullptr, 0, it.data);
break;
case eDeliveryTypeTunnel:
m_Gateway.SendTunnelDataMsg (it.hash, it.tunnelID, it.data);
break;
case eDeliveryTypeRouter:
m_Gateway.SendTunnelDataMsg (it.hash, 0, it.data);
break;
default:
LogPrint ("Unexpected delivery type ", (int)it.deliveryType);
}
}
m_Gateway.SendBuffer ();
}



Tunnels tunnels;

Tunnels::Tunnels (): m_IsRunning (false), m_IsTunnelCreated (false),
Expand Down
5 changes: 3 additions & 2 deletions Tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <inttypes.h>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <thread>
#include <cryptopp/modes.h>
Expand Down Expand Up @@ -64,9 +65,9 @@ namespace tunnel

OutboundTunnel (TunnelConfig * config): Tunnel (config), m_Gateway (this) {};

void SendTunnelDataMsg (i2p::I2NPMessage * msg); //local
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);

void SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs); // multiple messages

TunnelGateway& GetTunnelGateway () { return m_Gateway; };
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };

Expand Down
3 changes: 2 additions & 1 deletion TunnelBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <inttypes.h>
#include "Timestamp.h"
#include "I2NPProtocol.h"
#include "Identity.h"

namespace i2p
{
Expand All @@ -23,7 +24,7 @@ namespace tunnel
{
TunnelDeliveryType deliveryType;
uint32_t tunnelID;
uint8_t hash[32];
i2p::data::IdentHash hash;
I2NPMessage * data;
};

Expand Down
4 changes: 2 additions & 2 deletions TunnelEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ namespace tunnel
LogPrint ("Delivery type tunnel");
m.tunnelID = be32toh (*(uint32_t *)fragment);
fragment += 4; // tunnelID
memcpy (m.hash, fragment, 32);
m.hash = i2p::data::IdentHash (fragment);
fragment += 32; // hash
break;
case eDeliveryTypeRouter: // 2
LogPrint ("Delivery type router");
memcpy (m.hash, fragment, 32);
m.hash = i2p::data::IdentHash (fragment);
fragment += 32; // to hash
break;
default:
Expand Down

0 comments on commit 30ecf1e

Please sign in to comment.