sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
sp2plib::STUN Class Reference

Classes

struct  StunResponse
 Structure for storing data of stun query results. More...
 

Public Types

enum  NAT_Type {
  NAT_UdpBlocked = 0, NAT_OpenInternet = 255, NAT_SymmetricUdpFirewall = 20, NAT_FullCone = 200,
  NAT_RestrictedCone = 150, NAT_PortRestrictedCone = 100, NAT_Symmetric = 50, NAT_Unknown = 10
}
 Type of NAT device behavior. More...
 
typedef enum
sp2plib::STUN::NAT_Type 
NAT_Type
 Type of NAT device behavior.
 

Static Public Member Functions

static StunResponse Query (Socket sock, char *host, sp2plib::UInt16 port=STUN_PORT, sp2plib::UInt16 StunResponseTimeout=450)
 
static StunResponse Query (Socket sock, IP4Address srvAddr, sp2plib::UInt16 port=STUN_PORT, sp2plib::UInt16 StunResponseTimeout=450)
 
static int PortQuery (::std::map< ::std::string, IPEndPoint > *result, Socket s, IPEndPoint stunEP, int maxWait=2000)
 Records NAT mapped external end points while contacting STUN IP1:Port1,IP2:Port2,IP1:Port2,IP2:Port1
 
static int PortQueryUniquePorts (::std::set< sp2plib::UInt16 > *result, Socket s, IPEndPoint stunEP, int maxWait=2000)
 Records NAT mapped external unique ports while contacting STUN IP1:Port1,IP2:Port2,IP1:Port2,IP2:Port1
 
::std::string NATTypeName (NAT_Type NType)
 Gets textual representation of NAT_Type value
 

Member Enumeration Documentation

Type of NAT device behavior.

Enumerator:
NAT_UdpBlocked 

UDP is always blocked.

NAT_OpenInternet 

No NAT, public IP, no firewall.

NAT_SymmetricUdpFirewall 

No NAT, public IP, but symmetric UDP firewall.

NAT_FullCone 

A full cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Furthermore, any external host can send a packet to the internal host, by sending a packet to the mapped external address.

NAT_RestrictedCone 

A restricted cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Unlike a full cone NAT, an external host (with IP address X) can send a packet to the internal host only if the internal host had previously sent a packet to IP address X.

NAT_PortRestrictedCone 

A port restricted cone NAT is like a restricted cone NAT, but the restriction includes port numbers. Specifically, an external host can send a packet, with source IP address X and source port P, to the internal host only if the internal host had previously sent a packet to IP address X and port P.

NAT_Symmetric 

A symmetric NAT is one where all requests from the same internal IP address and port, to a specific destination IP address and port, are mapped to the same external IP address and port. If the same host sends a packet with the same source address and port, but to a different destination, a different mapping is used. Furthermore, only the external host that receives a packet can send a UDP packet back to the internal host.

NAT_Unknown 

Unknown

Member Function Documentation

::std::string sp2plib::STUN::NATTypeName ( NAT_Type  NType)
static

Gets textual representation of NAT_Type value

Parameters
NTypeThe type value
static int sp2plib::STUN::PortQuery ( ::std::map< ::std::string, IPEndPoint > *  result,
Socket  s,
IPEndPoint  stunEP,
int  maxWait = 2000 
)
static

Records NAT mapped external end points while contacting STUN IP1:Port1,IP2:Port2,IP1:Port2,IP2:Port1

Parameters
resultMap - keys are stun end points, values are mapped external endpoints
sSocket to use for operation
stunEPStun end pont - location
maxWait(Optional) the maximum wait timeout
Returns
0 is operation is completed witout errors , otherwise -1
static int sp2plib::STUN::PortQueryUniquePorts ( ::std::set< sp2plib::UInt16 > *  result,
Socket  s,
IPEndPoint  stunEP,
int  maxWait = 2000 
)
static

Records NAT mapped external unique ports while contacting STUN IP1:Port1,IP2:Port2,IP1:Port2,IP2:Port1

Parameters
result>Set - mapped external unique ports
sSocket to use for operation
stunEPStun end pont - location
maxWait(Optional) the maximum wait timeout
Returns
0 is operation is completed witout errors , otherwise -1
static StunResponse sp2plib::STUN::Query ( Socket  sock,
char *  host,
sp2plib::UInt16  port = STUN_PORT,
sp2plib::UInt16  StunResponseTimeout = 450 
)
static

Performs STUN query using ready UDP socket sock - Socket handle, socket shoud be opetaional before using as this argument host - Host name or IP of STUN server in text format port - Port of stun server , default is 3478 StunResponseTimeout - MAX miliseconds to wait for atomic STUN transaction ot receive response, default 450 ms

static StunResponse sp2plib::STUN::Query ( Socket  sock,
IP4Address  srvAddr,
sp2plib::UInt16  port = STUN_PORT,
sp2plib::UInt16  StunResponseTimeout = 450 
)
static

Performs STUN query using ready UDP socket sock - Socket handle, socket shoud be opetaional before using as this argument srvAddr - Host IP of STUN server port - Port of stun server , default is 3478 StunResponseTimeout - MAX miliseconds to wait for atomic STUN transaction ot receive response, default 450 ms


The documentation for this class was generated from the following file: