Yate
Public Member Functions | Static Public Member Functions | Protected Member Functions

IAXEngine Class Reference

IAX engine class. More...

#include <yateiax.h>

Inheritance diagram for IAXEngine:
DebugEnabler Mutex Lockable

List of all members.

Public Member Functions

 IAXEngine (const char *iface, int port, u_int16_t transListCount, u_int16_t retransCount, u_int16_t retransInterval, u_int16_t authTimeout, u_int16_t transTimeout, u_int16_t maxFullFrameDataLen, u_int32_t format, u_int32_t capab, u_int32_t trunkSendInterval, bool authRequired)
virtual ~IAXEngine ()
IAXTransactionaddFrame (const SocketAddr &addr, IAXFrame *frame)
IAXTransactionaddFrame (const SocketAddr &addr, const unsigned char *buf, unsigned int len)
virtual void processMedia (IAXTransaction *transaction, DataBlock &data, u_int32_t tStamp)
bool process ()
u_int16_t retransCount () const
u_int16_t retransInterval () const
bool authRequired () const
u_int16_t authTimeout () const
u_int32_t transactionTimeout () const
u_int16_t maxFullFrameDataLen () const
u_int32_t format () const
u_int32_t capability () const
void readSocket (SocketAddr &addr)
bool writeSocket (const void *buf, int len, const SocketAddr &addr, IAXFullFrame *frame=0)
void runGetEvents ()
void removeTransaction (IAXTransaction *transaction)
u_int32_t transactionCount ()
void keepAlive (SocketAddr &addr)
virtual bool voiceFormatChanged (IAXTransaction *trans, u_int32_t format)
bool acceptFormatAndCapability (IAXTransaction *trans)
virtual void defaultEventHandler (IAXEvent *event)
void enableTrunking (IAXTransaction *trans)
void removeTrunkFrame (IAXMetaTrunkFrame *metaFrame)
void runProcessTrunkFrames ()
Socketsocket ()

Static Public Member Functions

static void getMD5FromChallenge (String &md5data, const String &challenge, const String &password)
static bool isMD5ChallengeCorrect (const String &md5data, const String &challenge, const String &password)

Protected Member Functions

bool processTrunkFrames (u_int32_t time=Time::msecNow())
virtual void processEvent (IAXEvent *event)
IAXEventgetEvent (u_int64_t time)
u_int16_t generateCallNo ()
void releaseCallNo (u_int16_t lcallno)
IAXTransactionstartLocalTransaction (IAXTransaction::Type type, const SocketAddr &addr, IAXIEList &ieList, bool trunking=false)

Detailed Description

IAX engine class.

This class holds all information needded to manipulate all IAX transactions and events


Constructor & Destructor Documentation

IAXEngine ( const char *  iface,
int  port,
u_int16_t  transListCount,
u_int16_t  retransCount,
u_int16_t  retransInterval,
u_int16_t  authTimeout,
u_int16_t  transTimeout,
u_int16_t  maxFullFrameDataLen,
u_int32_t  format,
u_int32_t  capab,
u_int32_t  trunkSendInterval,
bool  authRequired 
)

Constructor

Parameters:
ifaceAddress of the interface to use, default all (0.0.0.0)
portUDP port to run the protocol on
transListCountNumber of entries in the transaction hash table
retransCountRetransmission counter for each transaction belonging to this engine
retransIntervalRetransmission interval default value in miliseconds
authTimeoutTimeout (in seconds) of acknoledged auth frames sent
transTimeoutTimeout (in seconds) on remote request of transactions belonging to this engine
maxFullFrameDataLenMax full frame IE list (buffer) length
formatDefault media format
capabMedia capabilities of this engine
trunkSendIntervalSend trunk meta frame interval
authRequiredAutomatically challenge all clients for authentication
virtual ~IAXEngine ( ) [virtual]

Destructor Closes all transactions belonging to this engine and flush all queues


Member Function Documentation

bool acceptFormatAndCapability ( IAXTransaction trans)

Process the initial received format and capability. If accepted on exit will set the transaction format and capability

Parameters:
transTransaction that received the new format
Returns:
True if accepted
IAXTransaction* addFrame ( const SocketAddr addr,
IAXFrame frame 
)

Add a parsed frame to the transaction list

Parameters:
addrAddress from which the frame was received
frameA parsed IAX frame
Returns:
Pointer to the transaction or 0 to deref the frame
IAXTransaction* addFrame ( const SocketAddr addr,
const unsigned char *  buf,
unsigned int  len 
)

Add a raw frame to the transaction list

Parameters:
addrAddress from which the message was received
bufPointer to the start of the buffer holding the IAX frame
lenLength of the message buffer
Returns:
Pointer to the transaction or 0
bool authRequired ( ) const [inline]

Check if a transaction should automatically request authentication

Returns:
True to automatically request authentication
u_int16_t authTimeout ( ) const [inline]

