Yate
|
IAX engine class. More...
#include <yateiax.h>
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, NamedList *params=0) | |
virtual | ~IAXEngine () |
IAXTransaction * | addFrame (const SocketAddr &addr, IAXFrame *frame) |
IAXTransaction * | addFrame (const SocketAddr &addr, const unsigned char *buf, unsigned int len) |
virtual void | processMedia (IAXTransaction *transaction, DataBlock &data, u_int32_t tStamp, int type, bool mark) |
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 (bool audio=true) const |
u_int32_t | capability () const |
void | initialize (const NamedList ¶ms) |
void | readSocket (SocketAddr &addr) |
bool | writeSocket (const void *buf, int len, const SocketAddr &addr, IAXFullFrame *frame=0, unsigned int *sent=0) |
bool | writeSocket (const SocketAddr &addr, IAXFullFrame *frame) |
void | runGetEvents () |
void | removeTransaction (IAXTransaction *transaction) |
u_int32_t | transactionCount () |
void | keepAlive (SocketAddr &addr) |
virtual bool | mediaFormatChanged (IAXTransaction *trans, int type, u_int32_t format) |
virtual bool | checkCallToken (const SocketAddr &addr, IAXFullFrame &frame) |
bool | acceptFormatAndCapability (IAXTransaction *trans, unsigned int *caps=0, int type=IAXFormat::Audio) |
virtual void | defaultEventHandler (IAXEvent *event) |
void | enableTrunking (IAXTransaction *trans) |
void | removeTrunkFrame (IAXMetaTrunkFrame *metaFrame) |
void | sendTrunkFrame (IAXMetaTrunkFrame *metaFrame) |
void | runProcessTrunkFrames () |
Socket & | socket () |
void | setFormats (u_int32_t caps, u_int32_t fmtAudio, u_int32_t fmtVideo) |
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) |
static void | buildAddrSecret (String &buf, const String &secret, const SocketAddr &addr) |
static int | addrSecretAge (const String &buf, const String &secret, const SocketAddr &addr) |
Protected Member Functions | |
bool | processTrunkFrames (u_int32_t time=Time::msecNow()) |
virtual void | processEvent (IAXEvent *event) |
IAXEvent * | getEvent (u_int64_t time) |
u_int16_t | generateCallNo () |
void | releaseCallNo (u_int16_t lcallno) |
IAXTransaction * | startLocalTransaction (IAXTransaction::Type type, const SocketAddr &addr, IAXIEList &ieList, bool trunking=false) |
IAX engine class.
This class holds all information needded to manipulate all IAX transactions and events
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, | ||
NamedList * | params = 0 |
||
) |
Constructor
iface | Address of the interface to use, default all (0.0.0.0) |
port | UDP port to run the protocol on |
transListCount | Number of entries in the transaction hash table |
retransCount | Retransmission counter for each transaction belonging to this engine |
retransInterval | Retransmission interval default value in miliseconds |
authTimeout | Timeout (in seconds) of acknoledged auth frames sent |
transTimeout | Timeout (in seconds) on remote request of transactions belonging to this engine |
maxFullFrameDataLen | Max full frame IE list (buffer) length |
format | Default media format |
capab | Media capabilities of this engine |
trunkSendInterval | Send trunk meta frame interval |
authRequired | Automatically challenge all clients for authentication |
params | Optional extra parameter list |
virtual ~IAXEngine | ( | ) | [virtual] |
Destructor Closes all transactions belonging to this engine and flush all queues
bool acceptFormatAndCapability | ( | IAXTransaction * | trans, |
unsigned int * | caps = 0 , |
||
int | type = IAXFormat::Audio |
||
) |
Process the initial received format and capability. If accepted on exit will set the transaction format and capability
trans | Transaction that received the new format |
caps | Optional codecs to set in transaction before processing |
type | Media type |
IAXTransaction* addFrame | ( | const SocketAddr & | addr, |
IAXFrame * | frame | ||
) |
Add a parsed frame to the transaction list
addr | Address from which the frame was received |
frame | A parsed IAX frame |
IAXTransaction* addFrame | ( | const SocketAddr & | addr, |
const unsigned char * | buf, | ||
unsigned int | len | ||
) |
Add a raw frame to the transaction list
addr | Address from which the message was received |
buf | Pointer to the start of the buffer holding the IAX frame |
len | Length of the message buffer |
static int addrSecretAge | ( | const String & | buf, |
const String & | secret, | ||
const SocketAddr & | addr | ||
) | [static] |
Decode a secret built using buildAddrSecret()
buf | Input buffer |
secret | Extra secret to check |
addr | Socket address |
bool authRequired | ( | ) | const [inline] |
Check if a transaction should automatically request authentication
u_int16_t authTimeout | ( | ) | const [inline] |
Get the timeout (in seconds) of acknoledged auth frames sent
static void buildAddrSecret | ( | String & | buf, |
const String & | secret, | ||
const SocketAddr & | addr | ||
) | [static] |
u_int32_t capability | ( | ) | const [inline] |
Get the media capability of this engine
virtual bool checkCallToken | ( | const SocketAddr & | addr, |
IAXFullFrame & | frame | ||
) | [virtual] |
Check call token on incoming call requests. This method is called by the engine when processing an incoming call request
addr | The address from where the call request was received |
frame | Received frame |
virtual void defaultEventHandler | ( | IAXEvent * | event | ) | [virtual] |
Default event handler. event MUST NOT be deleted
event | The event to handle |
void enableTrunking | ( | IAXTransaction * | trans | ) |
Enable trunking for the given transaction. Allocate a trunk meta frame if needded
trans | Transaction to enable trunking for |
u_int32_t format | ( | bool | audio = true | ) | const [inline] |
Get the default media format
audio | True to retrieve default audio format, false for video format |
u_int16_t generateCallNo | ( | ) | [protected] |
Generate call number. Update used call numbers list
static void getMD5FromChallenge | ( | String & | md5data, |
const String & | challenge, | ||
const String & | password | ||
) | [static] |
void initialize | ( | const NamedList & | params | ) |
(Re)Initialize the engine
params | Parameter list |
static bool isMD5ChallengeCorrect | ( | const String & | md5data, |
const String & | challenge, | ||
const String & | password | ||
) | [static] |
Test if a received response to an authentication request is correct
md5data | Data to compare with |
challenge | Received challenge |
password | Password source |
void keepAlive | ( | SocketAddr & | addr | ) |
Send an INVAL with call numbers set to 0 to a remote peer to keep it alive
addr | Address to send to |
u_int16_t maxFullFrameDataLen | ( | ) | const [inline] |
Get the maximum allowed frame length
virtual bool mediaFormatChanged | ( | IAXTransaction * | trans, |
int | type, | ||
u_int32_t | format | ||
) | [inline, virtual] |
Process a new format received with a full frame
trans | Transaction that received the new format |
type | Media type |
format | The received format |
bool process | ( | ) |
Event processor method. Keeps calling getEvent() and passing any events to processEvent() until there are no more events
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
event | Event to process |
virtual void processMedia | ( | IAXTransaction * | transaction, |
DataBlock & | data, | ||
u_int32_t | tStamp, | ||
int | type, | ||
bool | mark | ||
) | [inline, virtual] |
Process media from remote peer. Descendents must override this method
transaction | IAXTransaction that owns the call leg |
data | Media data |
tStamp | Media timestamp |
type | Media type |
mark | Mark flag |
bool processTrunkFrames | ( | u_int32_t | time = Time::msecNow() | ) | [protected] |
Process all trunk meta frames in the queue
time | Time of the call |
void readSocket | ( | SocketAddr & | addr | ) |
Read data from socket
addr | Socket to read from |
void releaseCallNo | ( | u_int16_t | lcallno | ) | [protected] |
Release a call number
lcallno | Call number to release |
void removeTransaction | ( | IAXTransaction * | transaction | ) |
Removes a transaction from queue. Free the allocated local call number Does not delete it
transaction | Transaction to remove |
void removeTrunkFrame | ( | IAXMetaTrunkFrame * | metaFrame | ) |
Remove a trunk meta frame from the queue and deref it
metaFrame | The trunk meta frame to remove |
u_int16_t retransCount | ( | ) | const [inline] |
Get default frame retransmission counter
u_int16_t retransInterval | ( | ) | const [inline] |
Get default frame retransmission starting interval
void runGetEvents | ( | ) |
Read events
void runProcessTrunkFrames | ( | ) |
Keep calling processTrunkFrames to send trunked media data
void sendTrunkFrame | ( | IAXMetaTrunkFrame * | metaFrame | ) | [inline] |
Send a trunk frame
metaFrame | The trunk meta frame to sent |
References IAXMetaTrunkFrame::send().
void setFormats | ( | u_int32_t | caps, |
u_int32_t | fmtAudio, | ||
u_int32_t | fmtVideo | ||
) | [inline] |
Send engine formats
caps | Capabilities |
fmtAudio | Default audio format |
fmtVideo | Default video format |
Get the socket used for engine operation
IAXTransaction* startLocalTransaction | ( | IAXTransaction::Type | type, |
const SocketAddr & | addr, | ||
IAXIEList & | ieList, | ||
bool | trunking = false |
||
) | [protected] |
Start a transaction based on a local request
type | Transaction type |
addr | Remote address to send the request |
ieList | First frame IE list |
trunking | Enable/disable trunking for this transaction |
u_int32_t transactionCount | ( | ) |
Return the transactions count This method is thread safe
u_int32_t transactionTimeout | ( | ) | const [inline] |
Get the timeout (in seconds) of transactions belonging to this engine
bool writeSocket | ( | const void * | buf, |
int | len, | ||
const SocketAddr & | addr, | ||
IAXFullFrame * | frame = 0 , |
||
unsigned int * | sent = 0 |
||
) |
Write data to socket.
buf | Data to write |
len | Data length |
addr | Socket to write to |
frame | Optional frame to be printed |
sent | Pointer to variable to be filled with the number of bytes sent |
bool writeSocket | ( | const SocketAddr & | addr, |
IAXFullFrame * | frame | ||
) | [inline] |
Write a full frame to socket
addr | Socket to write to |
frame | Frame to write |
References IAXFrame::data(), DataBlock::data(), DataBlock::length(), and IAXEngine::writeSocket().
Referenced by IAXEngine::writeSocket().