SIPTransaction Class Reference
A class holding one SIP transaction.
More...
#include <yatesip.h>
List of all members.
Public Types |
enum | State {
Invalid,
Initial,
Trying,
Process,
Retrans,
Finish,
Cleared
} |
enum | Processed { NoMatch,
NoDialog,
Matched
} |
Public Member Functions |
| SIPTransaction (SIPMessage *message, SIPEngine *engine, bool outgoing=true) |
| SIPTransaction (const SIPTransaction &original, const String &tag) |
virtual | ~SIPTransaction () |
int | getState () const |
bool | isActive () const |
const SIPMessage * | initialMessage () const |
const SIPMessage * | latestMessage () const |
const SIPMessage * | recentMessage () const |
SIPEngine * | getEngine () const |
bool | isOutgoing () const |
bool | isIncoming () const |
bool | isInvite () const |
bool | isReliable () const |
const String & | getMethod () const |
const String & | getURI () const |
const String & | getBranch () const |
const String & | getCallID () const |
const String & | getDialogTag () const |
void | setDialogTag (const char *tag=0) |
void | setTransmit () |
void | requestAuth (const String &realm, const String &domain, bool stale, bool proxy=false) |
int | authUser (String &user, bool proxy=false, GenObject *userData=0) |
virtual Processed | processMessage (SIPMessage *message, const String &branch) |
virtual void | processMessage (SIPMessage *message) |
virtual SIPEvent * | getEvent (bool pendingOnly=false) |
bool | setResponse (int code, const char *reason=0) |
void | setResponse (SIPMessage *message) |
int | getResponseCode () const |
void | setUserData (void *data) |
void * | getUserData () const |
Static Public Member Functions |
static const char * | stateName (int state) |
Protected Member Functions |
| SIPTransaction (SIPTransaction &original, SIPMessage *answer) |
virtual void | destroyed () |
bool | tryAutoAuth (SIPMessage *answer) |
virtual SIPEvent * | getClientEvent (int state, int timeout) |
virtual SIPEvent * | getServerEvent (int state, int timeout) |
virtual void | processClientMessage (SIPMessage *message, int state) |
virtual void | processServerMessage (SIPMessage *message, int state) |
bool | changeState (int newstate) |
void | setLatestMessage (SIPMessage *message=0) |
void | setPendingEvent (SIPEvent *event=0, bool replace=false) |
bool | isPendingEvent () const |
void | setTimeout (u_int64_t delay=0, unsigned int count=1) |
Protected Attributes |
bool | m_outgoing |
bool | m_invite |
bool | m_transmit |
int | m_state |
int | m_response |
unsigned int | m_timeouts |
u_int64_t | m_delay |
u_int64_t | m_timeout |
SIPMessage * | m_firstMessage |
SIPMessage * | m_lastMessage |
SIPEvent * | m_pending |
SIPEngine * | m_engine |
String | m_branch |
String | m_callid |
String | m_tag |
void * | m_private |
Detailed Description
A class holding one SIP transaction.
All informaton related to a SIP transaction, starting with 1st message
Member Enumeration Documentation
Current state of the transaction
Constructor & Destructor Documentation
Constructor from first message
- Parameters:
-
| message | A pointer to the initial message, should not be used afterwards as the transaction takes ownership |
| engine | A pointer to the SIP engine this transaction belongs |
| outgoing | True if this transaction is for an outgoing request |
Copy constructor to be used with forked INVITEs
- Parameters:
-
| original | Original transaction that is to be copied |
| tag | Dialog tag for the new transaction |
Destructor - clears all held objects
Constructor from previous auto authenticated transaction. This is used only internally
- Parameters:
-
| original | Original transaction that failed authentication |
| answer | SIP answer that creates the new transaction |
Member Function Documentation
int authUser |
( |
String & |
user, |
|
|
bool |
proxy = false , |
|
|
GenObject * |
userData = 0 | |
|
) |
| | |
Detect the proper credentials for any user in the engine
- Parameters:
-
| user | String to store the authenticated user name or user to look for (if not null on entry) |
| proxy | True to authenticate as proxy, false as user agent |
| userData | Pointer to an optional object that is passed back to SIPEngine::checkUser |
- Returns:
- Age of the nonce if user matches, negative for a failure
bool changeState |
( |
int |
newstate |
) |
[protected] |
Change the transaction state
- Parameters:
-
| newstate | The desired new state |
- Returns:
- True if state change occured
virtual void destroyed |
( |
|
) |
[protected, virtual] |
Pre-destruction notification used to clean up the transaction
Reimplemented from RefObject.
const String& getBranch |
( |
|
) |
const [inline] |
The Via branch that may uniquely identify this transaction
- Returns:
- The branch parameter taken from the Via header
const String& getCallID |
( |
|
) |
const [inline] |
The call ID may identify this transaction
- Returns:
- The Call-ID parameter taken from the message
virtual SIPEvent* getClientEvent |
( |
int |
state, |
|
|
int |
timeout | |
|
) |
| | [protected, virtual] |
Get an event only for client transactions
- Parameters:
-
| state | The current state of the transaction |
| timeout | If timeout occured, number of remaining timeouts, otherwise -1 |
- Returns:
- A newly allocated event or NULL if none is needed
const String& getDialogTag |
( |
|
) |
const [inline] |
The dialog tag that may identify this transaction
- Returns:
- The dialog tag parameter
virtual SIPEvent* getEvent |
( |
bool |
pendingOnly = false |
) |
[virtual] |
Get an event for this transaction if any is available. It provides default handling for invalid states, otherwise calls the more specific protected version. You may override this method if you need processing of invalid states.
- Parameters:
-
| pendingOnly | True to only return outgoing and pending events |
- Returns:
- A newly allocated event or NULL if none is needed
const String& getMethod |
( |
|
) |
const [inline] |
int getResponseCode |
( |
|
) |
const [inline] |
Retrive the latest response code
- Returns:
- Code of most recent response, zero if none is known
virtual SIPEvent* getServerEvent |
( |
int |
state, |
|
|
int |
timeout | |
|
) |
| | [protected, virtual] |
Get an event only for server transactions.
- Parameters:
-
| state | The current state of the transaction |
| timeout | If timeout occured, number of remaining timeouts, otherwise -1 |
- Returns:
- A newly allocated event or NULL if none is needed
int getState |
( |
|
) |
const [inline] |
The current state of the transaction
- Returns:
- The current state as one of the State enums
const String& getURI |
( |
|
) |
const [inline] |
void* getUserData |
( |
|
) |
const [inline] |
Return the opaque user data
const SIPMessage* initialMessage |
( |
|
) |
const [inline] |
The first message that created this transaction
bool isActive |
( |
|
) |
const [inline] |
Check if the transaction is active for the upper layer
- Returns:
- True if the transaction is active, false if it finished
bool isIncoming |
( |
|
) |
const [inline] |
Check if this transaction was initiated locally or by the remote peer
- Returns:
- True if the transaction was created by an incoming message
bool isInvite |
( |
|
) |
const [inline] |
Check if this transaction is an INVITE transaction or not
- Returns:
- True if the transaction is an INVITE
bool isOutgoing |
( |
|
) |
const [inline] |
Check if this transaction was initiated by the remote peer or locally
- Returns:
- True if the transaction was created by an outgoing message
bool isPendingEvent |
( |
|
) |
const [inline, protected] |
Check if there is a pending event waiting
- Returns:
- True is there is a pending event
bool isReliable |
( |
|
) |
const [inline] |
Check if this transaction is handled by a reliable protocol
- Returns:
- True if a reliable protocol (TCP, SCTP) is used
const SIPMessage* latestMessage |
( |
|
) |
const [inline] |
The last message (re)sent by this transaction
virtual void processClientMessage |
( |
SIPMessage * |
message, |
|
|
int |
state | |
|
) |
| | [protected, virtual] |
Process only the messages for client transactions
- Parameters:
-
| message | A pointer to the message to process, should not be used afterwards if this method returned True |
| state | The current state of the transaction |
virtual void processMessage |
( |
SIPMessage * |
message |
) |
[virtual] |
Process a message belonging to this transaction
- Parameters:
-
| message | A pointer to the message to process, the caller must make sure it belongs to this transaction |
Check if a message belongs to this transaction and process it if so
- Parameters:
-
| message | A pointer to the message to check, should not be used afterwards if this method returned Matched |
| branch | The branch parameter extracted from first Via header |
- Returns:
- Matched if the message was handled by this transaction, in which case it takes ownership over the message
virtual void processServerMessage |
( |
SIPMessage * |
message, |
|
|
int |
state | |
|
) |
| | [protected, virtual] |
Process only the messages for server transactions
- Parameters:
-
| message | A pointer to the message to process, should not be used afterwards if this method returned True |
| state | The current state of the transaction |
const SIPMessage* recentMessage |
( |
|
) |
const [inline] |
The most recent message handled by this transaction
void requestAuth |
( |
const String & |
realm, |
|
|
const String & |
domain, |
|
|
bool |
stale, |
|
|
bool |
proxy = false | |
|
) |
| | |
Send back an authentication required response
- Parameters:
-
| realm | Authentication realm to send in the answer |
| domain | Domain for which it will authenticate |
| stale | True if the previous password is valid but nonce is too old |
| proxy | True to authenticate as proxy, false as user agent |
void setDialogTag |
( |
const char * |
tag = 0 |
) |
|
Set a new dialog tag, optionally build a random one
- Parameters:
-
| tag | New dialog tag, a null string will build a random tag |
void setLatestMessage |
( |
SIPMessage * |
message = 0 |
) |
[protected] |
Set the latest message sent by this transaction
- Parameters:
-
| message | Pointer to the latest message |
void setPendingEvent |
( |
SIPEvent * |
event = 0 , |
|
|
bool |
replace = false | |
|
) |
| | [protected] |
Store a pending event to be picked up at the next getEvent() call
- Parameters:
-
| event | Event to store |
| replace | True to replace any existing pending event |
Transmits a final response message
bool setResponse |
( |
int |
code, |
|
|
const char * |
reason = 0 | |
|
) |
| | |
Creates and transmits a final response message
- Parameters:
-
| code | Response code to send |
| reason | Human readable reason text (optional) |
- Returns:
- True if the message was queued for transmission
void setTimeout |
( |
u_int64_t |
delay = 0 , |
|
|
unsigned int |
count = 1 | |
|
) |
| | [protected] |
Set a repetitive timeout
- Parameters:
-
| delay | How often (in microseconds) to fire the timeout |
| count | How many times to keep firing the timeout |
void setTransmit |
( |
|
) |
[inline] |
Set the (re)transmission flag that allows the latest outgoing message to be send over the wire
void setUserData |
( |
void * |
data |
) |
[inline] |
Set an arbitrary pointer as user specific data
static const char* stateName |
( |
int |
state |
) |
[static] |
Get the name of a transaction state
bool tryAutoAuth |
( |
SIPMessage * |
answer |
) |
[protected] |
Attempt to perform automatic client transaction authentication
- Parameters:
-
| answer | SIP answer that creates the new transaction |
- Returns:
- True if current client processing must be abandoned
The documentation for this class was generated from the following file: