MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / CreateRouterInfoDatabaseLookupMsg

Function CreateRouterInfoDatabaseLookupMsg

libi2pd/I2NPProtocol.cpp:144–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142 }
143
144 std::shared_ptr<I2NPMessage> CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
145 uint32_t replyTunnelID, bool exploratory, std::unordered_set<i2p::data::IdentHash> * excludedPeers)
146 {
147 int cnt = excludedPeers ? excludedPeers->size () : 0;
148 auto m = cnt > 7 ? NewI2NPMessage () : NewI2NPShortMessage ();
149 uint8_t * buf = m->GetPayload ();
150 memcpy (buf, key, 32); // key
151 buf += 32;
152 memcpy (buf, from, 32); // from
153 buf += 32;
154 uint8_t flag = exploratory ? DATABASE_LOOKUP_TYPE_EXPLORATORY_LOOKUP : DATABASE_LOOKUP_TYPE_ROUTERINFO_LOOKUP;
155 if (replyTunnelID)
156 {
157 *buf = flag | DATABASE_LOOKUP_DELIVERY_FLAG; // set delivery flag
158 htobe32buf (buf+1, replyTunnelID);
159 buf += 5;
160 }
161 else
162 {
163 *buf = flag; // flag
164 buf++;
165 }
166
167 if (excludedPeers)
168 {
169 htobe16buf (buf, cnt);
170 buf += 2;
171 for (auto& it: *excludedPeers)
172 {
173 memcpy (buf, it, 32);
174 buf += 32;
175 }
176 }
177 else
178 {
179 // nothing to exclude
180 htobuf16 (buf, 0);
181 buf += 2;
182 }
183
184 m->len += (buf - m->GetPayload ());
185 m->FillI2NPMessageHeader (eI2NPDatabaseLookup);
186 return m;
187 }
188
189 std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
190 const std::unordered_set<i2p::data::IdentHash>& excludedFloodfills,

Callers 2

CreateRequestMessageMethod · 0.85
ReseedFromFloodfillMethod · 0.85

Calls 7

NewI2NPMessageFunction · 0.85
NewI2NPShortMessageFunction · 0.85
htobe32bufFunction · 0.85
htobe16bufFunction · 0.85
htobuf16Function · 0.85
FillI2NPMessageHeaderMethod · 0.80
GetPayloadMethod · 0.45

Tested by

no test coverage detected