From c5644e0e32d799d59c3de6df1ecbf18598c870ca Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 3 Jul 2015 21:27:40 -0400 Subject: [PATCH] const I2NP messages --- NetDb.cpp | 20 ++++++++++---------- NetDb.h | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/NetDb.cpp b/NetDb.cpp index dad122a2..39dd6430 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -453,7 +453,7 @@ namespace data } } - void NetDb::HandleDatabaseStoreMsg (std::shared_ptr m) + void NetDb::HandleDatabaseStoreMsg (std::shared_ptr m) { const uint8_t * buf = m->GetPayload (); size_t len = m->GetSize (); @@ -540,9 +540,9 @@ namespace data } } - void NetDb::HandleDatabaseSearchReplyMsg (std::shared_ptr msg) + void NetDb::HandleDatabaseSearchReplyMsg (std::shared_ptr msg) { - uint8_t * buf = msg->GetPayload (); + const uint8_t * buf = msg->GetPayload (); char key[48]; int l = i2p::data::ByteStreamToBase64 (buf, 32, key, 48); key[l] = 0; @@ -611,7 +611,7 @@ namespace data // try responses for (int i = 0; i < num; i++) { - uint8_t * router = buf + 33 + i*32; + const uint8_t * router = buf + 33 + i*32; char peerHash[48]; int l1 = i2p::data::ByteStreamToBase64 (router, 32, peerHash, 48); peerHash[l1] = 0; @@ -629,9 +629,9 @@ namespace data } } - void NetDb::HandleDatabaseLookupMsg (std::shared_ptr msg) + void NetDb::HandleDatabaseLookupMsg (std::shared_ptr msg) { - uint8_t * buf = msg->GetPayload (); + const uint8_t * buf = msg->GetPayload (); IdentHash ident (buf); if (ident.IsZero ()) { @@ -644,7 +644,7 @@ namespace data uint8_t flag = buf[64]; LogPrint ("DatabaseLookup for ", key, " recieved flags=", (int)flag); uint8_t lookupType = flag & DATABASE_LOOKUP_TYPE_FLAGS_MASK; - uint8_t * excluded = buf + 65; + const uint8_t * excluded = buf + 65; uint32_t replyTunnelID = 0; if (flag & DATABASE_LOOKUP_DELIVERY_FLAG) //reply to tunnel { @@ -727,11 +727,11 @@ namespace data // encryption might be used though tunnel only if (flag & DATABASE_LOOKUP_ENCYPTION_FLAG) // encrypted reply requested { - uint8_t * sessionKey = excluded; + const uint8_t * sessionKey = excluded; uint8_t numTags = sessionKey[32]; if (numTags > 0) { - uint8_t * sessionTag = sessionKey + 33; // take first tag + const uint8_t * sessionTag = sessionKey + 33; // take first tag i2p::garlic::GarlicRoutingSession garlic (sessionKey, sessionTag); replyMsg = garlic.WrapSingleMessage (replyMsg); } @@ -890,7 +890,7 @@ namespace data return nullptr; // seems we have too few routers } - void NetDb::PostI2NPMsg (std::shared_ptr msg) + void NetDb::PostI2NPMsg (std::shared_ptr msg) { if (msg) m_Queue.Put (msg); } diff --git a/NetDb.h b/NetDb.h index adeee675..71db2e52 100644 --- a/NetDb.h +++ b/NetDb.h @@ -41,9 +41,9 @@ namespace data void RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete = nullptr); - void HandleDatabaseStoreMsg (std::shared_ptr msg); - void HandleDatabaseSearchReplyMsg (std::shared_ptr msg); - void HandleDatabaseLookupMsg (std::shared_ptr msg); + void HandleDatabaseStoreMsg (std::shared_ptr msg); + void HandleDatabaseSearchReplyMsg (std::shared_ptr msg); + void HandleDatabaseLookupMsg (std::shared_ptr msg); std::shared_ptr GetRandomRouter () const; std::shared_ptr GetRandomRouter (std::shared_ptr compatibleWith) const; @@ -56,7 +56,7 @@ namespace data std::shared_ptr GetClosestNonFloodfill (const IdentHash& destination, const std::set& excluded) const; void SetUnreachable (const IdentHash& ident, bool unreachable); - void PostI2NPMsg (std::shared_ptr msg); + void PostI2NPMsg (std::shared_ptr msg); void Reseed (); @@ -89,7 +89,7 @@ namespace data bool m_IsRunning; std::thread * m_Thread; - i2p::util::Queue > m_Queue; // of I2NPDatabaseStoreMsg + i2p::util::Queue > m_Queue; // of I2NPDatabaseStoreMsg Reseeder * m_Reseeder;