| 2423 | } |
| 2424 | |
| 2425 | std::shared_ptr<I2NPMessage> StreamingDestination::CreateDataMessage ( |
| 2426 | const uint8_t * payload, size_t len, uint16_t toPort, bool checksum, bool gzip) |
| 2427 | { |
| 2428 | size_t size; |
| 2429 | auto msg = (len <= STREAMING_MTU_RATCHETS) ? m_I2NPMsgsPool.AcquireShared () : NewI2NPMessage (); |
| 2430 | uint8_t * buf = msg->GetPayload (); |
| 2431 | buf += 4; // reserve for lengthlength |
| 2432 | msg->len += 4; |
| 2433 | |
| 2434 | if (m_Gzip || gzip) |
| 2435 | size = m_Deflator.Deflate (payload, len, buf, msg->maxLen - msg->len); |
| 2436 | else |
| 2437 | size = i2p::data::GzipNoCompression (payload, len, buf, msg->maxLen - msg->len); |
| 2438 | |
| 2439 | if (size) |
| 2440 | { |
| 2441 | htobe32buf (msg->GetPayload (), size); // length |
| 2442 | htobe16buf (buf + 4, m_LocalPort); // source port |
| 2443 | htobe16buf (buf + 6, toPort); // destination port |
| 2444 | buf[9] = i2p::client::PROTOCOL_TYPE_STREAMING; // streaming protocol |
| 2445 | msg->len += size; |
| 2446 | msg->FillI2NPMessageHeader (eI2NPData, 0, checksum); |
| 2447 | } |
| 2448 | else |
| 2449 | msg = nullptr; |
| 2450 | return msg; |
| 2451 | } |
| 2452 | |
| 2453 | uint32_t StreamingDestination::GetRandom () |
| 2454 | { |
no test coverage detected