|
@@ -1,4 +1,3 @@
|
|
|
-
|
|
|
Presence User Agent Module
|
|
|
|
|
|
Anca-Maria Vamanu
|
|
@@ -11,45 +10,44 @@ Anca-Maria Vamanu
|
|
|
|
|
|
Copyright © 2006 voice-system.ro
|
|
|
Revision History
|
|
|
- Revision $Revision$ $Date: 2008-08-06 12:08:33 +0200
|
|
|
- (Wed, 06 Aug 2008) $
|
|
|
- _________________________________________________________
|
|
|
+ Revision $Revision$ $Date$
|
|
|
+ __________________________________________________________________
|
|
|
|
|
|
Table of Contents
|
|
|
|
|
|
1. Admin Guide
|
|
|
|
|
|
- 1.1. Overview
|
|
|
- 1.2. Dependencies
|
|
|
+ 1. Overview
|
|
|
+ 2. Dependencies
|
|
|
|
|
|
- 1.2.1. Kamailio Modules
|
|
|
- 1.2.2. External Libraries or Applications
|
|
|
+ 2.1. Kamailio Modules
|
|
|
+ 2.2. External Libraries or Applications
|
|
|
|
|
|
- 1.3. Exported Parameters
|
|
|
+ 3. Exported Parameters
|
|
|
|
|
|
- 1.3.1. hash_size (int)
|
|
|
- 1.3.2. db_url (str)
|
|
|
- 1.3.3. db_table (str)
|
|
|
- 1.3.4. min_expires (int)
|
|
|
- 1.3.5. default_expires (int)
|
|
|
- 1.3.6. update_period (int)
|
|
|
- 1.3.7. outbound_proxy (str)
|
|
|
- 1.3.8. dlginfo_increase_version (int)
|
|
|
+ 3.1. hash_size (int)
|
|
|
+ 3.2. db_url (str)
|
|
|
+ 3.3. db_table (str)
|
|
|
+ 3.4. min_expires (int)
|
|
|
+ 3.5. default_expires (int)
|
|
|
+ 3.6. update_period (int)
|
|
|
+ 3.7. outbound_proxy (str)
|
|
|
+ 3.8. dlginfo_increase_version (int)
|
|
|
|
|
|
- 1.4. Exported Functions
|
|
|
+ 4. Exported Functions
|
|
|
|
|
|
- 1.4.1. pua_update_contact()
|
|
|
+ 4.1. pua_update_contact()
|
|
|
|
|
|
- 1.5. Installation
|
|
|
+ 5. Installation
|
|
|
|
|
|
2. Developer Guide
|
|
|
|
|
|
- 2.1. bind_pua(pua_api_t* api)
|
|
|
- 2.2. send_publish
|
|
|
- 2.3. send_subscribe
|
|
|
- 2.4. is_dialog
|
|
|
- 2.5. register_puacb
|
|
|
- 2.6. add_event
|
|
|
+ 1. bind_pua(pua_api_t* api)
|
|
|
+ 2. send_publish
|
|
|
+ 3. send_subscribe
|
|
|
+ 4. is_dialog
|
|
|
+ 5. register_puacb
|
|
|
+ 6. add_event
|
|
|
|
|
|
List of Examples
|
|
|
|
|
@@ -69,156 +67,195 @@ Anca-Maria Vamanu
|
|
|
|
|
|
Chapter 1. Admin Guide
|
|
|
|
|
|
-1.1. Overview
|
|
|
+ Table of Contents
|
|
|
+
|
|
|
+ 1. Overview
|
|
|
+ 2. Dependencies
|
|
|
+
|
|
|
+ 2.1. Kamailio Modules
|
|
|
+ 2.2. External Libraries or Applications
|
|
|
+
|
|
|
+ 3. Exported Parameters
|
|
|
+
|
|
|
+ 3.1. hash_size (int)
|
|
|
+ 3.2. db_url (str)
|
|
|
+ 3.3. db_table (str)
|
|
|
+ 3.4. min_expires (int)
|
|
|
+ 3.5. default_expires (int)
|
|
|
+ 3.6. update_period (int)
|
|
|
+ 3.7. outbound_proxy (str)
|
|
|
+ 3.8. dlginfo_increase_version (int)
|
|
|
+
|
|
|
+ 4. Exported Functions
|
|
|
+
|
|
|
+ 4.1. pua_update_contact()
|
|
|
+
|
|
|
+ 5. Installation
|
|
|
+
|
|
|
+1. Overview
|
|
|
+
|
|
|
+ This module offer the functionality of a presence user agent client,
|
|
|
+ sending Subscribe and Publish messages. It's a core part of Kamailio's
|
|
|
+ SIP presence package, implementing SIMPLE and various shared line
|
|
|
+ appearance implementations.
|
|
|
|
|
|
- This module offer the functionality of a presence user agent
|
|
|
- client, sending Subscribe and Publish messages.
|
|
|
+ It can be used with the following modules: pua_mi and pua_usrloc,
|
|
|
+ pua_bla and pua_xmpp. The <emphasize>pua_mi</emphasize> offer the
|
|
|
+ possibility to publish any kind of information or subscribing to a
|
|
|
+ resource through the manager interface. The
|
|
|
+ <emphasize>pua_usrloc</emphasize> module calls a function exported by
|
|
|
+ pua modules to publish elementary presence information, such as basic
|
|
|
+ status "open" or "closed", for clients that do not implement
|
|
|
+ client-to-server presence. Through <emphasize>pua_bla</emphasize> ,
|
|
|
+ BRIDGED LINE APPEARANCE features are added to openser. The
|
|
|
+ <emphasize>pua_xmpp</emphasize> module represents a gateway between SIP
|
|
|
+ and XMPP, so that jabber and SIP clients can exchange presence
|
|
|
+ information.
|
|
|
|
|
|
- Now it can be used with the following modules: pua_mi and
|
|
|
- pua_usrloc, pua_bla and pua_xmpp. The pua_mi offer the
|
|
|
- possibility to publish any kind of information or subscribing
|
|
|
- to a resource through fifo. The pua_usrloc module calls a
|
|
|
- function exported by pua modules to publish elementary
|
|
|
- presence information, such as basic status "open" or "closed",
|
|
|
- for clients that do not implement client-to-server presence.
|
|
|
- Through pua_bla , BRIDGED LINE APPEARANCE features are added
|
|
|
- to openser. The pua_xmpp module represents a gateway between
|
|
|
- SIP and XMPP, so that jabber and SIP clients can exchange
|
|
|
- presence information.
|
|
|
+ The module use a cache to store the presentity list and writes to
|
|
|
+ database on timer to be able to recover upon restart. The presence is
|
|
|
+ kept in-memory during run-time.
|
|
|
|
|
|
- The module use cache to store presentity list and writes to
|
|
|
- database on timer to be able to recover upon restart.
|
|
|
+2. Dependencies
|
|
|
|
|
|
-1.2. Dependencies
|
|
|
+ 2.1. Kamailio Modules
|
|
|
+ 2.2. External Libraries or Applications
|
|
|
|
|
|
-1.2.1. Kamailio Modules
|
|
|
+2.1. Kamailio Modules
|
|
|
|
|
|
The following modules must be loaded before this module:
|
|
|
* a database modules.
|
|
|
* tm.
|
|
|
|
|
|
-1.2.2. External Libraries or Applications
|
|
|
+2.2. External Libraries or Applications
|
|
|
|
|
|
- The following libraries or applications must be installed
|
|
|
- before running Kamailio with this module loaded:
|
|
|
+ The following libraries or applications must be installed before
|
|
|
+ running Kamailio with this module loaded:
|
|
|
* libxml.
|
|
|
|
|
|
-1.3. Exported Parameters
|
|
|
+3. Exported Parameters
|
|
|
|
|
|
-1.3.1. hash_size (int)
|
|
|
+ 3.1. hash_size (int)
|
|
|
+ 3.2. db_url (str)
|
|
|
+ 3.3. db_table (str)
|
|
|
+ 3.4. min_expires (int)
|
|
|
+ 3.5. default_expires (int)
|
|
|
+ 3.6. update_period (int)
|
|
|
+ 3.7. outbound_proxy (str)
|
|
|
+ 3.8. dlginfo_increase_version (int)
|
|
|
|
|
|
- The size of the hash table used for storing Subscribe and
|
|
|
- Publish information. This parameter will be used as the power
|
|
|
- of 2 when computing table size.
|
|
|
+3.1. hash_size (int)
|
|
|
|
|
|
- Default value is "9".
|
|
|
+ The size of the hash table used for storing Subscribe and Publish
|
|
|
+ information. This parameter will be used as the power of 2 when
|
|
|
+ computing table size.
|
|
|
+
|
|
|
+ Default value is "9".
|
|
|
|
|
|
Example 1.1. Set hash_size parameter
|
|
|
...
|
|
|
modparam("pua", "hash_size", 11)
|
|
|
...
|
|
|
|
|
|
-1.3.2. db_url (str)
|
|
|
+3.2. db_url (str)
|
|
|
|
|
|
Database url.
|
|
|
|
|
|
- Default value is
|
|
|
- ">mysql://openser:openserrw@localhost/openser".
|
|
|
+ Default value is ">mysql://openser:openserrw@localhost/openser".
|
|
|
|
|
|
Example 1.2. Set db_url parameter
|
|
|
...
|
|
|
modparam("pua", "db_url" "dbdriver://username:password@dbhost/dbname")
|
|
|
...
|
|
|
|
|
|
-1.3.3. db_table (str)
|
|
|
+3.3. db_table (str)
|
|
|
|
|
|
The name of the database table.
|
|
|
|
|
|
- Default value is "pua".
|
|
|
+ Default value is "pua".
|
|
|
|
|
|
Example 1.3. Set db_table parameter
|
|
|
...
|
|
|
modparam("pua", "db_table", "pua")
|
|
|
...
|
|
|
|
|
|
-1.3.4. min_expires (int)
|
|
|
+3.4. min_expires (int)
|
|
|
|
|
|
The inferior expires limit for both Publish and Subscribe.
|
|
|
|
|
|
- Default value is "0".
|
|
|
+ Default value is "0".
|
|
|
|
|
|
Example 1.4. Set min_expires parameter
|
|
|
...
|
|
|
modparam("pua", "min_expires", 0)
|
|
|
...
|
|
|
|
|
|
-1.3.5. default_expires (int)
|
|
|
+3.5. default_expires (int)
|
|
|
|
|
|
The default expires value used in case this information is not
|
|
|
provisioned.
|
|
|
|
|
|
- Default value is "3600".
|
|
|
+ Default value is "3600".
|
|
|
|
|
|
Example 1.5. Set default_expires parameter
|
|
|
...
|
|
|
modparam("pua", "default_expires", 3600)
|
|
|
...
|
|
|
|
|
|
-1.3.6. update_period (int)
|
|
|
+3.6. update_period (int)
|
|
|
|
|
|
- The interval at which the information in database and hash
|
|
|
- table should be updated. In the case of the hash table
|
|
|
- updating is deleting expired messages.
|
|
|
+ The interval at which the information in database and hash table should
|
|
|
+ be updated. In the case of the hash table updating means deleting
|
|
|
+ expired messages.
|
|
|
|
|
|
- Default value is "100".
|
|
|
+ Default value is "100".
|
|
|
|
|
|
Example 1.6. Set update_period parameter
|
|
|
...
|
|
|
modparam("pua", "update_period", 100)
|
|
|
...
|
|
|
|
|
|
-1.3.7. outbound_proxy (str)
|
|
|
+3.7. outbound_proxy (str)
|
|
|
|
|
|
- SIP URI of outbound proxy to be used when sending PUBLISH
|
|
|
- requests.
|
|
|
+ SIP URI of outbound proxy to be used when sending PUBLISH requests.
|
|
|
|
|
|
- By default, no outbound proxy has been defined.
|
|
|
+ By default, no outbound proxy has been defined.
|
|
|
|
|
|
Example 1.7. Set outbound_proxy parameter
|
|
|
...
|
|
|
modparam("pua", "outbound_proxy", "sip:outbound.example.com")
|
|
|
...
|
|
|
|
|
|
-1.3.8. dlginfo_increase_version (int)
|
|
|
+3.8. dlginfo_increase_version (int)
|
|
|
|
|
|
- When sending PUBLISHs for Event: dialog, the body contains an
|
|
|
- XML document according to RFC 4235. This XML document contains
|
|
|
- a version attribut to easily detect changes in the dialog
|
|
|
- state. By setting this parameter, the pua module parses the
|
|
|
- XML document and sets the version attribute to the proper
|
|
|
- value. If the receiver of the PUBLISH does not care about the
|
|
|
- version parameter (e.g. like Kamailio presence_dialoginfo
|
|
|
- module) it makes no sense to waste CPU resources for parsing
|
|
|
- the XML body and the parameter should be set to 0.
|
|
|
+ When sending PUBLISHs for Event: dialog, the body contains an XML
|
|
|
+ document according to RFC 4235. This XML document contains a version
|
|
|
+ attribute to easily detect changes in the dialog state. By setting this
|
|
|
+ parameter, the pua module parses the XML document and sets the version
|
|
|
+ attribute to the proper value. If the receiver of the PUBLISH does not
|
|
|
+ care about the version parameter (e.g. like Kamailio
|
|
|
+ presence_dialoginfo module) it makes no sense to waste CPU resources
|
|
|
+ for parsing the XML body and the parameter should be set to 0.
|
|
|
|
|
|
- Default value is "0".
|
|
|
+ Default value is "0".
|
|
|
|
|
|
Example 1.8. Set dlginfo_increase_version parameter
|
|
|
...
|
|
|
modparam("pua", "dlginfo_increase_version", 1)
|
|
|
...
|
|
|
|
|
|
-1.4. Exported Functions
|
|
|
+4. Exported Functions
|
|
|
+
|
|
|
+ 4.1. pua_update_contact()
|
|
|
|
|
|
-1.4.1. pua_update_contact()
|
|
|
+4.1. pua_update_contact()
|
|
|
|
|
|
- The remote target can be updated by the Contact of a
|
|
|
- subsequent in dialog request. In the PUA watcher case (sending
|
|
|
- a SUBSCRIBE messages), this means that the remote target for
|
|
|
- the following Subscribe messages can be updated at any time by
|
|
|
- the contact of a Notify message. If this function is called on
|
|
|
- request route on receiving a Notify message, it will try to
|
|
|
- update the stored remote target.
|
|
|
+ The remote target can be updated by the Contact of a subsequent in
|
|
|
+ dialog request. In the PUA watcher case (sending a SUBSCRIBE messages),
|
|
|
+ this means that the remote target for the following Subscribe messages
|
|
|
+ can be updated at any time by the contact of a Notify message. If this
|
|
|
+ function is called on request route on receiving a Notify message, it
|
|
|
+ will try to update the stored remote target.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE.
|
|
|
|
|
@@ -232,24 +269,32 @@ if(method=="NOTIFY")
|
|
|
pua_update_contact();
|
|
|
...
|
|
|
|
|
|
-1.5. Installation
|
|
|
+5. Installation
|
|
|
|
|
|
- The module requires 1 table in Kamailio database: pua. The SQL
|
|
|
- syntax to create it can be found in presence_xml-create.sql
|
|
|
- script in the database directories in the kamailio/scripts
|
|
|
- folder. You can also find the complete database documentation
|
|
|
- on the project webpage,
|
|
|
+ The module requires one table in the Kamailio database: pua. The SQL
|
|
|
+ syntax to create it can be found in presence_xml-create.sql script in
|
|
|
+ the database directories in the kamailio/scripts folder. You can also
|
|
|
+ find the complete database documentation on the project webpage,
|
|
|
http://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.
|
|
|
|
|
|
Chapter 2. Developer Guide
|
|
|
|
|
|
- The module provides the following functions that can be used
|
|
|
- in other Kamailio modules.
|
|
|
+ Table of Contents
|
|
|
+
|
|
|
+ 1. bind_pua(pua_api_t* api)
|
|
|
+ 2. send_publish
|
|
|
+ 3. send_subscribe
|
|
|
+ 4. is_dialog
|
|
|
+ 5. register_puacb
|
|
|
+ 6. add_event
|
|
|
+
|
|
|
+ The module provides the following functions that can be used by other
|
|
|
+ Kamailio modules.
|
|
|
|
|
|
-2.1. bind_pua(pua_api_t* api)
|
|
|
+1. bind_pua(pua_api_t* api)
|
|
|
|
|
|
- This function binds the pua modules and fills the structure
|
|
|
- with the two exported function.
|
|
|
+ This function binds the pua modules and fills the structure with the
|
|
|
+ two exported functions.
|
|
|
|
|
|
Example 2.1. pua_api structure
|
|
|
...
|
|
@@ -262,15 +307,15 @@ typedef struct pua_api {
|
|
|
} pua_api_t;
|
|
|
...
|
|
|
|
|
|
-2.2. send_publish
|
|
|
+2. send_publish
|
|
|
|
|
|
Field type:
|
|
|
...
|
|
|
typedef int (*send_publish_t)(publ_info_t* publ);
|
|
|
...
|
|
|
|
|
|
- This function receives as a parameter a structure with Publish
|
|
|
- required information and sends a Publish message.
|
|
|
+ This function receives as a parameter a structure with Publish required
|
|
|
+ information and sends a Publish message.
|
|
|
|
|
|
The structure received as a parameter:
|
|
|
...
|
|
@@ -281,13 +326,11 @@ typedef struct publ_info
|
|
|
str* pres_uri; /* the presentity uri */
|
|
|
str* body; /* the body of the Publish message;
|
|
|
can be NULL in case of an update expires*/
|
|
|
-
|
|
|
int expires; /* the expires value that will be used in
|
|
|
Publish Expires header*/
|
|
|
int flag; /* it can be : INSERT_TYPE or UPDATE_TYPE
|
|
|
if missing it will be established according
|
|
|
to the result of the search in hash table*/
|
|
|
-
|
|
|
int source_flag; /* flag identifying the resource ;
|
|
|
supported values: UL_PUBLISH, MI_PUBLISH,
|
|
|
BLA_PUBLISH, XMPP_PUBLISH*/
|
|
@@ -305,7 +348,6 @@ typedef struct publ_info
|
|
|
the reply for the sent request */
|
|
|
void* cbparam; /* extra parameter for tha callback function */
|
|
|
|
|
|
-
|
|
|
}publ_info_t;
|
|
|
...
|
|
|
|
|
@@ -314,15 +356,15 @@ typedef struct publ_info
|
|
|
typedef int (publrpl_cb_t)(struct sip_msg* reply, void* extra_param);
|
|
|
...
|
|
|
|
|
|
-2.3. send_subscribe
|
|
|
+3. send_subscribe
|
|
|
|
|
|
Field type:
|
|
|
...
|
|
|
typedef int (*send_subscribe_t)(subs_info_t* subs);
|
|
|
...
|
|
|
|
|
|
- This function receives as a parameter a structure with
|
|
|
- Subscribe required information and sends a Subscribe message.
|
|
|
+ This function receives as a parameter a structure with Subscribe
|
|
|
+ required information and sends a Subscribe message.
|
|
|
|
|
|
The structure received as a parameter:
|
|
|
...
|
|
@@ -353,15 +395,15 @@ typedef struct subs_info
|
|
|
}subs_info_t;
|
|
|
...
|
|
|
|
|
|
-2.4. is_dialog
|
|
|
+4. is_dialog
|
|
|
|
|
|
Field type:
|
|
|
...
|
|
|
typedef int (*query_dialog_t)(ua_pres_t* presentity);
|
|
|
...
|
|
|
|
|
|
- This function checks is the parameter corresponds to a stored
|
|
|
- Subscribe initiated dialog.
|
|
|
+ This function checks is the parameter corresponds to a stored Subscribe
|
|
|
+ initiated dialog.
|
|
|
|
|
|
Example 2.2. pua_is_dialog usage example
|
|
|
...
|
|
@@ -372,20 +414,19 @@ typedef int (*query_dialog_t)(ua_pres_t* presentity);
|
|
|
}
|
|
|
...
|
|
|
|
|
|
-2.5. register_puacb
|
|
|
+5. register_puacb
|
|
|
|
|
|
Field type:
|
|
|
...
|
|
|
typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
|
|
|
...
|
|
|
|
|
|
- This function registers a callback to be called on receiving
|
|
|
- the reply message for a sent Subscribe request. The type
|
|
|
- parameter should be set the same as the source_flag for that
|
|
|
- request. The function registered as callback for pua should be
|
|
|
- of type pua_cb , which is: typedef void (pua_cb)(ua_pres_t*
|
|
|
- hentity, struct msg_start * fl); The parameters are the dialog
|
|
|
- structure for that request and the first line of the reply
|
|
|
+ This function registers a callback to be called on receiving the reply
|
|
|
+ message for a sent Subscribe request. The type parameter should be set
|
|
|
+ the same as the source_flag for that request. The function registered
|
|
|
+ as callback for pua should be of type pua_cb , which is: typedef void
|
|
|
+ (pua_cb)(ua_pres_t* hentity, struct msg_start * fl); The parameters are
|
|
|
+ the dialog structure for that request and the first line of the reply
|
|
|
message.
|
|
|
|
|
|
Example 2.3. register_puacb usage example
|
|
@@ -397,7 +438,7 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
|
|
|
}
|
|
|
...
|
|
|
|
|
|
-2.6. add_event
|
|
|
+6. add_event
|
|
|
|
|
|
Field type:
|
|
|
...
|
|
@@ -405,7 +446,6 @@ typedef int (*add_pua_event_t)(int ev_flag, char* name,
|
|
|
char* content_type,evs_process_body_t* process_body);
|
|
|
|
|
|
- ev_flag : an event flag defined as a macro in pua module
|
|
|
-
|
|
|
- name : the event name to be used in Event request headers
|
|
|
- content_type: the default content_type for Publish body for
|
|
|
that event (NULL if winfo event)
|
|
@@ -414,8 +454,8 @@ typedef int (*add_pua_event_t)(int ev_flag, char* name,
|
|
|
(NULL if winfo event)
|
|
|
...
|
|
|
|
|
|
- This function allows registering new events to the pua module.
|
|
|
- Now there are 4 events supported by the pua module: presence,
|
|
|
+ This function allows registering new events to the pua module. Now
|
|
|
+ there are 4 events supported by the pua module: presence,
|
|
|
presence;winfo, message-summary, dialog;sla. These events are
|
|
|
registered from within the pua module.
|
|
|
|
|
@@ -426,7 +466,6 @@ typedef int (evs_process_body_t)(struct publ_info* publ,
|
|
|
- publ : the structure received as a parameter in send_publish
|
|
|
function ( initial body found in publ->body)
|
|
|
- final_body: the pointer where the result(final_body) should be stored
|
|
|
-
|
|
|
- ver : a counter for the sent Publish requests
|
|
|
(used for winfo events)
|
|
|
- tuple : a unique identifier for the resource;
|
|
@@ -437,8 +476,7 @@ typedef int (evs_process_body_t)(struct publ_info* publ,
|
|
|
|
|
|
Example 2.4. add_event usage example
|
|
|
...
|
|
|
- if(pua.add_event((PRESENCE_EVENT, "presence", "application/pidf
|
|
|
-+xml",
|
|
|
+ if(pua.add_event((PRESENCE_EVENT, "presence", "application/pidf+xml",
|
|
|
pres_process_body) & 0)
|
|
|
{
|
|
|
LM_ERR("Could not register new event\n");
|