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

Method UdpConnectivity

src/engine/client/client.cpp:5175–5217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5173}
5174
5175int CClient::UdpConnectivity(int NetType)
5176{
5177 static const int NETTYPES[2] = {NETTYPE_IPV6, NETTYPE_IPV4};
5178 int Connectivity = CONNECTIVITY_UNKNOWN;
5179 for(int PossibleNetType : NETTYPES)
5180 {
5181 if((NetType & PossibleNetType) == 0)
5182 {
5183 continue;
5184 }
5185 NETADDR GlobalUdpAddr;
5186 int NewConnectivity;
5187 switch(m_aNetClient[CONN_MAIN].GetConnectivity(PossibleNetType, &GlobalUdpAddr))
5188 {
5189 case CONNECTIVITY::UNKNOWN:
5190 NewConnectivity = CONNECTIVITY_UNKNOWN;
5191 break;
5192 case CONNECTIVITY::CHECKING:
5193 NewConnectivity = CONNECTIVITY_CHECKING;
5194 break;
5195 case CONNECTIVITY::UNREACHABLE:
5196 NewConnectivity = CONNECTIVITY_UNREACHABLE;
5197 break;
5198 case CONNECTIVITY::REACHABLE:
5199 NewConnectivity = CONNECTIVITY_REACHABLE;
5200 break;
5201 case CONNECTIVITY::ADDRESS_KNOWN:
5202 GlobalUdpAddr.port = 0;
5203 if(m_HaveGlobalTcpAddr && NetType == (int)m_GlobalTcpAddr.type && net_addr_comp(&m_GlobalTcpAddr, &GlobalUdpAddr) != 0)
5204 {
5205 NewConnectivity = CONNECTIVITY_DIFFERING_UDP_TCP_IP_ADDRESSES;
5206 break;
5207 }
5208 NewConnectivity = CONNECTIVITY_REACHABLE;
5209 break;
5210 default:
5211 dbg_assert(0, "invalid connectivity value");
5212 return CONNECTIVITY_UNKNOWN;
5213 }
5214 Connectivity = std::max(Connectivity, NewConnectivity);
5215 }
5216 return Connectivity;
5217}
5218
5219static bool ViewLinkImpl(const char *pLink)
5220{

Callers 1

RenderPopupConnectingMethod · 0.80

Calls 2

net_addr_compFunction · 0.85
GetConnectivityMethod · 0.45

Tested by

no test coverage detected