Yate
|
The SIP engine and transaction list. More...
#include <yatesip.h>
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 |
The SIP engine and transaction list.
The SIP engine holds common methods and the list of current transactions
void addAllowed | ( | const char * | method | ) |
Add a method to the allowed methods list
method | Uppercase name of the method to add |
SIPTransaction* addMessage | ( | SIPParty * | ep, |
const char * | buf, | ||
int | len = -1 |
||
) |
Add a message into the transaction list
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 |
SIPTransaction* addMessage | ( | SIPMessage * | message | ) |
Add a message into the transaction list This method is thread safe
message | A parsed SIP message to add to the transactions |
void append | ( | SIPTransaction * | transaction | ) | [inline] |
Append a transaction to the end of the list
transaction | Pointer to transaction to append |
int authUser | ( | const SIPMessage * | message, |
String & | user, | ||
bool | proxy = false , |
||
GenObject * | userData = 0 |
||
) |
Detect the proper credentials for any user in the engine
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 |
static void buildAuth | ( | const String & | username, |
const String & | realm, | ||
const String & | passwd, | ||
const String & | nonce, | ||
const String & | method, | ||
const String & | uri, | ||
String & | response | ||
) | [static] |
Build an authentication response
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
message | Pointer to the message to build the party |
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
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 |
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] |
Check user credentials for validity
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 |
virtual SIPTransaction* forkInvite | ( | SIPMessage * | answer, |
SIPTransaction * | trans | ||
) | [virtual] |
Handle answers that create new dialogs for an outgoing INVITE
answer | The message that creates the INVITE fork |
trans | One of the transactions part of the same INVITE |
const String& getAllowed | ( | ) | const [inline] |
Get all the allowed methods
SIPEvent* getEvent | ( | ) |
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
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
which | A one-character constant that selects which timer to return |
reliable | Whether we request the timer value for a reliable protocol |
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)
void insert | ( | SIPTransaction * | transaction | ) | [inline] |
Insert a transaction at the start of the list
transaction | Pointer to transaction to insert |
bool isAllowed | ( | const char * | method | ) | const |
Check if a method is in the allowed methods list
method | Uppercase name of the method to check |
bool lazyTrying | ( | ) | const [inline] |
Check if the engine is set up for lazy "100 Trying" messages
void lazyTrying | ( | bool | lazy100 | ) | [inline] |
Set the lazy "100 Trying" messages flag
lazy100 | True to not send the 1st 100 message for non-INVITE |
long nonceAge | ( | const String & | nonce | ) |
Get the age of an authentication nonce
nonce | String nonce to check for validity and age |
void nonceGet | ( | String & | nonce | ) |
Get an authentication nonce
nonce | String reference to fill with the current nonce |
bool process | ( | ) |
This method should be called very often to get the events from the list and to send them to processEvent method.
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
void remove | ( | SIPTransaction * | transaction | ) | [inline] |
Remove a transaction from the list without dereferencing it
transaction | Pointer to transaction to remove |
ObjList m_transList [protected] |
The list that holds all the SIP transactions.