| 453 | } |
| 454 | |
| 455 | std::shared_ptr<I2NPMessage> DatagramDestination::CreateDataMessage ( |
| 456 | const std::vector<std::pair<const uint8_t *, size_t> >& payloads, |
| 457 | uint16_t fromPort, uint16_t toPort, uint8_t protocolType, bool checksum) |
| 458 | { |
| 459 | size_t size; |
| 460 | auto msg = m_I2NPMsgsPool.AcquireShared (); |
| 461 | uint8_t * buf = msg->GetPayload (); |
| 462 | buf += 4; // reserve for length |
| 463 | |
| 464 | if (m_Gzip && m_Deflator) |
| 465 | size = m_Deflator->Deflate (payloads, buf, msg->maxLen - msg->len); |
| 466 | else |
| 467 | size = i2p::data::GzipNoCompression (payloads, buf, msg->maxLen - msg->len); |
| 468 | |
| 469 | if (size) |
| 470 | { |
| 471 | htobe32buf (msg->GetPayload (), size); // length |
| 472 | htobe16buf (buf + 4, fromPort); // source port |
| 473 | htobe16buf (buf + 6, toPort); // destination port |
| 474 | buf[9] = protocolType; // raw or datagram protocol |
| 475 | msg->len += size + 4; |
| 476 | msg->FillI2NPMessageHeader (eI2NPData, 0, checksum); |
| 477 | } |
| 478 | else |
| 479 | msg = nullptr; |
| 480 | return msg; |
| 481 | } |
| 482 | |
| 483 | void DatagramDestination::CleanUp () |
| 484 | { |
nothing calls this directly
no test coverage detected