Menu Close

Configuring XCAP support for IM and presence over kamailio 3.1 – debian (lenny)

This article continue on series of articles about the Kamailio 3.1.x SIP proxy deployed on debian lenny and its features. In previous articles we have:

1) installed clear Kamailio 3.1.x server

2) added Mysql support for persistance location storage

3) SIREMIS web management interface for our kamailio server.

4) configured IM and presence service on Kamailio 3.1 – Howto


and now, we will configure the XCAP support for IM and presence. XCAP is a new Kamailio 3.1 feature supported by the XCAP Server module with XHTTP module. The official tutorial is at the SIP SIMPLE Presence Made Simple with Kamailio 3.1.x. XCAP allows to communicate over HTTP with your SIP Server (Presence agent here) and modify your presence info. As I understand it clear it should, in addition to, support buddy list feature of the Presence, or SIPMLE service architecture. Look at the guide for a short explanation. 

 Discussion about the Kamailio Xcap is at list.



The following modules must be loaded before this module: 

  • a database module.
  • presence.
  • sl.
  • xcap_client.
    • Only compulsory if not using an integrated xcap server (if ‘integrated_xcap_server’ parameter is not set).

External Libraries or Applications have to be already installed

  • libxml.



pstest:/home/palo# apt-cache search xcap
kamailio-presence-modules - SIMPLE presence modules for Kamailio

we may see that the xcap is part of the kamailio-presence-module package. We do not need install any other module as we have from previous steps.


Now, in contrast with previous articles about the kamailio, we have to add some lines into /etc/kamailio/kamailio.cfg file, because XCAP support is not yet preconfigured. So open the kamailio.cfg file.

At the top part of the file, as we did before, we add definition of the zone directive for XCAP support:


In global parameters section we have to add parameters for tcp life time connection




which allow to accept requests without content length

Inside of the load module part of the cfg we add zone block to load required XCAP modules

loadmodule ""
loadmodule ""

Now go to the module parameters part of the cfg file and set up xcap server module parameter for database:

# ----- xcap_server params -----
modparam("xcap_server", "db_url", DBURL)

and update the presence configuration to react on XCAP. So go to modparam section where presence is defined (search for !ifdef WITH_PRESENCE), and add following lines:

modparam("presence", "fallback2db", 1)
modparam("presence", "db_update_period", 20)


and edit presence xml params inside of the same presence zone block, so change

modparam("presence_xml", "force_active", 1) 


modparam("presence_xml", "force_active", 0) 


and add line

modparam("presence_xml", "integrated_xcap_server", 1)

The whole block should look now like:

# ----- presence params -----
modparam("presence", "db_url", DBURL)
modparam("presence", "fallback2db", 1)
modparam("presence", "db_update_period", 20)

# ----- presence_xml params -----
modparam("presence_xml", "db_url", DBURL)
modparam("presence_xml", "force_active", 0)
modparam("presence_xml", "integrated_xcap_server", 1)

Modifying the route block

And at the route logic part put following lines (just copy from the guide), I’ll try to analyze it later, we are just testing the guide 


event_route[xhttp:request] {
	xdbg("===== xhttp: request [$rv] $rm => $hu\n");
	if (!www_authorize("xcap", "subscriber"))
		www_challenge("xcap", "0");
		# xcap ops
		$xcapuri(u=>data) = $hu;
			$var(uri) = $xcapuri(u=>xuid);
		else if($xcapuri(u=>xuid)=~".+@.+")
			$var(uri) = "sip:" + $xcapuri(u=>xuid);
			$var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri;
		xlog("===== xhttp: $xcapuri(u=>auid) : $xcapuri(u=>xuid)\n");
			$var(xbody) =
"<?xml version='1.0' encoding='UTF-8'?> <xcap-caps xmlns='urn:ietf:params:xml:ns:xcap-caps'>   <auids>     <auid>rls-services</auid>     <auid>pidf-manipulation</auid>     <auid>xcap-caps</auid>     <auid>resource-lists</auid>     <auid>pres-rules</auid>     <auid>org.openmobilealliance.pres-rules</auid>   </auids>   <extensions>   </extensions>   <namespaces>     <namespace>urn:ietf:params:xml:ns:rls-services</namespace>     <namespace>urn:ietf:params:xml:ns:pidf</namespace>     <namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>     <namespace>urn:ietf:params:xml:ns:resource-lists</namespace>     <namespace>urn:ietf:params:xml:ns:pres-rules</namespace>   </namespaces> </xcap-caps>";
			xhttp_reply("200", "ok", "application/xcap-caps+xml",
        # be sure auth user access only its documents
        if ($au!=$(var(uri){uri.user})) {
            xhttp_reply("403", "Forbidden", "text/html",
		switch($rm) {
			case "PUT":
				xcaps_put("$var(uri)", "$hu", "$rb");
					xlog("===== xhttp put: refreshing watchers for $var(uri)\n");
					pres_update_watchers("$var(uri)", "presence");
					pres_refresh_watchers("$var(uri)", "presence", 1);
			case "GET":
				xlog("===== xhttp: get $var(uri) => $hu\n");
				xcaps_get("$var(uri)", "$hu");
			case "DELETE":
				xcaps_del("$var(uri)", "$hu");
					xlog("===== xhttp del: refreshing watchers for $var(uri)\n");
					pres_update_watchers("$var(uri)", "presence");
					pres_refresh_watchers("$var(uri)", "presence", 1);
	# http ops
	xhttp_reply("200", "ok", "text/html",
					"<html><body>OK: $si:$sp</body></html>");

Do not forget to restart kamailio.


Using SIP client with XCAP support


First, configure XCAP support correctly with IP address of your XCAP Server

Then try add a new contact.

On a SIP client where Jan is online following windows with authorization should appear:

If we authorize pepe, we may see on pepe’s SIP client authorization for jan, who is adding pepe into its list.

Finally we should see correct presence infos on both clients:


To verify XCAP store, we use an another SIP client with XCAP support, or another Jitsi instance running for example on another PC with the same SIP credentials, a newly added contact should appear on your new place (client or PC)


Configuring Bria 2.4




Using curl

Curl  is  a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS,  SCP,  SFTP,  TFTP,  DICT, TELNET,  LDAP  or  FILE).

First install curl utility

apt-get install curl

then type

curl --digest -u pepe:pepe GET
curl: (6) Couldn't resolve host 'GET'

to verify operation, return is 200Ok.

Or list of contacts

curl --digest -u pepe:pepe
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists">
<list name="RootGroup">
<entry uri="">

Using Siremis

it requires installed SIREMIS WEB gui

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.