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

Method CreatePaddingBlock

libi2pd/SSU2Session.cpp:3031–3041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3029 }
3030
3031 size_t SSU2Session::CreatePaddingBlock (uint8_t * buf, size_t len, size_t minSize)
3032 {
3033 if (len < 3 || len < minSize) return 0;
3034 size_t paddingSize = m_Server.GetRng ()() & 0x1F; // 0 - 31
3035 if (paddingSize + 3 > len) paddingSize = len - 3;
3036 else if (paddingSize + 3 < minSize) paddingSize = minSize - 3;
3037 buf[0] = eSSU2BlkPadding;
3038 htobe16buf (buf + 1, paddingSize);
3039 memset (buf + 3, 0, paddingSize);
3040 return paddingSize + 3;
3041 }
3042
3043 size_t SSU2Session::CreateI2NPBlock (uint8_t * buf, size_t len, std::shared_ptr<I2NPMessage>&& msg)
3044 {

Callers 1

SendLocalRouterInfoMethod · 0.45

Calls 1

htobe16bufFunction · 0.85

Tested by

no test coverage detected