Yate
|
An IAX2 transaction. More...
#include <yateiax.h>
Public Types | |
enum | Type { Incorrect, New, RegReq, RegRel, Poke } |
enum | State { Connected, NewLocalInvite, NewLocalInvite_AuthRecv, NewLocalInvite_RepSent, NewRemoteInvite, NewRemoteInvite_AuthSent, NewRemoteInvite_RepRecv, Unknown, Terminated, Terminating } |
Public Member Functions | |
virtual | ~IAXTransaction () |
IAXEngine * | getEngine () const |
Type | type () const |
State | state () const |
u_int64_t | timeStamp () const |
bool | outgoing () const |
void | setUserData (void *data) |
void * | getUserData () const |
u_int16_t | localCallNo () const |
u_int16_t | remoteCallNo () const |
const SocketAddr & | remoteAddr () const |
const String & | username () |
const String & | callingNo () |
const String & | callingName () |
const String & | calledNo () |
const String & | calledContext () |
const String & | challenge () |
u_int32_t | format () |
u_int32_t | formatIn () |
u_int32_t | formatOut () const |
u_int32_t | capability () const |
u_int32_t | expire () const |
const String & | authdata () |
IAXTransaction * | processFrame (IAXFrame *frame) |
IAXTransaction * | processMedia (DataBlock &data, u_int32_t tStamp, bool voice=false) |
IAXTransaction * | sendMedia (const DataBlock &data, u_int32_t format) |
IAXEvent * | getEvent (u_int64_t time) |
bool | sendAnswer () |
bool | sendRinging () |
bool | sendProgress () |
bool | sendAccept () |
bool | sendHangup (const char *cause=0, u_int8_t code=0) |
bool | sendReject (const char *cause=0, u_int8_t code=0) |
bool | sendAuth () |
bool | sendAuthReply (const String &response) |
bool | sendDtmf (u_int8_t dtmf) |
bool | sendText (const char *text) |
bool | sendNoise (u_int8_t noise) |
bool | abortReg () |
bool | enableTrunking (IAXMetaTrunkFrame *trunkFrame) |
void | print () |
Static Public Member Functions | |
static IAXTransaction * | factoryIn (IAXEngine *engine, IAXFullFrame *frame, u_int16_t lcallno, const SocketAddr &addr, void *data=0) |
static IAXTransaction * | factoryOut (IAXEngine *engine, Type type, u_int16_t lcallno, const SocketAddr &addr, IAXIEList &ieList, void *data=0) |
static unsigned char | getMaxFrameList () |
static bool | setMaxFrameList (unsigned char value) |
Static Public Attributes | |
static String | s_iax_modNoAuthMethod |
static String | s_iax_modNoMediaFormat |
static String | s_iax_modInvalidAuth |
static String | s_iax_modNoUsername |
Protected Member Functions | |
IAXTransaction (IAXEngine *engine, IAXFullFrame *frame, u_int16_t lcallno, const SocketAddr &addr, void *data=0) | |
IAXTransaction (IAXEngine *engine, Type type, u_int16_t lcallno, const SocketAddr &addr, IAXIEList &ieList, void *data=0) | |
void | init (IAXIEList &ieList) |
bool | incrementSeqNo (const IAXFullFrame *frame, bool inbound) |
bool | isFrameAcceptable (const IAXFullFrame *frame) |
bool | changeState (State newState) |
IAXEvent * | terminate (u_int8_t evType, bool local, const IAXFullFrame *frame=0, bool createIEList=true) |
IAXEvent * | waitForTerminate (u_int8_t evType, bool local, const IAXFullFrame *frame) |
void | postFrame (IAXFrame::Type type, u_int32_t subclass, void *data=0, u_int16_t len=0, u_int32_t tStamp=0, bool ackOnly=false) |
bool | sendFrame (IAXFrameOut *frame, bool vnak=false) |
IAXEvent * | createEvent (u_int8_t evType, bool local, const IAXFullFrame *frame, State newState) |
IAXEvent * | createResponse (IAXFrameOut *frame, u_int8_t findType, u_int8_t findSubclass, u_int8_t evType, bool local, State newState) |
IAXEvent * | getEventResponse (IAXFrameOut *frame, bool &delFrame) |
IAXEvent * | getEventResponse_New (IAXFrameOut *frame, bool &delFrame) |
IAXEvent * | processAuthReq (IAXEvent *event) |
IAXEvent * | processAccept (IAXEvent *event) |
IAXEvent * | processAuthRep (IAXEvent *event) |
IAXEvent * | getEventResponse_Reg (IAXFrameOut *frame, bool &delFrame) |
IAXEvent * | processRegAck (IAXEvent *event) |
IAXEvent * | getEventStartTrans (IAXFullFrame *frame, bool &delFrame) |
IAXEvent * | getEventRequest (IAXFullFrame *frame, bool &delFrame) |
IAXEvent * | getEventRequest_New (IAXFullFrame *frame, bool &delFrame) |
IAXFullFrame * | findInFrame (IAXFrame::Type type, u_int32_t subclass) |
bool | findInFrameTimestamp (const IAXFullFrame *frameOut, IAXFrame::Type type, u_int32_t subclass) |
bool | findInFrameAck (const IAXFullFrame *frameOut) |
void | ackInFrames () |
bool | sendConnected (IAXFullFrame::ControlType subclass, IAXFrame::Type frametype=IAXFrame::Control) |
void | sendAck (const IAXFullFrame *frame) |
void | sendInval () |
void | sendVNAK () |
void | sendUnsupport (u_int32_t subclass) |
IAXEvent * | processInternalOutgoingRequest (IAXFrameOut *frame, bool &delFrame) |
IAXEvent * | processInternalIncomingRequest (const IAXFullFrame *frame, bool &delFrame) |
IAXEvent * | processMidCallControl (const IAXFullFrame *frame, bool &delFrame) |
IAXEvent * | processMidCallIAXControl (const IAXFullFrame *frame, bool &delFrame) |
IAXEvent * | remoteRejectCall (const IAXFullFrame *frame, bool &delFrame) |
IAXEvent * | getEventTerminating (u_int64_t time) |
IAXTransaction * | processVoiceFrame (const IAXFullFrame *frame) |
IAXTransaction * | retransmitOnVNAK (u_int16_t seqNo) |
IAXEvent * | internalAccept () |
IAXEvent * | internalReject (String &reason) |
void | eventTerminated (IAXEvent *event) |
IAXEvent * | keepEvent (IAXEvent *event) |
Friends | |
class | IAXEvent |
class | IAXEngine |
An IAX2 transaction.
This class holds all the data needded for the management of an IAX2 transaction which might be a call leg, a register/unregister or a poke one
enum State |
The transaction state as enumeration
enum Type |
The transaction type as enumeration
virtual ~IAXTransaction | ( | ) | [virtual] |
Destructor
IAXTransaction | ( | IAXEngine * | engine, |
IAXFullFrame * | frame, | ||
u_int16_t | lcallno, | ||
const SocketAddr & | addr, | ||
void * | data = 0 |
||
) | [protected] |
Constructor: constructs an incoming transaction from a received full frame with an IAX control message that needs a new transaction
engine | The engine that owns this transaction |
frame | A valid full frame |
lcallno | Local call number |
addr | Address from where the frame was received |
data | Pointer to arbitrary user data |
IAXTransaction | ( | IAXEngine * | engine, |
Type | type, | ||
u_int16_t | lcallno, | ||
const SocketAddr & | addr, | ||
IAXIEList & | ieList, | ||
void * | data = 0 |
||
) | [protected] |
Constructor: constructs an outgoing transaction with an IAX control message that needs a new transaction
engine | The engine that owns this transaction |
type | Transaction type: see Type enumeration |
lcallno | Local call number |
addr | Address to use |
ieList | Starting IE list |
data | Pointer to arbitrary user data |
bool abortReg | ( | ) |
Abort a registration transaction This method is thread safe
void ackInFrames | ( | ) | [protected] |
Acknoledge the last received full frame
const String& authdata | ( | ) | [inline] |
Retrive the authentication data sent/received during authentication
const String& calledContext | ( | ) | [inline] |
Retrive the called context
const String& calledNo | ( | ) | [inline] |
Retrive the called number
const String& callingName | ( | ) | [inline] |
Retrive the calling name
const String& callingNo | ( | ) | [inline] |
Retrive the calling number
u_int32_t capability | ( | ) | const [inline] |
Retrive the media capability of this transaction
const String& challenge | ( | ) | [inline] |
Retrive the challenge sent/received during authentication
bool changeState | ( | State | newState | ) | [protected] |
Change the transaction state
newState | the new transaction state |
IAXEvent* createEvent | ( | u_int8_t | evType, |
bool | local, | ||
const IAXFullFrame * | frame, | ||
State | newState | ||
) | [protected] |
Create an event
evType | Event type |
local | If true it is a locally generated event. |
frame | Frame to create from |
newState | The transaction new state |
IAXEvent* createResponse | ( | IAXFrameOut * | frame, |
u_int8_t | findType, | ||
u_int8_t | findSubclass, | ||
u_int8_t | evType, | ||
bool | local, | ||
State | newState | ||
) | [protected] |
Create an event from a received frame that is a response to a sent frame and change the transaction state to newState. Remove the response from incoming list.
frame | Frame to create response for |
findType | Frame type to find |
findSubclass | Frame subclass to find |
evType | Event type to generate |
local | Local flag for the generated event. |
newState | New transaction state if an event was generated |
bool enableTrunking | ( | IAXMetaTrunkFrame * | trunkFrame | ) |
Enable trunking for this transaction
trunkFrame | Pointer to IAXMetaTrunkFrame used to send trunked media |
void eventTerminated | ( | IAXEvent * | event | ) | [protected] |
Event terminated feedback This method is thread safe
event | The event notifying termination |
u_int32_t expire | ( | ) | const [inline] |
Retrive the expiring time for a register/unregister transaction
static IAXTransaction* factoryIn | ( | IAXEngine * | engine, |
IAXFullFrame * | frame, | ||
u_int16_t | lcallno, | ||
const SocketAddr & | addr, | ||
void * | data = 0 |
||
) | [static] |
Constructs an incoming transaction from a received full frame with an IAX control message that needs a new transaction
engine | The engine that owns this transaction |
frame | A valid full frame |
lcallno | Local call number |
addr | Address from where the frame was received |
data | Pointer to arbitrary user data |
static IAXTransaction* factoryOut | ( | IAXEngine * | engine, |
Type | type, | ||
u_int16_t | lcallno, | ||
const SocketAddr & | addr, | ||
IAXIEList & | ieList, | ||
void * | data = 0 |
||
) | [static] |
Constructs an outgoing transaction with an IAX control message that needs a new transaction
engine | The engine that owns this transaction |
type | Transaction type |
lcallno | Local call number |
addr | Address to use |
ieList | Starting IE list |
data | Pointer to arbitrary user data |
IAXFullFrame* findInFrame | ( | IAXFrame::Type | type, |
u_int32_t | subclass | ||
) | [protected] |
Search for a frame in m_inFrames having the given type and subclass
type | Frame type to find. |
subclass | Frame subclass to find. |
bool findInFrameAck | ( | const IAXFullFrame * | frameOut | ) | [protected] |
Search in m_inFrames for an ACK frame which confirm the received frame and deletes it
frameOut | Frame to find response for |
bool findInFrameTimestamp | ( | const IAXFullFrame * | frameOut, |
IAXFrame::Type | type, | ||
u_int32_t | subclass | ||
) | [protected] |
Search in m_inFrames for a frame with the same timestamp as frameOut and deletes it.
frameOut | Frame to find response for |
type | Frame type to find |
subclass | Frame subclass to find |
u_int32_t format | ( | ) | [inline] |
Retrive the media format used during initialization
u_int32_t formatIn | ( | ) | [inline] |
Retrive the incoming media format
u_int32_t formatOut | ( | ) | const [inline] |
Retrive the outgoing media format
IAXEngine* getEngine | ( | ) | const [inline] |
The IAX engine this transaction belongs to
IAXEvent* getEvent | ( | u_int64_t | time | ) |
Get an IAX event from the queue This method is thread safe.
time | The time this method was called |
IAXEvent* getEventRequest | ( | IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Find out if a frame is a remote request
frame | Frame to process |
delFrame | Delete rame flag. If true on exit, a request was found |
IAXEvent* getEventRequest_New | ( | IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Find out if a frame is a remote request if transaction type is New
frame | Frame to process |
delFrame | Delete rame flag. If true on exit, a request was found |
IAXEvent* getEventResponse | ( | IAXFrameOut * | frame, |
bool & | delFrame | ||
) | [protected] |
Find a response for a previously sent frame
frame | Frame to find response for |
delFrame | Delete frame flag. If true on exit, a response was found |
IAXEvent* getEventResponse_New | ( | IAXFrameOut * | frame, |
bool & | delFrame | ||
) | [protected] |
Find a response for a previously sent frame if the transaction type is New
frame | Frame to find response for |
delFrame | Delete frame flag. If true on exit, a response was found |
IAXEvent* getEventResponse_Reg | ( | IAXFrameOut * | frame, |
bool & | delFrame | ||
) | [protected] |
Find a response for a previously sent frame if the transaction type is RegReq/RegRel
frame | Frame to find response for |
delFrame | Delete frame flag. If true on exit, a response was found |
IAXEvent* getEventStartTrans | ( | IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Find out if an incoming frame would start a transaction
frame | Frame to process |
delFrame | Delete frame flag. If true on exit, frame is valid |
IAXEvent* getEventTerminating | ( | u_int64_t | time | ) | [protected] |
Terminate the transaction if state is Terminating on a remote request
time | Current time |
static unsigned char getMaxFrameList | ( | ) | [static] |
Get the maximum allowed number of full frames in the incoming frame list
void* getUserData | ( | ) | const [inline] |
Return the opaque user data stored in the transaction
Referenced by IAXEvent::getUserData().
bool incrementSeqNo | ( | const IAXFullFrame * | frame, |
bool | inbound | ||
) | [protected] |
Increment sequence numbers (inbound or outbound) for the frames that need it
frame | Received frame if inbound is true, otherwise a transmitted one |
inbound | True for inbound frames |
void init | ( | IAXIEList & | ieList | ) | [protected] |
Init data members from an IE list
ieList | IE list to init from |
IAXEvent* internalAccept | ( | ) | [protected] |
Generate an Accept event after internally accepting a transaction
Generate a Reject event after internally rejecting a transaction
reason | The reason of rejecting |
bool isFrameAcceptable | ( | const IAXFullFrame * | frame | ) | [protected] |
Test if frame is acceptable (not an out of order or a late one)
frame | Frame to test |
Set the current event
event | The event notifying termination |
u_int16_t localCallNo | ( | ) | const [inline] |
Retrive the local call number
bool outgoing | ( | ) | const [inline] |
Get the direction of this transaction
void postFrame | ( | IAXFrame::Type | type, |
u_int32_t | subclass, | ||
void * | data = 0 , |
||
u_int16_t | len = 0 , |
||
u_int32_t | tStamp = 0 , |
||
bool | ackOnly = false |
||
) | [protected] |
Constructs an IAXFrameOut frame, send it to remote peer and put it in the transmission list This method is thread safe
type | Frame type |
subclass | Frame subclass |
data | Frame IE list |
len | Frame IE list length |
tStamp | Frame timestamp. If 0 the transaction timestamp will be used |
ackOnly | Frame's acknoledge only flag |
void print | ( | ) |
Print transaction data on stdin
Process an accept. If not valid (call m_engine->acceptFormatAndCapability) send a reject. Otherwise return the event
event | Already generated event |
Process an authentication reply
event | Already generated event |
Process an authentication request. If valid, send an authentication reply
event | Already generated event |
IAXTransaction* processFrame | ( | IAXFrame * | frame | ) |
Process a frame from remote peer This method is thread safe.
frame | IAX frame belonging to this transaction to process |
IAXEvent* processInternalIncomingRequest | ( | const IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Internal protocol incoming frames processing (PING/LAGRQ)
frame | Frame to process |
delFrame | Delete frame flag. If true on exit, a request was found |
IAXEvent* processInternalOutgoingRequest | ( | IAXFrameOut * | frame, |
bool & | delFrame | ||
) | [protected] |
Internal protocol outgoing frames processing (PING/LAGRQ)
frame | Frame to process |
delFrame | Delete frame flag. If true on exit, a response was found |
IAXTransaction* processMedia | ( | DataBlock & | data, |
u_int32_t | tStamp, | ||
bool | voice = false |
||
) |
Process received mini frame data
data | Received data |
tStamp | Mini frame timestamp |
voice | True if received mini frame inside a Voice full frame |
IAXEvent* processMidCallControl | ( | const IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Process mid call control frames
frame | Frame to process |
delFrame | Delete frame flag. If true on exit, a request was found |
IAXEvent* processMidCallIAXControl | ( | const IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Process mid call IAX control frames
frame | Frame to process |
delFrame | Delete frame flag. If true on exit, a request was found |
Update transaction data from the event
event | Already generated event |
IAXTransaction* processVoiceFrame | ( | const IAXFullFrame * | frame | ) | [protected] |
Process received Voice frames
frame | Received voice frame |
const SocketAddr& remoteAddr | ( | ) | const [inline] |
Retrive the remote host+port address
u_int16_t remoteCallNo | ( | ) | const [inline] |
Retrive the remote call number
IAXEvent* remoteRejectCall | ( | const IAXFullFrame * | frame, |
bool & | delFrame | ||
) | [protected] |
Test if frame is a Reject/RegRej frame
frame | Frame to process. |
delFrame | Delete frame flag. If true on exit, a request was found |
IAXTransaction* retransmitOnVNAK | ( | u_int16_t | seqNo | ) | [protected] |
Send all frames from outgoing queue with outbound sequence number starting with seqNo.
seqNo | Requested sequence number |
bool sendAccept | ( | ) |
Send an ACCEPT/REGACK frame to remote peer This method is thread safe
void sendAck | ( | const IAXFullFrame * | frame | ) | [protected] |
Send an ACK frame
frame | Aknoledged frame |
bool sendAnswer | ( | ) | [inline] |
Send an ANSWER frame to remote peer This method is thread safe
bool sendAuth | ( | ) |
Send an AUTHREQ/REGAUTH frame to remote peer This method is thread safe
bool sendAuthReply | ( | const String & | response | ) |
Send an AUTHREP/REGREQ/REGREL frame to remote peer as a response to AUTHREQ/REGREQ/REGREL This method is thread safe
response | Response to send |
bool sendConnected | ( | IAXFullFrame::ControlType | subclass, |
IAXFrame::Type | frametype = IAXFrame::Control |
||
) | [protected] |
Send a frame to remote peer in state Connected This method is thread safe
subclass | Frame subclass to send |
frametype | Frame type to send |
bool sendDtmf | ( | u_int8_t | dtmf | ) | [inline] |
Send a DTMF frame to remote peer This method is thread safe
dtmf | DTMF char to send |
bool sendFrame | ( | IAXFrameOut * | frame, |
bool | vnak = false |
||
) | [protected] |
Send a full frame to remote peer
frame | Frame to send |
vnak | If true the transmission is a response to a VNAK frame |
bool sendHangup | ( | const char * | cause = 0 , |
u_int8_t | code = 0 |
||
) |
Send a HANGUP frame to remote peer This method is thread safe
cause | Optional reason for hangup |
code | Optional code of reason |
void sendInval | ( | ) | [protected] |
Send an INVAL frame
IAXTransaction* sendMedia | ( | const DataBlock & | data, |
u_int32_t | format | ||
) |
Send media data to remote peer. Update the outgoing media format if changed
data | Data to send |
format | Data format |
bool sendNoise | ( | u_int8_t | noise | ) | [inline] |
Send a NOISE frame to remote peer This method is thread safe
noise | Noise value to send |
bool sendProgress | ( | ) | [inline] |
Send a PROCEEDING frame to remote peer This method is thread safe
bool sendReject | ( | const char * | cause = 0 , |
u_int8_t | code = 0 |
||
) |
Send a REJECT/REGREJ frame to remote peer This method is thread safe
cause | Optional reason for reject |
code | Optional code of reason |
bool sendRinging | ( | ) | [inline] |
Send a RINGING frame to remote peer This method is thread safe
bool sendText | ( | const char * | text | ) |
Send a TEXT frame to remote peer This method is thread safe
text | Text to send |
void sendUnsupport | ( | u_int32_t | subclass | ) | [protected] |
Send an Unsupport frame
subclass | Unsupported frame's subclass |
void sendVNAK | ( | ) | [protected] |
Send an VNAK frame
static bool setMaxFrameList | ( | unsigned char | value | ) | [static] |
Set the maximum allowed number of full frames in the incoming frame list
value | The new value of m_maxInFrames |
void setUserData | ( | void * | data | ) | [inline] |
Store a pointer to arbitrary user data
data | User provided pointer |
State state | ( | ) | const [inline] |
Get the state of this transaction
IAXEvent* terminate | ( | u_int8_t | evType, |
bool | local, | ||
const IAXFullFrame * | frame = 0 , |
||
bool | createIEList = true |
||
) | [protected] |
u_int64_t timeStamp | ( | ) | const [inline] |
Get the timestamp of this transaction
References Time::msecNow().
Type type | ( | ) | const [inline] |
Get the type of this transaction
const String& username | ( | ) | [inline] |
Retrive the username
IAXEvent* waitForTerminate | ( | u_int8_t | evType, |
bool | local, | ||
const IAXFullFrame * | frame | ||
) | [protected] |
String s_iax_modInvalidAuth [static] |
Standard message sent if the received authentication data is incorrect
String s_iax_modNoAuthMethod [static] |
Standard message sent if unsupported/unknown/none authentication methosd was received
String s_iax_modNoMediaFormat [static] |
Standard message sent if unsupported/unknown/none media format was received
String s_iax_modNoUsername [static] |
Standard message sent if a received frame doesn't have an username information element