PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PTURNClient Class Reference

#include <pstun.h>

Inheritance diagram for PTURNClient:
Collaboration diagram for PTURNClient:

Public Types

enum  { DefaultPriority = 30 }
 
- Public Types inherited from PSTUNClient
enum  { DefaultPriority = 40 }
 
- Public Types inherited from PSTUN
enum  { DefaultPort = 3478 }
 
enum  { MinChannelNumber = 0x4000, MaxChannelNumber = 0x7ffe }
 

Public Member Functions

virtual PCaselessString GetMethodName () const
 
 PTURNClient (unsigned priority=DefaultPriority)
 
bool CreateSocket (PUDPSocket *&socket, const PIPSocket::Address &binding=PIPSocket::GetDefaultIpAny(), WORD localPort=0, PObject *context=NULL, Component component=eComponent_Unknown)
 Create a single socket. More...
 
bool CreateSocketPair (PUDPSocket *&socket1, PUDPSocket *&socket2, const PIPSocket::Address &binding=PIPSocket::GetDefaultIpAny(), PObject *context=NULL)
 Create a socket pair. More...
 
virtual RTPSupportTypes GetRTPSupport (bool force=false)
 Return an indication if the current STUN type supports RTP Use the force variable to guarantee an up to date test. More...
 
- Public Member Functions inherited from PSTUNClient
 PSTUNClient (unsigned priority=DefaultPriority)
 
 ~PSTUNClient ()
 
bool SetServer (const PString &server)
 Set the STUN server to use. More...
 
virtual PString GetServer () const
 Get the current server address name. More...
 
virtual bool GetServerAddress (PIPSocketAddressAndPort &serverAddressAndPort) const
 
virtual bool GetInterfaceAddress (PIPSocket::Address &internalAddress) const
 
virtual bool Open (const PIPSocket::Address &ifaceAddr)
 
virtual bool IsAvailable (const PIPSocket::Address &binding, PObject *userData)
 
virtual void Close ()
 
- Public Member Functions inherited from PSTUN
 PSTUN ()
 
virtual ~PSTUN ()
 
virtual PNatMethod::NatTypes DoRFC3489Discovery (PSTUNUDPSocket *socket, const PIPSocketAddressAndPort &serverAddress, PIPSocketAddressAndPort &baseAddressAndPort, PIPSocketAddressAndPort &externalAddressAndPort)
 Determine the NAT type using RFC3489 discovery method. More...
 
virtual PNatMethod::NatTypes FinishRFC3489Discovery (PSTUNMessage &responseI, PSTUNUDPSocket *socket, PIPSocketAddressAndPort &externalAddressAndPort)
 
virtual int MakeAuthenticatedRequest (PSTUNUDPSocket *socket, PSTUNMessage &request, PSTUNMessage &response)
 
virtual bool GetFromBindingResponse (const PSTUNMessage &response, PIPSocketAddressAndPort &externalAddress)
 
virtual void AppendMessageIntegrity (PSTUNMessage &message)
 
virtual void SetCredentials (const PString &username, const PString &password, const PString &realm)
 
virtual const PTimeInterval GetTimeout () const
 Get the timeout for responses from STUN server. More...
 
virtual void SetTimeout (const PTimeInterval &timeout)
 Set the timeout for responses from STUN server. More...
 
virtual PINDEX GetRetries () const
 Get the number of retries for responses from STUN server. More...
 
virtual void SetRetries (PINDEX retries)
 Set the number of retries for responses from STUN server. More...
 

Static Public Member Functions

static const char * MethodName ()
 Get the NAT Method Name. More...
 
- Static Public Member Functions inherited from PSTUNClient
static const char * MethodName ()
 Get the NAT Method Name. More...
 

Protected Member Functions

virtual PNATUDPSocket * InternalCreateSocket (Component component, PObject *context)
 
virtual bool RefreshAllocation (DWORD lifetime=600)
 
- Protected Member Functions inherited from PSTUNClient
virtual void InternalUpdate ()
 
bool InternalSetServer (const PIPSocketAddressAndPort &addr)
 

Additional Inherited Members

- Public Attributes inherited from PSTUN
PINDEX m_pollRetries
 
PSASLString m_userName
 
PSASLString m_realm
 
PSASLString m_nonce
 
PBYTEArray m_password
 
PIPSocket::Address m_interface
 
PIPSocketAddressAndPort m_serverAddress
 
PTimeInterval replyTimeout
 
- Protected Attributes inherited from PSTUNClient
PSTUNUDPSocketm_socket
 

Member Enumeration Documentation

anonymous enum
Enumerator
DefaultPriority 

Constructor & Destructor Documentation

PTURNClient::PTURNClient ( unsigned  priority = DefaultPriority)

Member Function Documentation

bool PTURNClient::CreateSocket ( PUDPSocket *&  socket,
const PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
WORD  localPort = 0,
PObject context = NULL,
Component  component = eComponent_Unknown 
)
virtual

Create a single socket.

The STUN protocol is used to create a socket for which the external IP address and port numbers are known. A PUDPSocket descendant is returned which will, in response to GetLocalAddress() return the externally visible IP and port rather than the local machines IP and socket.

The will create a new socket pointer. It is up to the caller to make sure the socket is deleted to avoid memory leaks.

The socket pointer is set to NULL if the function fails and returns false.

Reimplemented from PSTUNClient.

bool PTURNClient::CreateSocketPair ( PUDPSocket *&  socket1,
PUDPSocket *&  socket2,
const PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
PObject context = NULL 
)
virtual

Create a socket pair.

The STUN protocol is used to create a pair of sockets with adjacent port numbers for which the external IP address and port numbers are known. PUDPSocket descendants are returned which will, in response to GetLocalAddress() return the externally visible IP and port rather than the local machines IP and socket.

The will create new socket pointers. It is up to the caller to make sure the sockets are deleted to avoid memory leaks.

The socket pointers are set to NULL if the function fails and returns false.

Reimplemented from PSTUNClient.

virtual PCaselessString PTURNClient::GetMethodName ( ) const
virtual

Reimplemented from PSTUNClient.

virtual RTPSupportTypes PTURNClient::GetRTPSupport ( bool  force = false)
virtual

Return an indication if the current STUN type supports RTP Use the force variable to guarantee an up to date test.

Parameters
forceForce a new check
virtual PNATUDPSocket* PTURNClient::InternalCreateSocket ( Component  component,
PObject context 
)
protectedvirtual

Reimplemented from PSTUNClient.

static const char* PTURNClient::MethodName ( )
static

Get the NAT Method Name.

virtual bool PTURNClient::RefreshAllocation ( DWORD  lifetime = 600)
protectedvirtual

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