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

Method HandleI2PRawDatagramReceive

libi2pd_client/SAM.cpp:1322–1348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1320 }
1321
1322 void SAMSocket::HandleI2PRawDatagramReceive (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)
1323 {
1324 LogPrint (eLogDebug, "SAM: Raw datagram received ", len);
1325 auto session = m_Owner.FindSession(m_ID);
1326 if(session)
1327 {
1328 auto ep = session->UDPEndpoint;
1329 if (ep)
1330 // udp forward enabled
1331 m_Owner.SendTo({ {buf, len} }, *ep);
1332 else
1333 {
1334#ifdef _MSC_VER
1335 size_t l = sprintf_s ((char *)m_StreamBuffer, SAM_STREAM_BUFFER_SIZE, SAM_RAW_RECEIVED, (long unsigned int)len);
1336#else
1337 size_t l = snprintf ((char *)m_StreamBuffer, SAM_STREAM_BUFFER_SIZE, SAM_RAW_RECEIVED, (long unsigned int)len);
1338#endif
1339 if (len < SAM_STREAM_BUFFER_SIZE - l)
1340 {
1341 memcpy (m_StreamBuffer + l, buf, len);
1342 WriteI2PData(len + l);
1343 }
1344 else
1345 LogPrint (eLogWarning, "SAM: Received raw datagram size ", len," exceeds buffer");
1346 }
1347 }
1348 }
1349
1350 void SAMSocket::HandleStreamSend(const boost::system::error_code & ec)
1351 {

Callers

nothing calls this directly

Calls 3

LogPrintFunction · 0.85
FindSessionMethod · 0.45
SendToMethod · 0.45

Tested by

no test coverage detected