|
|
This class holds all information needded to manipulate all IAX transactions and events
IAXEngine (const char* iface, int port, u_int32_t format, u_int32_t capab,
const NamedList* params = 0, const char* name = "iaxengine")
| IAXEngine |
Constructor
Parameters:
iface | Address of the interface to use, default all (0.0.0.0) |
port | UDP port to run the protocol on |
format | Default media format |
capab | Media capabilities of this engine |
params | Optional extra parameter list |
name | Engine name |
~IAXEngine ()
| ~IAXEngine |
[virtual]
Destructor Closes all transactions belonging to this engine and flush all queues
inline const String& name ()
| name |
[const]
Retrieve the engine name
Returns: Engine name
inline u_int8_t callerNumType ()
| callerNumType |
[const]
Retrieve the default caller number type
Returns: Default caller number type
inline u_int8_t callingPres ()
| callingPres |
[const]
Retrieve the default caller number presentation and screening concatenated value
Returns: Default caller number presentation and screening
IAXTransaction* addFrame (const SocketAddr& addr, IAXFrame* frame)
| addFrame |
Add a parsed frame to the transaction list
Parameters:
addr | Address from which the frame was received |
frame | A 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)
| addFrame |
Add a raw frame to the transaction list
Parameters:
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 |
Returns: Pointer to the transaction or 0
IAXTransaction* findTransaction (const SocketAddr& addr, u_int16_t rCallNo)
| findTransaction |
Find a complete transaction. This method is thread safe
Parameters:
addr | Remote address |
rCallNo | Remote transaction call number |
Returns: Referrenced pointer to the transaction or 0
void processMedia (IAXTransaction* transaction, DataBlock& data, u_int32_t tStamp,
int type, bool mark)
| processMedia |
[virtual]
Process media from remote peer. Descendents must override this method
Parameters:
transaction | IAXTransaction that owns the call leg |
data | Media data |
tStamp | Media timestamp |
type | Media type |
mark | Mark flag |
bool process ()
| 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
inline unsigned int challengeTout ()
| challengeTout |
[const]
Get the timeout interval sent challenge
Returns: Sent challenge timeout interval
inline u_int16_t maxFullFrameDataLen ()
| maxFullFrameDataLen |
[const]
Get the maximum allowed frame length
Returns: The maximum allowed frame length
inline u_int32_t format (bool audio = true)
| format |
[const]
Get the default media format
Parameters:
audio | True to retrieve default audio format, false for video format |
Returns: The default media format
inline u_int32_t capability ()
| capability |
[const]
Get the media capability of this engine
Returns: The media capability of this engine
inline void getOutDataAdjust (unsigned int& thres, unsigned int& over,
unsigned int& under)
| getOutDataAdjust |
[const]
Retrieve outgoing data timestamp adjust values
Parameters:
thres | Adjust outgoing data timestamp threshold |
over | Value used to adjust outgoing data timestamp on data overrun |
under | Value used to adjust outgoing data timestamp on data underrun |
void initOutDataAdjust (const NamedList& params, IAXTransaction* tr = 0)
| initOutDataAdjust |
Initialize outgoing data timestamp adjust values. This method is thread safe
Parameters:
params | Parameters list |
tr | Optional transaction to init, initialize the engine's data if 0 |
void initialize (const NamedList& params)
| initialize |
(Re)Initialize the engine
Parameters:
params | Parameter list |
void readSocket (SocketAddr& addr)
| readSocket |
Read data from socket
Parameters:
addr | Socket to read from |
bool writeSocket (const void* buf, int len, const SocketAddr& addr, IAXFullFrame* frame = 0,
unsigned int* sent = 0)
| writeSocket |
Write data to socket.
Parameters:
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 |
Returns: True on success
inline bool writeSocket (const SocketAddr& addr, IAXFullFrame* frame)
| writeSocket |
Write a full frame to socket
Parameters:
addr | Socket to write to |
frame | Frame to write |
Returns: True on success
void runGetEvents ()
| runGetEvents |
Read events
void removeTransaction (IAXTransaction* transaction)
| removeTransaction |
Removes a transaction from queue. Free the allocated local call number Does not delete it
Parameters:
transaction | Transaction to remove |
bool haveTransactions ()
| haveTransactions |
Check if there are any transactions in the engine This method is thread safe
Returns: True if the engine holds at least 1 transaction
u_int32_t transactionCount ()
| transactionCount |
Return the transactions count This method is thread safe
Returns: Transactions count
void keepAlive (const SocketAddr& addr)
| keepAlive |
Send an INVAL with call numbers set to 0 to a remote peer to keep it alive
Parameters:
addr | Address to send to |
bool mediaFormatChanged (IAXTransaction* trans, int type, u_int32_t format)
| mediaFormatChanged |
[virtual]
Process a new format received with a full frame
Parameters:
trans | Transaction that received the new format |
type | Media type |
format | The received format |
Returns: True if accepted
bool checkCallToken (const SocketAddr& addr, IAXFullFrame& frame)
| checkCallToken |
[virtual]
Check call token on incoming call requests. This method is called by the engine when processing an incoming call request
Parameters:
addr | The address from where the call request was received |
frame | Received frame |
Returns: True if accepted, false to ignore the call
bool acceptFormatAndCapability (IAXTransaction* trans, unsigned int* caps = 0,
int type = IAXFormat::Audio)
| acceptFormatAndCapability |
Process the initial received format and capability. If accepted on exit will set the transaction format and capability
Parameters:
trans | Transaction that received the new format |
caps | Optional codecs to set in transaction before processing |
type | Media type |
Returns: True if accepted
void defaultEventHandler (IAXEvent* event)
| defaultEventHandler |
[virtual]
Default event handler. event MUST NOT be deleted
Parameters:
event | The event to handle |
inline bool exiting ()
| exiting |
[const]
Check if the engine is exiting
Returns: True if the engine is exiting
void setExiting ()
| setExiting |
[virtual]
Set the exiting flag
void enableTrunking (IAXTransaction* trans, const NamedList* params,
const String& prefix = String::empty())
| enableTrunking |
Enable trunking for the given transaction. Allocate a trunk meta frame if needed. Trunk data is ignored if a trunk object for transaction remote address already exists
Parameters:
trans | Transaction to enable trunking for |
params | Trunk parameters list, may be 0 |
prefix | Trunk parameters name prefix |
void enableTrunking (IAXTransaction* trans, IAXTrunkInfo& data)
| enableTrunking |
Enable trunking for the given transaction. Allocate a trunk meta frame if needed. Trunk data is ignored if a trunk object for transaction remote address already exists
Parameters:
trans | Transaction to enable trunking for |
data | Trunk info to use |
void initTrunkIn (IAXTransaction* trans, const NamedList* params,
const String& prefix = String::empty())
| initTrunkIn |
Init incoming trunking data for a given transaction
Parameters:
trans | Transaction to init |
params | Trunk parameters list, may be 0 |
prefix | Trunk parameters name prefix |
void initTrunkIn (IAXTransaction* trans, IAXTrunkInfo& data)
| initTrunkIn |
Init incoming trunking data for a given transaction
Parameters:
trans | Transaction to init |
data | Trunk info to use |
inline bool trunkInfo (RefPointer | trunkInfo |
Retrieve the default trunk info data
Parameters:
info | Destination to be set with trunk info pointer |
Returns: True if destination pointr is valid
void sendInval (IAXFullFrame* frame, const SocketAddr& addr)
| sendInval |
Send an INVAL frame
Parameters:
frame | Frame for which to send an INVAL frame |
addr | The address from where the call request was received |
void runProcessTrunkFrames ()
| runProcessTrunkFrames |
Keep calling processTrunkFrames to send trunked media data
inline Socket& socket ()
| socket |
Get the socket used for engine operation
Returns: Reference to the UDP socket
inline const SocketAddr& addr ()
| addr |
[const]
Retrieve the socket address on wgich we are bound
Returns: Local address we are bound on
inline void setFormats (u_int32_t caps, u_int32_t fmtAudio, u_int32_t fmtVideo)
| setFormats |
Send engine formats
Parameters:
caps | Capabilities |
fmtAudio | Default audio format |
fmtVideo | Default video format |
inline int getPort (const NamedList& params, const String& param = "port")
| getPort |
[static]
Retrieve a port parameter
Parameters:
params | Parameters list |
param | Parameter to retrieve |
Returns: The port (default, 4569, if the parameter is missing or invalid)
void getMD5FromChallenge (String& md5data, const String& challenge, const String& password)
| getMD5FromChallenge |
[static]
Get the MD5 data from a challenge and a password
Parameters:
md5data | Destination String |
challenge | Challenge source |
password | Password source |
bool isMD5ChallengeCorrect (const String& md5data, const String& challenge, const String& password)
| isMD5ChallengeCorrect |
[static]
Test if a received response to an authentication request is correct
Parameters:
md5data | Data to compare with |
challenge | Received challenge |
password | Password source |
void buildAddrSecret (String& buf, const String& secret,
const SocketAddr& addr)
| buildAddrSecret |
[static]
Build a time signed secret used to authenticate an IP address
Parameters:
buf | Destination buffer |
secret | Extra secret to add to MD5 sum |
addr | Socket address |
int addrSecretAge (const String& buf, const String& secret,
const SocketAddr& addr)
| addrSecretAge |
[static]
Decode a secret built using buildAddrSecret()
Parameters:
buf | Input buffer |
secret | Extra secret to check |
addr | Socket address |
Returns: Secret age, negative if invalid
inline void addKeyword (NamedList& list, const char* param,
const TokenDict* tokens, unsigned int val)
| addKeyword |
[static]
Add string (keyword) if found in a dictionary or integer parameter to a named list
Parameters:
list | Destination list |
param | Parameter to add to the list |
tokens | The dictionary used to find the given value |
val | The value to find/add to the list |
void decodeDateTime (u_int32_t dt, unsigned int& year, unsigned int& month,
unsigned int& day, unsigned int& hour, unsigned int& minute, unsigned int& sec)
| decodeDateTime |
[static]
Decode a DATETIME value
Parameters:
dt | Value to decode |
year | The year component of the date |
month | The month component of the date |
day | The day component of the date |
hour | The hour component of the time |
minute | The minute component of the time |
sec | The seconds component of the time |
unsigned int overallTout (unsigned int interval = IAX2_RETRANS_INTERVAL_DEF,
unsigned int nRetrans = IAX2_RETRANS_COUNT_DEF)
| overallTout |
[static]
Calculate overall timeout from interval and retransmission counter
Parameters:
interval | The first retransmisssion interval |
nRetrans | The number of retransmissions |
Returns: The overall timeout
bool processTrunkFrames (const Time& time = Time())
| processTrunkFrames |
[protected]
Process all trunk meta frames in the queue
Parameters:
time | Time of the call |
Returns: True if at least one frame was sent
void processEvent (IAXEvent* event)
| processEvent |
[protected virtual]
Default event for connection transactions handler. This method may be overriden to perform custom processing This method is thread safe
Parameters:
event | Event to process |
IAXEvent* getEvent (const Time& now = Time())
| getEvent |
[protected]
Get an IAX event from the queue. This method is thread safe.
Parameters:
now | Current time |
Returns: Pointer to an IAXEvent or 0 if none is available
u_int16_t generateCallNo ()
| generateCallNo |
[protected]
Generate call number. Update used call numbers list
Returns: Call number or 0 if none available
void releaseCallNo (u_int16_t lcallno)
| releaseCallNo |
[protected]
Release a call number
Parameters:
lcallno | Call number to release |
IAXTransaction* startLocalTransaction (IAXTransaction::Type type,
const SocketAddr& addr, IAXIEList& ieList,
bool refTrans = false, bool startTrans = true)
| startLocalTransaction |
[protected]
Start a transaction based on a local request
Parameters:
type | Transaction type |
addr | Remote address to send the request |
ieList | First frame IE list |
refTrans | Return a refferenced transaction pointer |
startTrans | Start transaction |
Returns: IAXTransaction pointer on success
bool bind (const char* iface, int port, bool force)
| bind |
[protected]
Bind the socket. Terminate it before trying
Parameters:
iface | Address of the interface to use, default all (0.0.0.0) |
port | UDP port to run the protocol on |
force | Force binding if failed on required port |
Returns: True on success
int m_trunking | m_trunking |
[protected]
Generated by: paulc on bussard on Thu Jul 24 18:41:02 2014, using kdoc 2.0a54. |