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.
Prerequsities
-
Installed the Kamailio (OpenSER) 3.1.0 server with support for Mysql
-
installed Mysql Server
-
configured Presence and IM feastures over Kamailio
-
XCAP client (SIP communicator)
Dependencies
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).
- 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.
Preparation
Using
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.
Configuration
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:
#!define WITH_XCAPSRV
In global parameters section we have to add parameters for tcp life time connection
tcp_connection_lifetime=3064
and
#!ifdef WITH_XCAPSRV tcp_accept_no_cl=yes #!endif
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
#!ifdef WITH_XCAPSRV loadmodule "xhttp.so" loadmodule "xcap_server.so" #!endif
Now go to the module parameters part of the cfg file and set up xcap server module parameter for database:
#!ifdef WITH_XCAPSRV # ----- xcap_server params ----- modparam("xcap_server", "db_url", DBURL) #!endif
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)
to
modparam("presence_xml", "force_active", 0)
and add line
modparam("presence_xml", "integrated_xcap_server", 1)
The whole block should look now like:
#!ifdef WITH_PRESENCE # ----- 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) #!endif
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
#!ifdef WITH_XCAPSRV #!define WITH_XHTTPAUTH event_route[xhttp:request] { xdbg("===== xhttp: request [$rv] $rm => $hu\n"); #!ifdef WITH_XHTTPAUTH if (!www_authorize("xcap", "subscriber")) { www_challenge("xcap", "0"); exit; } #!endif if($hu=~"^/xcap-root/") { set_reply_close(); set_reply_no_connect(); # xcap ops $xcapuri(u=>data) = $hu; if($xcapuri(u=>xuid)=~"^sip:.+@.+") $var(uri) = $xcapuri(u=>xuid); else if($xcapuri(u=>xuid)=~".+@.+") $var(uri) = "sip:" + $xcapuri(u=>xuid); else $var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri; xlog("===== xhttp: $xcapuri(u=>auid) : $xcapuri(u=>xuid)\n"); if($xcapuri(u=>auid)=="xcap-caps") { $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", "$var(xbody)"); exit; } #!ifdef WITH_XHTTPAUTH # be sure auth user access only its documents if ($au!=$(var(uri){uri.user})) { xhttp_reply("403", "Forbidden", "text/html", "<html><body>$si:$sp</body></html>"); exit; } #!endif switch($rm) { case "PUT": xcaps_put("$var(uri)", "$hu", "$rb"); if($xcapuri(u=>auid)=~"pres-rules") { xlog("===== xhttp put: refreshing watchers for $var(uri)\n"); pres_update_watchers("$var(uri)", "presence"); pres_refresh_watchers("$var(uri)", "presence", 1); } exit; break; case "GET": xlog("===== xhttp: get $var(uri) => $hu\n"); xcaps_get("$var(uri)", "$hu"); exit; break; case "DELETE": xcaps_del("$var(uri)", "$hu"); if($xcapuri(u=>auid)=~"pres-rules") { xlog("===== xhttp del: refreshing watchers for $var(uri)\n"); pres_update_watchers("$var(uri)", "presence"); pres_refresh_watchers("$var(uri)", "presence", 1); } exit; break; } } # http ops xhttp_reply("200", "ok", "text/html", "<html><body>OK: $si:$sp</body></html>"); exit; } #!endif
Do not forget to restart kamailio.
Testing
Using SIP client with XCAP support
Jitsi
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 http://158.193.139.51:5060/xcap-root curl: (6) Couldn't resolve host 'GET' <html><body>OK: 158.193.139.51:50334</body></html>
to verify operation, return is 200Ok.
Or list of contacts
curl --digest -u pepe:pepe http://158.193.139.51:5060/xcap-root/resource-lists/users/sip:pepe@ps.sip.uniza.sk/index <?xml version="1.0" encoding="UTF-8" standalone="no"?> <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists"> <list name="RootGroup"> <entry uri="sip:jan@ps.sip.uniza.sk"> <display-name>jan@ps</display-name> </entry> </list> </resource-lists>
Using Siremis
it requires installed SIREMIS WEB gui