Get the timeout (in seconds) of acknoledged auth frames sent

Returns:
Auth timeout in seconds
u_int32_t capability ( ) const [inline]

Get the media capability of this engine

Returns:
The media capability of this engine
virtual void defaultEventHandler ( IAXEvent event) [virtual]

Default event handler. event MUST NOT be deleted

Parameters:
eventThe event to handle
void enableTrunking ( IAXTransaction trans)

Enable trunking for the given transaction. Allocate a trunk meta frame if needded

Parameters:
transTransaction to enable trunking for
u_int32_t format ( ) const [inline]

Get the default media format

Returns:
The default media format
u_int16_t generateCallNo ( ) [protected]

Generate call number. Update used call numbers list

Returns:
Call number or 0 if none available
IAXEvent* getEvent ( u_int64_t  time) [protected]

Get an IAX event from the queue. This method is thread safe.

Parameters:
timeTime of the call
Returns:
Pointer to an IAXEvent or 0 if none is available
static void getMD5FromChallenge ( String md5data,
const String challenge,
const String password 
) [static]

Get the MD5 data from a challenge and a password

Parameters:
md5dataDestination String
challengeChallenge source
passwordPassword source
static bool isMD5ChallengeCorrect ( const String md5data,
const String challenge,
const String password 
) [static]

Test if a received response to an authentication request is correct

Parameters:
md5dataData to compare with
challengeReceived challenge
passwordPassword source
void keepAlive ( SocketAddr addr)

Send an INVAL with call numbers set to 0 to a remote peer to keep it alive

Parameters:
addrAddress to send to
u_int16_t maxFullFrameDataLen ( ) const [inline]

Get the maximum allowed frame length

Returns:
The maximum allowed frame length
bool process ( )

Event processor method. Keeps calling getEvent() and passing any events to processEvent() until there are no more events

Returns:
True if at least one event was processed
virtual void processEvent ( IAXEvent event) [protected, virtual]

Default event for connection transactions handler. This method may be overriden to perform custom processing This method is thread safe

Parameters:
eventEvent to process
virtual void processMedia ( IAXTransaction transaction,
DataBlock data,
u_int32_t  tStamp 
) [inline, virtual]

Process media from remote peer. Descendents must override this method

Parameters:
transactionIAXTransaction that owns the call leg
dataMedia data
tStampMedia timestamp
bool processTrunkFrames ( u_int32_t  time = Time::msecNow()) [protected]

Process all trunk meta frames in the queue

Parameters:
timeTime of the call
Returns:
True if at least one frame was sent
void readSocket ( SocketAddr addr)

Read data from socket

Parameters:
addrSocket to read from
void releaseCallNo ( u_int16_t  lcallno) [protected]

Release a call number

Parameters:
lcallnoCall number to release
void removeTransaction ( IAXTransaction transaction)

Removes a transaction from queue. Free the allocated local call number Does not delete it

Parameters:
transactionTransaction to remove
void removeTrunkFrame ( IAXMetaTrunkFrame metaFrame)

Remove a trunk meta frame from the queue and deref it

Parameters:
metaFrameThe trunk meta frame to remove
u_int16_t retransCount ( ) const [inline]

Get default frame retransmission counter

Returns:
Frame retransmission counter
u_int16_t retransInterval ( ) const [inline]

Get default frame retransmission starting interval

Returns:
Frame retransmission starting interval
void runGetEvents ( )

Read events

void runProcessTrunkFrames ( )

Keep calling processTrunkFrames to send trunked media data

Socket& socket ( ) [inline]

Get the socket used for engine operation

Returns:
Reference to the UDP socket
IAXTransaction* startLocalTransaction ( IAXTransaction::Type  type,
const SocketAddr addr,
IAXIEList ieList,
bool  trunking = false 
) [protected]

Start a transaction based on a local request

Parameters:
typeTransaction type
addrRemote address to send the request
ieListFirst frame IE list
trunkingEnable/disable trunking for this transaction
Returns:
IAXTransaction pointer on success.
u_int32_t transactionCount ( )

Return the transactions count This method is thread safe

Returns:
Transactions count
u_int32_t transactionTimeout ( ) const [inline]

Get the timeout (in seconds) of transactions belonging to this engine

Returns:
Timeout (in seconds) of transactions belonging to this engine
virtual bool voiceFormatChanged ( IAXTransaction trans,
u_int32_t  format 
) [inline, virtual]

Process a new format received with a Voice frame

Parameters:
transTransaction that received the new format
formatThe received format
Returns:
True if accepted
bool writeSocket ( const void *  buf,
int  len,
const SocketAddr addr,
IAXFullFrame frame = 0 
)

Write data to socket.

Parameters:
bufData to write
lenData length
addrSocket to write to
frameOptional frame to be printed if debug is DebugAll
Returns:
True on success

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