sipxportlib  Version 3.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
OsNatAgentTask Class Reference

#include <OsNatAgentTask.h>

Inheritance diagram for OsNatAgentTask:
Inheritance graph
[legend]
Collaboration diagram for OsNatAgentTask:
Collaboration graph
[legend]

Public Member Functions

virtual UtlBoolean handleMessage (OsMsg &rMsg)
 
UtlBoolean sendStunProbe (IStunSocket *pSocket, const UtlString &remoteAddress, int remotePort, int priority)
 
UtlBoolean enableStun (IStunSocket *pSocket, const UtlString &stunServer, int stunPort, const int stunOptions, int keepAlive)
 
UtlBoolean disableStun (IStunSocket *pSocket)
 
UtlBoolean enableTurn (IStunSocket *pSocket, const UtlString &turnServer, int iTurnPort, int keepAliveSecs, const UtlString &username, const UtlString &password)
 
UtlBoolean primeTurnReception (IStunSocket *pSocket, const char *szAddress, int iPort)
 
UtlBoolean setTurnDestination (IStunSocket *pSocket, const char *szAddress, int iPort)
 
void disableTurn (IStunSocket *pSocket)
 
UtlBoolean addCrLfKeepAlive (IStunSocket *pSocket, const UtlString &remoteIp, int remotePort, int keepAliveSecs, OsNatKeepaliveListener *pListener)
 
UtlBoolean removeCrLfKeepAlive (IStunSocket *pSocket, const UtlString &serverIp, int serverPort)
 
UtlBoolean addStunKeepAlive (IStunSocket *pSocket, const UtlString &remoteIp, int remotePort, int keepAliveSecs, OsNatKeepaliveListener *pListener)
 
UtlBoolean removeStunKeepAlive (IStunSocket *pSocket, const UtlString &serverIp, int serverPort)
 
UtlBoolean removeKeepAlives (IStunSocket *pSocket)
 
UtlBoolean removeStunProbes (IStunSocket *pSocket)
 
void synchronize ()
 
UtlBoolean areProbesOutstanding (IStunSocket *pSocket, int priority)
 
UtlBoolean doesBindingExist (IStunSocket *pSocket, NAT_AGENT_BINDING_TYPE type, const UtlString &serverIp, int serverPort)
 
OsTimergetTimer ()
 
UtlBoolean findContactAddress (const UtlString &destHost, int destPort, UtlString *pContactHost, int *pContactPort, int iTimeoutMs=0)
 
void addExternalBinding (OsSocket *pSocket, UtlString remoteAddress, int remotePort, UtlString contactAddress, int contactPort)
 
void clearExternalBinding (OsSocket *pSocket, UtlString remoteAddress, int remotePort, bool bOnlyIfEmpty=false)
 
UtlBoolean findExternalBinding (const UtlString &destHost, int destPort, UtlString *pContactHost, int *pContactPort, int iTimeoutMs=0, UtlBoolean *pTimedOut=NULL)
 
- Public Member Functions inherited from OsServerTask
 OsServerTask (const UtlString &name="", void *pArg=NULL, const int maxRequestQMsgs=DEF_MAX_MSGS, const int priority=DEF_PRIO, const int options=DEF_OPTIONS, const int stackSize=DEF_STACKSIZE)
 Main constructor for OsServerTask. More...
 
virtual ~OsServerTask ()
 
virtual OsStatus postMessage (const OsMsg &rMsg, const OsTime &rTimeout=OsTime::OS_INFINITY, UtlBoolean sentFromISR=FALSE)
 
virtual void requestShutdown (void)
 
OsMsgQ * getMessageQueue ()
 

Static Public Member Functions

static OsNatAgentTaskgetInstance ()
 
static void releaseInstance ()
 

Protected Member Functions

virtual UtlBoolean handleTimerEvent (NAT_AGENT_CONTEXT *pContext)
 
virtual void handleStunTimeout (NAT_AGENT_CONTEXT *pContext)
 
virtual void handleTurnTimeout (NAT_AGENT_CONTEXT *pContext)
 
virtual UtlBoolean handleCrLfKeepAlive (NAT_AGENT_CONTEXT *pContext)
 
virtual UtlBoolean handleStunKeepAlive (NAT_AGENT_CONTEXT *pContext)
 
virtual UtlBoolean handleStunMessage (NatMsg &rMsg)
 
virtual UtlBoolean handleTurnMessage (NatMsg &rMsg)
 
