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

Method OnPacket

src/engine/shared/network_stun.cpp:82–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82bool CStun::CProtocol::OnPacket(NETADDR Addr, unsigned char *pData, int DataSize)
83{
84 if(m_NextTry < 0 || !m_HaveStunServer)
85 {
86 return false;
87 }
88 bool Success;
89 NETADDR StunAddr;
90 if(StunMessageParse(pData, DataSize, &m_Stun, &Success, &StunAddr))
91 {
92 return false;
93 }
94 m_LastResponse = time_get();
95 if(!Success)
96 {
97 m_HaveAddr = false;
98 log_debug(IndexToSystem(m_Index), "got error response");
99 return true;
100 }
101 m_NextTry = -1;
102 m_NumUnsuccessfulTries = -1;
103 m_HaveAddr = true;
104 m_Addr = StunAddr;
105
106 char aStunAddr[NETADDR_MAXSTRSIZE];
107 net_addr_str(&StunAddr, aStunAddr, sizeof(aStunAddr), true);
108 log_debug(IndexToSystem(m_Index), "got address: %s", aStunAddr);
109 return true;
110}
111
112CONNECTIVITY CStun::CProtocol::GetConnectivity(NETADDR *pGlobalAddr)
113{

Callers 1

RecvMethod · 0.45

Calls 5

StunMessageParseFunction · 0.85
time_getFunction · 0.85
IndexToSystemFunction · 0.85
net_addr_strFunction · 0.85
IndexFromNetTypeFunction · 0.85

Tested by

no test coverage detected