Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Functions | |
template<typename T , size_t n = sizeof(T)> | |
void | 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 | GetFromBuffer (const std::vector< u8 > &buffer, u32 &offset, T &result) |
Read POD data from a network-byte-order buffer. More... | |
void | SendStunRequest (ENetHost &transactionHost, ENetAddress addr) |
bool | CreateStunRequest (ENetHost &transactionHost) |
Creates a STUN request and sends it to a STUN server. More... | |
bool | ReceiveStunResponse (ENetHost &transactionHost, std::vector< u8 > &buffer) |
Gets the response from the STUN server and checks it for its validity. More... | |
bool | ParseStunResponse (const std::vector< u8 > &buffer) |
bool | STUNRequestAndResponse (ENetHost &transactionHost) |
bool | FindPublicIP (ENetHost &transactionHost, CStr &ip, u16 &port) |
void | SendHolePunchingMessages (ENetHost &enetClient, const std::string &serverAddress, u16 serverPort) |
Send a message to the target server with the given ENet host/socket. More... | |
bool | FindLocalIP (CStr &ip) |
bool | FindPublicIP (ENetHost &enetClient, CStr8 &ip, u16 &port) |
Return the publicly accessible IP of the given ENet host/socket. More... | |
bool | FindLocalIP (CStr8 &ip) |
Return the local IP. More... | |
Variables | |
const u32 | m_MagicCookie = 0x2112A442 |
These constants are defined in Section 6 of RFC 5389. More... | |
const u16 | m_MethodTypeBinding = 0x01 |
const u32 | m_BindingSuccessResponse = 0x0101 |
const u16 | m_ComprehensionOptional = 0x1 << 15 |
Bit determining whether comprehension of an attribute is optional. More... | |
const u16 | m_IETFReview = 0x1 << 14 |
Bit determining whether the bit was assigned by IETF Review. More... | |
const u8 | m_IPAddressFamilyIPv4 = 0x01 |
These constants are defined in Section 15.1 of RFC 5389. More... | |
const u16 | m_AttrTypeMappedAddress = 0x001 |
These constants are defined in Section 18.2 of RFC 5389. More... | |
const u16 | m_AttrTypeXORMappedAddress = 0x0020 |
u8 | m_TransactionID [12] |
Described in section 3 of RFC 5389. More... | |
ENetAddress | m_StunServer |
ENetAddress | m_PublicAddress |
Public IP + port discovered via the STUN transaction. More... | |
void StunClient::AddToBuffer | ( | std::vector< u8 > & | buffer, |
const T | value | ||
) |
Push POD data to a network-byte-order buffer.
TODO: this should be optimised & moved to byte_order.h
bool StunClient::CreateStunRequest | ( | ENetHost & | transactionHost | ) |
Creates a STUN request and sends it to a STUN server.
The request is sent through transactionHost, from which the answer will be retrieved by ReceiveStunResponse and interpreted by ParseStunResponse.
bool StunClient::FindLocalIP | ( | CStr & | ip | ) |
bool StunClient::FindLocalIP | ( | CStr8 & | ip | ) |
Return the local IP.
Technically not a STUN method, but convenient to define here.
Return the publicly accessible IP of the given ENet host/socket.
This is done by contacting STUN server. The return IP & port should only be considered valid for the give host/socket.
bool StunClient::GetFromBuffer | ( | const std::vector< u8 > & | buffer, |
u32 & | offset, | ||
T & | result | ||
) |
Read POD data from a network-byte-order buffer.
TODO: this should be optimised & moved to byte_order.h
bool StunClient::ParseStunResponse | ( | const std::vector< u8 > & | buffer | ) |
Gets the response from the STUN server and checks it for its validity.
void StunClient::SendHolePunchingMessages | ( | ENetHost & | enetClient, |
const std::string & | serverAddress, | ||
u16 | serverPort | ||
) |
Send a message to the target server with the given ENet host/socket.
This will open a port on the local gateway (if any) to receive trafic, allowing the recipient to answer (thus 'punching a hole' in the NAT). NB: this assumes consistent NAT, i.e. the outgoing port is always the same for the given client, thus allowing the IP discovered via STUN to be sent to the target server.
void StunClient::SendStunRequest | ( | ENetHost & | transactionHost, |
ENetAddress | addr | ||
) |
bool StunClient::STUNRequestAndResponse | ( | ENetHost & | transactionHost | ) |
const u16 StunClient::m_AttrTypeMappedAddress = 0x001 |
These constants are defined in Section 18.2 of RFC 5389.
const u16 StunClient::m_AttrTypeXORMappedAddress = 0x0020 |
const u32 StunClient::m_BindingSuccessResponse = 0x0101 |
const u16 StunClient::m_ComprehensionOptional = 0x1 << 15 |
Bit determining whether comprehension of an attribute is optional.
Described in Section 15 of RFC 5389.
const u16 StunClient::m_IETFReview = 0x1 << 14 |
Bit determining whether the bit was assigned by IETF Review.
Described in section 18.1. of RFC 5389.
const u8 StunClient::m_IPAddressFamilyIPv4 = 0x01 |
These constants are defined in Section 15.1 of RFC 5389.
const u32 StunClient::m_MagicCookie = 0x2112A442 |
These constants are defined in Section 6 of RFC 5389.
const u16 StunClient::m_MethodTypeBinding = 0x01 |
ENetAddress StunClient::m_PublicAddress |
Public IP + port discovered via the STUN transaction.
ENetAddress StunClient::m_StunServer |
u8 StunClient::m_TransactionID[12] |
Described in section 3 of RFC 5389.