virtual UtlBoolean handleSynchronize (OsRpcMsg &rMsg)
 
virtual UtlBoolean sendMessage (StunMessage *pMsg, IStunSocket *pSocket, const UtlString &toAddress, unsigned short toPort, PacketType packetType=UNKNOWN_PACKET)
 
NAT_AGENT_CONTEXTgetBinding (IStunSocket *pSocket, NAT_AGENT_BINDING_TYPE type)
 
NAT_AGENT_CONTEXTgetBinding (NAT_AGENT_CONTEXT *pContext)
 
NAT_AGENT_CONTEXTgetBinding (STUN_TRANSACTION_ID *pId)
 
void destroyBinding (NAT_AGENT_CONTEXT *pBinding)
 
void releaseTimer (OsTimer *pTimer)
 
UtlBoolean sendStunRequest (NAT_AGENT_CONTEXT *pBinding)
 
UtlBoolean sendTurnRequest (NAT_AGENT_CONTEXT *pBinding)
 
void markStunFailure (NAT_AGENT_CONTEXT *pBinding)
 
void markStunSuccess (NAT_AGENT_CONTEXT *pBinding, const UtlString &mappedAddress, int mappedPort)
 
void markTurnFailure (NAT_AGENT_CONTEXT *pBinding)
 
void markTurnSuccess (NAT_AGENT_CONTEXT *pBinding, const UtlString &relayAddress, int relayPort)
 
OsNatKeepaliveEvent populateKeepaliveEvent (NAT_AGENT_CONTEXT *pContext)
 
void dumpContext (UtlString *pResults, NAT_AGENT_CONTEXT *pBinding)
 
- Protected Member Functions inherited from OsServerTask
virtual OsStatus receiveMessage (OsMsg *&rpMsg)
 
virtual OsStatus receiveMessage (OsMsg *&rpMsg, const OsTime &rTimeout)
 
virtual int run (void *pArg)
 

Additional Inherited Members

- Static Public Attributes inherited from OsServerTask
static const int DEF_MAX_MSGS = OsMsgQ::DEF_MAX_MSGS
 
- Protected Attributes inherited from OsServerTask
OsMsgQ mIncomingQ
 

Detailed Description

The OsNatAgentTask is responsible for servicing all stun requests and and responses on behalf of the IStunSocket. This handles the stun requests/responses however relies on someone else to pump sockets.

Use cases:

1) Send a STUN request via a supplied IStunSocket 2) Process responses from a IStunSocket 3) Process server requests from a IStunSocket

Member Function Documentation

OsNatAgentTask * getInstance ( )
static

Obtain a singleton instance

void releaseInstance ( )
static

Release/Free the singleton instance obtained by calling getInstance. This method is included for clean shutdown of the system.

UtlBoolean handleMessage ( OsMsg rMsg)
virtual

Standard OsServerTask message handler – used to process timer messages for stun refreshes, reads, etc.

Implements OsServerTask.

UtlBoolean sendStunProbe ( IStunSocket pSocket,
const UtlString remoteAddress,
int  remotePort,
int  priority 
)
UtlBoolean enableStun ( IStunSocket pSocket,
const UtlString stunServer,
int  stunPort,
const int  stunOptions,
int  keepAlive 
)
UtlBoolean disableStun ( IStunSocket pSocket)
UtlBoolean enableTurn ( IStunSocket pSocket,
const UtlString turnServer,
int  iTurnPort,
int  keepAliveSecs,
const UtlString username,
const UtlString password 
)
UtlBoolean primeTurnReception ( IStunSocket pSocket,
const char *  szAddress,
int  iPort 
)
UtlBoolean setTurnDestination ( IStunSocket pSocket,
const char *  szAddress,
int  iPort 
)
void disableTurn ( IStunSocket pSocket)
UtlBoolean addCrLfKeepAlive ( IStunSocket pSocket,
const UtlString remoteIp,
int  remotePort,
int  keepAliveSecs,
OsNatKeepaliveListener pListener 
)
UtlBoolean removeCrLfKeepAlive ( IStunSocket pSocket,
const UtlString serverIp,
int  serverPort 
)
UtlBoolean addStunKeepAlive ( IStunSocket pSocket,
const UtlString remoteIp,
int  remotePort,
int  keepAliveSecs,
OsNatKeepaliveListener pListener 
)
UtlBoolean removeStunKeepAlive ( IStunSocket pSocket,
const UtlString serverIp,
int  serverPort 
)
UtlBoolean removeKeepAlives ( IStunSocket pSocket)
UtlBoolean removeStunProbes ( IStunSocket pSocket)
void synchronize ( )

