SIPEngine Class Reference
The SIP engine and transaction list.
More...
#include <yatesip.h>
List of all members.
Public Member Functions |
| SIPEngine (const char *userAgent=0) |
virtual | ~SIPEngine () |
virtual bool | buildParty (SIPMessage *message)=0 |
virtual bool | checkUser (const String &username, const String &realm, const String &nonce, const String &method, const String &uri, const String &response, const SIPMessage *message, GenObject *userData) |
virtual bool | checkAuth (bool noUser, const SIPMessage *message, GenObject *userData) |
int | authUser (const SIPMessage *message, String &user, bool proxy=false, GenObject *userData=0) |
SIPTransaction * | addMessage (SIPParty *ep, const char *buf, int len=-1) |
SIPTransaction * | addMessage (SIPMessage *message) |
SIPEvent * | getEvent () |
bool | process () |
virtual void | processEvent (SIPEvent *event) |
virtual SIPTransaction * | forkInvite (SIPMessage *answer, SIPTransaction *trans) |
virtual u_int64_t | getUserTimeout () const |
u_int64_t | getTimer (char which, bool reliable=false) const |
unsigned int | getMaxForwards () const |
const String & | getUserAgent () const |
int | getNextCSeq () |
bool | lazyTrying () const |
void | lazyTrying (bool lazy100) |
void | nonceGet (String &nonce) |
long | nonceAge (const String &nonce) |
bool | isAllowed (const char *method) const |
void | addAllowed (const char *method) |
const String & | getAllowed () const |
void | remove (SIPTransaction *transaction) |
void | append (SIPTransaction *transaction) |
void | insert (SIPTransaction *transaction) |
Static Public Member Functions |
static void | buildAuth (const String &username, const String &realm, const String &passwd, const String &nonce, const String &method, const String &uri, String &response) |
static void | buildAuth (const String &hash_a1, const String &nonce, const String &hash_a2, String &response) |
Protected Attributes |
ObjList | m_transList |
u_int64_t | m_t1 |
u_int64_t | m_t4 |
unsigned int | m_maxForwards |
int | m_cseq |
bool | m_lazyTrying |
String | m_userAgent |
String | m_allowed |
String | m_nonce |
String | m_nonce_secret |
u_int32_t | m_nonce_time |
Mutex | m_nonce_mutex |
Detailed Description
The SIP engine and transaction list.
The SIP engine holds common methods and the list of current transactions
Constructor & Destructor Documentation
Member Function Documentation
void addAllowed |
( |
const char * |
method |
) |
|
Add a method to the allowed methods list
- Parameters:
-
| method | Uppercase name of the method to add |
Add a message into the transaction list This method is thread safe
- Parameters:
-
| message | A parsed SIP message to add to the transactions |
- Returns:
- Pointer to the transaction or NULL if message was invalid
Add a message into the transaction list
- Parameters:
-
| ep | Party of the received message |
| buf | A buffer containing the SIP message text |
| len | The length of the message or -1 to interpret as C string |
- Returns:
- Pointer to the transaction or NULL if message was invalid
Append a transaction to the end of the list
- Parameters:
-
| transaction | Pointer to transaction to append |
Detect the proper credentials for any user in the engine
- Parameters:
-
| message | Pointer to the message to check |
| 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 checkUser |
- Returns:
- Age of the nonce if user matches, negative for a failure
static void buildAuth |
( |
const String & |
hash_a1, |
|
|
const String & |
nonce, |
|
|
const String & |
hash_a2, |
|
|
String & |
response | |
|
) |
| | [static] |
Build an authentication response from already hashed components
- Parameters:
-
| hash_a1 | MD5 digest of username:realm:password |
| nonce | Authentication opaque nonce generated by the server |
| hash_a2 | MD5 digest of method:uri |
| response | String to store the computed response |
Build an authentication response
- Parameters:
-
| username | User account name |
| realm | Authentication realm |
| passwd | Account password |
| nonce | Authentication opaque nonce generated by the server |
| method | Method of the SIP message that is being authenticated |
| uri | URI of the SIP message that is being authenticated |
| response | String to store the computed response |
virtual bool buildParty |
( |
SIPMessage * |
message |
) |
[pure virtual] |
Build a new SIPParty for a message
- Parameters:
-
| message | Pointer to the message to build the party |
- Returns:
- True on success, false if party could not be built
virtual bool checkAuth |
( |
bool |
noUser, |
|
|
const SIPMessage * |
message, |
|
|
GenObject * |
userData | |
|
) |
| | [virtual] |
Authenticate a message by other means than user credentials. By default it calls checkUser with empty user credential fields
- Parameters:
-
| noUser | No plausible user credentials were detected so far |
| message | Message that is to be authenticated |
| userData | Pointer to an optional object passed from authUser |
- Returns:
- True if message is authenticated, false if verification failed
Check user credentials for validity
- Parameters:
-
| username | User account name |
| realm | Authentication realm |
| nonce | Authentication opaque nonce generated by the server |
| method | Method of the SIP message that is being authenticated |
| uri | URI of the SIP message that is being authenticated |
| response | Response computed by the authenticated entity |
| message | Message that is to be authenticated |
| userData | Pointer to an optional object passed from authUser |
- Returns:
- True if valid user/password, false if verification failed
Handle answers that create new dialogs for an outgoing INVITE
- Parameters:
-
| answer | The message that creates the INVITE fork |
| trans | One of the transactions part of the same INVITE |
- Returns:
- Pointer to new transaction or NULL if message is ignored
const String& getAllowed |
( |
|
) |
const [inline] |
Get all the allowed methods
- Returns:
- Comma separated list of allowed methods
Get a SIPEvent from the queue. This method mainly looks into the transaction list and get all kind of events, like an incoming request (INVITE, REGISTRATION), a timer, an outgoing message. This method is thread safe
unsigned int getMaxForwards |
( |
|
) |
const [inline] |
Get the default value of the Max-Forwards header for this engine
- Returns:
- The maximum number of hops the request is allowed to pass
int getNextCSeq |
( |
|
) |
[inline] |
Get a CSeq value suitable for use in a new request
u_int64_t getTimer |
( |
char |
which, |
|
|
bool |
reliable = false | |
|
) |
| | const |
Get the length of a timer
- Parameters:
-
| which | A one-character constant that selects which timer to return |
| reliable | Whether we request the timer value for a reliable protocol |
- Returns:
- Duration of the selected timer or 0 if invalid
const String& getUserAgent |
( |
|
) |
const [inline] |
Get the User agent for this SIP engine
virtual u_int64_t getUserTimeout |
( |
|
) |
const [virtual] |
Get the timeout to be used for transactions involving human interaction. The default implementation returns the proxy INVITE timeout (timer C = 3 minutes) minus the INVITE response retransmit interval (timer T2 = 4 seconds)
- Returns:
- Duration of the timeout in microseconds
Insert a transaction at the start of the list
- Parameters:
-
| transaction | Pointer to transaction to insert |
bool isAllowed |
( |
const char * |
method |
) |
const |
Check if a method is in the allowed methods list
- Parameters:
-
| method | Uppercase name of the method to check |
- Returns:
- True if the method should be allowed processing
void lazyTrying |
( |
bool |
lazy100 |
) |
[inline] |
Set the lazy "100 Trying" messages flag
- Parameters:
-
| lazy100 | True to not send the 1st 100 message for non-INVITE |
bool lazyTrying |
( |
|
) |
const [inline] |
Check if the engine is set up for lazy "100 Trying" messages
- Returns:
- True if the first 100 message is to be skipped for non-INVITE
long nonceAge |
( |
const String & |
nonce |
) |
|
Get the age of an authentication nonce
- Parameters:
-
| nonce | String nonce to check for validity and age |
- Returns:
- Age of the nonce in seconds, negative for invalid
void nonceGet |
( |
String & |
nonce |
) |
|
Get an authentication nonce
- Parameters:
-
| nonce | String reference to fill with the current nonce |
This method should be called very often to get the events from the list and to send them to processEvent method.
- Returns:
- True if some events were processed this turn
virtual void processEvent |
( |
SIPEvent * |
event |
) |
[virtual] |
Default handling for events. This method should be overriden for what you need and at the end you should call this default one This method is thread safe
Remove a transaction from the list without dereferencing it
- Parameters:
-
| transaction | Pointer to transaction to remove |
Member Data Documentation
The list that holds all the SIP transactions.
The documentation for this class was generated from the following file: