Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
StunClient.cpp File Reference
#include "precompiled.h"
#include "StunClient.h"
#include "lib/byte_order.h"
#include "lib/external_libraries/enet.h"
#include "ps/CLogger.h"
#include "ps/ConfigDB.h"
#include "ps/CStr.h"
#include <chrono>
#include <cstddef>
#include <thread>
#include <vector>
Include dependency graph for StunClient.cpp:

Namespaces

namespace  StunClient
 

Functions

template<typename T , size_t n = sizeof(T)>
void StunClient::AddToBuffer (std::vector< u8 > &buffer, const T value)
 Push POD data to a network-byte-order buffer. More...
 
template<typename T , size_t n = sizeof(T)>
bool StunClient::GetFromBuffer (const std::vector< u8 > &buffer, u32 &offset, T &result)
 Read POD data from a network-byte-order buffer. More...
 
void StunClient::SendStunRequest (ENetHost &transactionHost, ENetAddress addr)
 
bool StunClient::CreateStunRequest (ENetHost &transactionHost)
 Creates a STUN request and sends it to a STUN server. More...
 
bool StunClient::ReceiveStunResponse (ENetHost &transactionHost, std::vector< u8 > &buffer)
 Gets the response from the STUN server and checks it for its validity. More...
 
bool StunClient::ParseStunResponse (const std::vector< u8 > &buffer)
 
bool StunClient::STUNRequestAndResponse (ENetHost &transactionHost)
 
bool StunClient::FindPublicIP (ENetHost &transactionHost, CStr &ip, u16 &port)
 
void StunClient::SendHolePunchingMessages (ENetHost &enetClient, const std::string &serverAddress, u16 serverPort)
 Send a message to the target server with the given ENet host/socket. More...
 
bool StunClient::FindLocalIP (CStr &ip)
 

Variables

const u32 StunClient::m_MagicCookie = 0x2112A442
 These constants are defined in Section 6 of RFC 5389. More...
 
const u16 StunClient::m_MethodTypeBinding = 0x01
 
const u32 StunClient::m_BindingSuccessResponse = 0x0101
 
const u16 StunClient::m_ComprehensionOptional = 0x1 << 15
 Bit determining whether comprehension of an attribute is optional. More...
 
const u16 StunClient::m_IETFReview = 0x1 << 14
 Bit determining whether the bit was assigned by IETF Review. More...
 
const u8 StunClient::m_IPAddressFamilyIPv4 = 0x01
 These constants are defined in Section 15.1 of RFC 5389. More...
 
const u16 StunClient::m_AttrTypeMappedAddress = 0x001
 These constants are defined in Section 18.2 of RFC 5389. More...
 
const u16 StunClient::m_AttrTypeXORMappedAddress = 0x0020
 
u8 StunClient::m_TransactionID [12]
 Described in section 3 of RFC 5389. More...
 
ENetAddress StunClient::m_StunServer
 
ENetAddress StunClient::m_PublicAddress
 Public IP + port discovered via the STUN transaction. More...