Synchronize with the OsNatAgentTask by posting a message to this event queue and waiting for that message to be processed. Do not call this method from the OsNatAgentTask's thread context (will block forever).

UtlBoolean areProbesOutstanding ( IStunSocket pSocket,
int  priority 
)

Determines if probes of a higher priority are still outstanding

UtlBoolean doesBindingExist ( IStunSocket pSocket,
NAT_AGENT_BINDING_TYPE  type,
const UtlString serverIp,
int  serverPort 
)

Does a binding of the designated type/server exist

OsTimer * getTimer ( )

Accessor for the timer object.

UtlBoolean findContactAddress ( const UtlString destHost,
int  destPort,
UtlString pContactHost,
int *  pContactPort,
int  iTimeoutMs = 0 
)

Look at all of the stun data structures and see if you can find a known back-route to the specified destination.

void addExternalBinding ( OsSocket pSocket,
UtlString  remoteAddress,
int  remotePort,
UtlString  contactAddress,
int  contactPort 
)

Add an external binding (used for findContactAddress)

void clearExternalBinding ( OsSocket pSocket,
UtlString  remoteAddress,
int  remotePort,
bool  bOnlyIfEmpty = false 
)
UtlBoolean findExternalBinding ( const UtlString destHost,
int  destPort,
UtlString pContactHost,
int *  pContactPort,
int  iTimeoutMs = 0,
UtlBoolean pTimedOut = NULL 
)

Locate an external binding for the specified destination host/port. This API while block while wait for a result.

UtlBoolean handleTimerEvent ( NAT_AGENT_CONTEXT pContext)
protectedvirtual
void handleStunTimeout ( NAT_AGENT_CONTEXT pContext)
protectedvirtual
void handleTurnTimeout ( NAT_AGENT_CONTEXT pContext)
protectedvirtual
UtlBoolean handleCrLfKeepAlive ( NAT_AGENT_CONTEXT pContext)
protectedvirtual
UtlBoolean handleStunKeepAlive ( NAT_AGENT_CONTEXT pContext)
protectedvirtual
UtlBoolean handleStunMessage ( NatMsg rMsg)
protectedvirtual

Handle an inbound Stun message. The messages are handled to this thread by the IStunSocket whenever someone calls one of the read methods.

UtlBoolean handleTurnMessage ( NatMsg rMsg)
protectedvirtual

Handle an inbound Turn message. The messages are handled to this thread by the IStunSocket whenever someone calls one of the read methods.

UtlBoolean handleSynchronize ( OsRpcMsg rMsg)
protectedvirtual

Handle a synchronization request. Synchronization consists of sending a message and waiting for that messsage to be processed.

UtlBoolean sendMessage ( StunMessage pMsg,
IStunSocket pSocket,
const UtlString toAddress,
unsigned short  toPort,
PacketType  packetType = UNKNOWN_PACKET 
)
protectedvirtual
NAT_AGENT_CONTEXT * getBinding ( IStunSocket pSocket,
NAT_AGENT_BINDING_TYPE  type 
)
protected
NAT_AGENT_CONTEXT * getBinding ( NAT_AGENT_CONTEXT pContext)
protected
NAT_AGENT_CONTEXT * getBinding ( STUN_TRANSACTION_ID pId)
protected
void destroyBinding ( NAT_AGENT_CONTEXT pBinding)
protected
void releaseTimer ( OsTimer pTimer)
protected
UtlBoolean sendStunRequest ( NAT_AGENT_CONTEXT pBinding)
protected
UtlBoolean sendTurnRequest ( NAT_AGENT_CONTEXT pBinding)
protected
void markStunFailure ( NAT_AGENT_CONTEXT pBinding)
protected
void markStunSuccess ( NAT_AGENT_CONTEXT pBinding,
const UtlString mappedAddress,
int  mappedPort 
)
protected
void markTurnFailure ( NAT_AGENT_CONTEXT pBinding)
protected
void markTurnSuccess ( NAT_AGENT_CONTEXT pBinding,
const UtlString relayAddress,
int  relayPort 
)
protected
OsNatKeepaliveEvent populateKeepaliveEvent ( NAT_AGENT_CONTEXT pContext)
protected
void dumpContext ( UtlString pResults,
NAT_AGENT_CONTEXT pBinding 
)
protected