|
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 |
| const char * | typeName () |
| State | state () const |
| const char * | stateName () |
| 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 () |
| IAXFormat * | getFormat (int type) |
| IAXMediaData * | getData (int type) |
| u_int32_t | format (int type) |
| u_int32_t | formatIn (int type) |
| u_int32_t | formatOut (int type) |
| u_int32_t | capability () const |
| u_int32_t | expire () const |
| const String & | authdata () |
| void | setDestroy () |
| void | start () |
| IAXTransaction * | processFrame (IAXFrame *frame) |
| IAXTransaction * | processMedia (DataBlock &data, u_int32_t tStamp, int type=IAXFormat::Audio, bool full=false, bool mark=false) |
| unsigned int | sendMedia (const DataBlock &data, unsigned int tStamp, u_int32_t format, int type=IAXFormat::Audio, bool mark=false) |
| IAXEvent * | getEvent (const Time &now=Time()) |
| bool | sendAnswer () |
| bool | sendRinging () |
| bool | sendProgress () |
| bool | sendAccept (unsigned int *expires=0) |
| 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, bool efficientUse) |
| void | processCallToken (const DataBlock &callToken) |
| void | processMiniNoTs (u_int32_t ts, ObjList &blocks, const Time &now=Time()) |
| void | print (bool printStats=false, bool printFrames=false, const char *location="status") |
Public Member Functions inherited from RefObject | |
| RefObject () | |
| virtual | ~RefObject () |
| virtual void * | getObject (const String &name) const |
| virtual bool | alive () const |
| bool | ref () |
| bool | deref () |
| int | refcount () const |
| virtual void | destruct () |
Public Member Functions inherited from GenObject | |
| GenObject () | |
| virtual | ~GenObject () |
| virtual const String & | toString () const |
| virtual const String & | traceId () const |
| NamedCounter * | getObjCounter () const |
| NamedCounter * | setObjCounter (NamedCounter *counter) |
Public Member Functions inherited from Mutex | |
| Mutex (bool recursive=false, const char *name=0) | |
| Mutex (const Mutex &original) | |
| ~Mutex () | |
| Mutex & | operator= (const Mutex &original) |
| virtual bool | lock (long maxwait=-1) |
| virtual bool | unlock () |
| virtual bool | locked () const |
| const char * | owner () const |
| bool | recursive () const |
Public Member Functions inherited from Lockable | |
| virtual | ~Lockable () |
| virtual bool | check (long maxwait=-1) |
| virtual bool | unlockAll () |
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 const char * | typeName (int type) |
| static const char * | stateName (int state) |
Static Public Member Functions inherited from RefObject | |
| static bool | alive (const RefObject *obj) |
| static bool | efficientIncDec () |
Static Public Member Functions inherited from GenObject | |
| static void * | getObject (const String &name, const GenObject *obj) |
| static bool | getObjCounting () |
| static void | setObjCounting (bool enable) |
| static NamedCounter * | getObjCounter (const String &name, bool create=true) |
| static ObjList & | getObjCounters () |
Static Public Member Functions inherited from Mutex | |
| static int | count () |
| static int | locks () |
| static bool | efficientTimedLock () |
Static Public Member Functions inherited from Lockable | |
| static void | wait (unsigned long maxwait) |
| static unsigned long | wait () |
| static void | startUsingNow () |
| static void | enableSafety (bool safe=true) |
| static bool | safety () |
Static Public Attributes | |
| static const TokenDict | s_typeName [] |
| static const TokenDict | s_stateName [] |
| 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) | |
| virtual void | destroyed () |
| 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, IAXFullFrame *frame=0, bool createIEList=true) |
| IAXEvent * | waitForTerminate (u_int8_t evType=0, bool local=true, IAXFullFrame *frame=0) |
| 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 mark=false) |
| void | postFrameIes (IAXFrame::Type type, u_int32_t subclass, IAXIEList *ies, u_int32_t tStamp=0, bool ackOnly=false) |
| bool | sendFrame (IAXFrameOut *frame, bool vnak=false) |
| IAXEvent * | createEvent (u_int8_t evType, bool local, 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 | sendVNAK () |
| void | sendUnsupport (u_int32_t subclass) |
| IAXEvent * | processInternalOutgoingRequest (IAXFrameOut *frame, bool &delFrame) |
| IAXEvent * | processInternalIncomingRequest (const IAXFullFrame *frame, bool &delFrame) |
| IAXEvent * | processMidCallControl (IAXFullFrame *frame, bool &delFrame) |
| IAXEvent * | processMidCallIAXControl (IAXFullFrame *frame, bool &delFrame) |
| IAXEvent * | remoteRejectCall (IAXFullFrame *frame, bool &delFrame) |
| IAXTransaction * | processMediaFrame (const IAXFullFrame *frame, int type) |
| IAXTransaction * | retransmitOnVNAK (u_int16_t seqNo) |
| IAXEvent * | internalReject (const char *reason, u_int8_t code) |
| void | eventTerminated (IAXEvent *event) |
| IAXEvent * | keepEvent (IAXEvent *event) |
Protected Member Functions inherited from RefObject | |
| virtual void | zeroRefs () |
| bool | resurrect () |
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 |
Destructor
|
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 |
Referenced by factoryIn(), factoryOut(), processFrame(), processMedia(), processMediaFrame(), and retransmitOnVNAK().
|
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 |
References type().
| bool abortReg | ( | ) |
Abort a registration transaction This method is thread safe
|
protected |
Acknoledge the last received full frame
|
inline |
Retrieve the authentication data sent/received during authentication
|
inline |
Retrieve the called context
|
inline |
Retrieve the called number
|
inline |
Retrieve the calling name
|
inline |
Retrieve the calling number
|
inline |
Retrieve the media capability of this transaction
|
inline |
Retrieve the challenge sent/received during authentication
|
protected |
Change the transaction state
| newState | the new transaction state |
|
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 |
|
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 |
|
protectedvirtual |
Cleanup
Reimplemented from RefObject.
| bool enableTrunking | ( | IAXMetaTrunkFrame * | trunkFrame, |
| bool | efficientUse ) |
Enable trunking for this transaction
| trunkFrame | Pointer to IAXMetaTrunkFrame used to send trunked media |
| efficientUse | Use or not the trunk based on calls using it |
|
protected |
Event terminated feedback This method is thread safe
| event | The event notifying termination |
|
inline |
Retrieve the expiring time for a register/unregister transaction
|
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 |
References IAXTransaction().
|
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 |
References IAXTransaction(), and type().
|
protected |
Search for a frame in m_inFrames having the given type and subclass
| type | Frame type to find. |
| subclass | Frame subclass to find. |
References type().
|
protected |
Search in m_inFrames for an ACK frame which confirm the received frame and deletes it
| frameOut | Frame to find response for |
|
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 |
References type().
|
inline |
Retrieve the media format used during initialization
| type | Media type to retrieve |
References IAXFormat::format(), getFormat(), and type().
Referenced by sendMedia().
|
inline |
Retrieve the incoming media format
| type | Media type to retrieve |
References getFormat(), IAXFormat::in(), and type().
|
inline |
Retrieve the outgoing media format
| type | Media type to retrieve |
References getFormat(), IAXFormat::out(), and type().
|
inline |
Retrieve the media data for a given type
| type | Media type to retrieve |
References type().
|
inline |
The IAX engine this transaction belongs to
Get an IAX event from the queue This method is thread safe.
| now | Current time |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
inline |
Retrieve the media of a given type
| type | Media type to retrieve |
References type().
Referenced by format(), formatIn(), and formatOut().
|
static |
Get the maximum allowed number of full frames in the incoming frame list
|
inline |
Return the opaque user data stored in the transaction
|
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 |
|
protected |
Init data members from an IE list
| ieList | IE list to init from |
|
protected |
Generate a Reject event after internally rejecting a transaction
| reason | The reason of rejecting |
| code | Error code |
|
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 |
|
inline |
Retrieve the local call number
|
inline |
Get the direction of this transaction
|
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 |
| mark | Frame mark flag |
References type().
|
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 |
| ies | Frame IE list |
| tStamp | Frame timestamp. If 0 the transaction timestamp will be used |
| ackOnly | Frame's acknoledge only flag |
References type().
| void print | ( | bool | printStats = false, |
| bool | printFrames = false, | ||
| const char * | location = "status" ) |
Print transaction data on stdin
| printStats | True to print media statistics |
| printFrames | True to print in/out pending frames |
| location | Additional location info to be shown in debug |
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 |
| void processCallToken | ( | const DataBlock & | callToken | ) |
Process a received call token This method is thread safe
| callToken | Received call token |
| IAXTransaction * processFrame | ( | IAXFrame * | frame | ) |
Process a frame from remote peer. This method is thread safe
| frame | IAX frame belonging to this transaction to process |
References IAXTransaction().
|
protected |
Internal protocol incoming frames processing (PING/LAGRQ)
| frame | Frame to process |
| delFrame | Delete frame flag. If true on exit, a request was found |
|
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, | ||
| int | type = IAXFormat::Audio, | ||
| bool | full = false, | ||
| bool | mark = false ) |
Process received media data
| data | Received data |
| tStamp | Mini frame timestamp multiplied by format multiplier |
| type | Media type |
| full | True if received in a full frame |
| mark | Mark flag |
References IAXTransaction(), and type().
|
protected |
Process received media full frames
| frame | Received frame |
| type | Media type |
References IAXTransaction(), and type().
|
protected |
Process mid call control frames
| frame | Frame to process |
| delFrame | Delete frame flag. If true on exit, a request was found |
|
protected |
Process mid call IAX control frames
| frame | Frame to process |
| delFrame | Delete frame flag. If true on exit, a request was found |
Process incoming audio miniframes from trunk without timestamps
| ts | Trunk frame timestamp |
| blocks | Received blocks |
| now | Current time |
Update transaction data from the event
| event | Already generated event |
|
inline |
Retrieve the remote host+port address
|
inline |
Retrieve the remote call number
|
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 |
|
protected |
Send all frames from outgoing queue with outbound sequence number starting with seqNo.
| seqNo | Requested sequence number |
References IAXTransaction().
| bool sendAccept | ( | unsigned int * | expires = 0 | ) |
Send an ACCEPT/REGACK frame to remote peer This method is thread safe
| expires | Optional pointer to expiring time for register transactions |
|
protected |
Send an ACK frame
| frame | Aknoledged frame |
|
inline |
Send an ANSWER frame to remote peer This method is thread safe
References sendConnected().
| 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 |
|
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 |
Referenced by sendAnswer(), sendDtmf(), sendNoise(), sendProgress(), and sendRinging().
|
inline |
Send a DTMF frame to remote peer This method is thread safe
| dtmf | DTMF char to send |
References sendConnected().
|
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 |
| unsigned int sendMedia | ( | const DataBlock & | data, |
| unsigned int | tStamp, | ||
| u_int32_t | format, | ||
| int | type = IAXFormat::Audio, | ||
| bool | mark = false ) |
|
inline |
Send a NOISE frame to remote peer This method is thread safe
| noise | Noise value to send |
References sendConnected().
|
inline |
Send a PROCEEDING frame to remote peer This method is thread safe
References sendConnected().
| 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 |
|
inline |
Send a RINGING frame to remote peer This method is thread safe
References sendConnected().
| bool sendText | ( | const char * | text | ) |
Send a TEXT frame to remote peer This method is thread safe
| text | Text to send |
|
protected |
Send an Unsupport frame
| subclass | Unsupported frame's subclass |
|
protected |
Send an VNAK frame
|
inline |
Set the destroy flag
|
static |
Set the maximum allowed number of full frames in the incoming frame list
| value | The new value of m_maxInFrames |
|
inline |
Store a pointer to arbitrary user data
| data | User provided pointer |
| void start | ( | ) |
Start an outgoing transaction. This method is thread safe
|
inline |
Get the state of this transaction
Referenced by stateName(), and stateName().
|
inline |
Retrieve the transaction state name
References state(), and stateName().
Referenced by stateName().
|
inlinestatic |
Retrieve transaction state name
| state | Transaction state |
References s_stateName, and state().
|
protected |
|
inline |
Get the timestamp of this transaction
References Time::msecNow().
|
inline |
Get the type of this transaction
Referenced by factoryOut(), findInFrame(), findInFrameTimestamp(), format(), formatIn(), formatOut(), getData(), getFormat(), IAXTransaction(), postFrame(), postFrameIes(), processMedia(), processMediaFrame(), sendMedia(), typeName(), and typeName().
|
inline |
Retrieve transaction type name
References type(), and typeName().
Referenced by typeName().
|
inlinestatic |
Retrieve transaction type name from transaction type
| type | Transaction type |
References s_typeName, and type().
|
inline |
Retrieve the username
|
protected |
|
static |
Standard message sent if the received authentication data is incorrect
|
static |
Standard message sent if unsupported/unknown/none authentication methosd was received
|
static |
Standard message sent if unsupported/unknown/none media format was received
|
static |
Standard message sent if a received frame doesn't have an username information element
|
static |
Transaction state name
Referenced by stateName().
|
static |
Transaction type name
Referenced by typeName().