MCPcopy Create free account
hub / github.com/ddnet/ddnet / StunMessagePrepare

Function StunMessagePrepare

src/engine/shared/stun.cpp:19–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
18
19size_t StunMessagePrepare(unsigned char *pBuffer, size_t BufferSize, CStunData *pData)
20{
21 dbg_assert(BufferSize >= 20, "stun message buffer too small");
22 secure_random_fill(pData->m_aSecret, sizeof(pData->m_aSecret));
23 pBuffer[0] = 0x00; // STUN Request Message Type 1: Binding
24 pBuffer[1] = 0x01;
25 pBuffer[2] = 0x00; // Message Length: 0 (extra bytes after the header)
26 pBuffer[3] = 0x00;
27 pBuffer[4] = 0x21; // Magic Cookie: 0x2112A442
28 pBuffer[5] = 0x12;
29 pBuffer[6] = 0xA4;
30 pBuffer[7] = 0x42;
31 mem_copy(pBuffer + 8, pData->m_aSecret, sizeof(pData->m_aSecret)); // Transaction ID
32 return 20;
33}
34
35bool StunMessageParse(const unsigned char *pMessage, size_t MessageSize, const CStunData *pData, bool *pSuccess, NETADDR *pAddr)
36{

Callers 3

mainFunction · 0.85
CProtocolMethod · 0.85
UpdateMethod · 0.85

Calls 2

secure_random_fillFunction · 0.85
mem_copyFunction · 0.85

Tested by

no test coverage detected