Browse Source

pass local LeaseSet as const

pull/48/head
orignal 11 years ago
parent
commit
25f2f932b0
  1. 10
      Garlic.cpp
  2. 10
      Garlic.h
  3. 5
      I2NPProtocol.h
  4. 4
      Streaming.cpp
  5. 2
      Streaming.h

10
Garlic.cpp

@ -43,7 +43,7 @@ namespace garlic
} }
} }
I2NPMessage * GarlicRoutingSession::WrapSingleMessage (I2NPMessage * msg, I2NPMessage * leaseSet) I2NPMessage * GarlicRoutingSession::WrapSingleMessage (I2NPMessage * msg, const I2NPMessage * leaseSet)
{ {
I2NPMessage * m = NewI2NPMessage (); I2NPMessage * m = NewI2NPMessage ();
size_t len = 0; size_t len = 0;
@ -89,7 +89,7 @@ namespace garlic
return m; return m;
} }
size_t GarlicRoutingSession::CreateAESBlock (uint8_t * buf, I2NPMessage * msg, I2NPMessage * leaseSet) size_t GarlicRoutingSession::CreateAESBlock (uint8_t * buf, const I2NPMessage * msg, const I2NPMessage * leaseSet)
{ {
size_t blockSize = 0; size_t blockSize = 0;
*(uint16_t *)buf = m_NextTag < 0 ? htobe16 (m_NumTags) : 0; // tag count *(uint16_t *)buf = m_NextTag < 0 ? htobe16 (m_NumTags) : 0; // tag count
@ -116,7 +116,7 @@ namespace garlic
return blockSize; return blockSize;
} }
size_t GarlicRoutingSession::CreateGarlicPayload (uint8_t * payload, I2NPMessage * msg, I2NPMessage * leaseSet) size_t GarlicRoutingSession::CreateGarlicPayload (uint8_t * payload, const I2NPMessage * msg, const I2NPMessage * leaseSet)
{ {
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 5000; // 5 sec uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 5000; // 5 sec
uint32_t msgID = m_Rnd.GenerateWord32 (); uint32_t msgID = m_Rnd.GenerateWord32 ();
@ -153,7 +153,7 @@ namespace garlic
return size; return size;
} }
size_t GarlicRoutingSession::CreateGarlicClove (uint8_t * buf, I2NPMessage * msg, bool isDestination) size_t GarlicRoutingSession::CreateGarlicClove (uint8_t * buf, const I2NPMessage * msg, bool isDestination)
{ {
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 5000; // 5 sec uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 5000; // 5 sec
size_t size = 0; size_t size = 0;
@ -245,7 +245,7 @@ namespace garlic
} }
I2NPMessage * GarlicRouting::WrapMessage (const i2p::data::RoutingDestination& destination, I2NPMessage * GarlicRouting::WrapMessage (const i2p::data::RoutingDestination& destination,
I2NPMessage * msg, I2NPMessage * leaseSet) I2NPMessage * msg, const I2NPMessage * leaseSet)
{ {
auto it = m_Sessions.find (destination.GetIdentHash ()); auto it = m_Sessions.find (destination.GetIdentHash ());
GarlicRoutingSession * session = nullptr; GarlicRoutingSession * session = nullptr;

10
Garlic.h

@ -42,7 +42,7 @@ namespace garlic
GarlicRoutingSession (const i2p::data::RoutingDestination& destination, int numTags); GarlicRoutingSession (const i2p::data::RoutingDestination& destination, int numTags);
~GarlicRoutingSession (); ~GarlicRoutingSession ();
I2NPMessage * WrapSingleMessage (I2NPMessage * msg, I2NPMessage * leaseSet); I2NPMessage * WrapSingleMessage (I2NPMessage * msg, const I2NPMessage * leaseSet);
int GetNextTag () const { return m_NextTag; }; int GetNextTag () const { return m_NextTag; };
uint32_t GetFirstMsgID () const { return m_FirstMsgID; }; uint32_t GetFirstMsgID () const { return m_FirstMsgID; };
@ -51,9 +51,9 @@ namespace garlic
private: private:
size_t CreateAESBlock (uint8_t * buf, I2NPMessage * msg, I2NPMessage * leaseSet); size_t CreateAESBlock (uint8_t * buf, const I2NPMessage * msg, const I2NPMessage * leaseSet);
size_t CreateGarlicPayload (uint8_t * payload, I2NPMessage * msg, I2NPMessage * leaseSet); size_t CreateGarlicPayload (uint8_t * payload, const I2NPMessage * msg, const I2NPMessage * leaseSet);
size_t CreateGarlicClove (uint8_t * buf, I2NPMessage * msg, bool isDestination); size_t CreateGarlicClove (uint8_t * buf, const I2NPMessage * msg, bool isDestination);
size_t CreateDeliveryStatusClove (uint8_t * buf, uint32_t msgID); size_t CreateDeliveryStatusClove (uint8_t * buf, uint32_t msgID);
void GenerateSessionTags (); void GenerateSessionTags ();
@ -86,7 +86,7 @@ namespace garlic
I2NPMessage * WrapSingleMessage (const i2p::data::RoutingDestination& destination, I2NPMessage * msg); I2NPMessage * WrapSingleMessage (const i2p::data::RoutingDestination& destination, I2NPMessage * msg);
I2NPMessage * WrapMessage (const i2p::data::RoutingDestination& destination, I2NPMessage * WrapMessage (const i2p::data::RoutingDestination& destination,
I2NPMessage * msg, I2NPMessage * leaseSet = nullptr); I2NPMessage * msg, const I2NPMessage * leaseSet = nullptr);
private: private:

5
I2NPProtocol.h

@ -103,9 +103,10 @@ namespace tunnel
size_t len, offset; size_t len, offset;
i2p::tunnel::InboundTunnel * from; i2p::tunnel::InboundTunnel * from;
I2NPHeader * GetHeader () { return (I2NPHeader *)(buf + offset); }; I2NPHeader * GetHeader () { return (I2NPHeader *)GetBuffer (); };
uint8_t * GetPayload () { return buf + offset + sizeof(I2NPHeader); }; uint8_t * GetPayload () { return GetBuffer () + sizeof(I2NPHeader); };
uint8_t * GetBuffer () { return buf + offset; }; uint8_t * GetBuffer () { return buf + offset; };
const uint8_t * GetBuffer () const { return buf + offset; };
size_t GetLength () const { return len - offset; }; size_t GetLength () const { return len - offset; };
I2NPMessage& operator=(const I2NPMessage& other) I2NPMessage& operator=(const I2NPMessage& other)

4
Streaming.cpp

@ -264,7 +264,7 @@ namespace stream
bool Stream::SendPacket (uint8_t * packet, size_t size) bool Stream::SendPacket (uint8_t * packet, size_t size)
{ {
I2NPMessage * leaseSet = nullptr; const I2NPMessage * leaseSet = nullptr;
if (m_LeaseSetUpdated) if (m_LeaseSetUpdated)
{ {
leaseSet = m_LocalDestination->GetLeaseSet (); leaseSet = m_LocalDestination->GetLeaseSet ();
@ -367,7 +367,7 @@ namespace stream
it.second->SetLeaseSetUpdated (); it.second->SetLeaseSetUpdated ();
} }
I2NPMessage * StreamingDestination::GetLeaseSet () const I2NPMessage * StreamingDestination::GetLeaseSet ()
{ {
if (!m_LeaseSet) if (!m_LeaseSet)
m_LeaseSet = CreateLeaseSet (); m_LeaseSet = CreateLeaseSet ();

2
Streaming.h

@ -112,7 +112,7 @@ namespace stream
const i2p::data::PrivateKeys& GetKeys () const { return m_Keys; }; const i2p::data::PrivateKeys& GetKeys () const { return m_Keys; };
const i2p::data::Identity& GetIdentity () const { return m_Keys.pub; }; const i2p::data::Identity& GetIdentity () const { return m_Keys.pub; };
I2NPMessage * GetLeaseSet (); const I2NPMessage * GetLeaseSet ();
i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; }; i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; };
void Sign (uint8_t * buf, int len, uint8_t * signature) const; void Sign (uint8_t * buf, int len, uint8_t * signature) const;

Loading…
Cancel
Save