Table of Contents
List of Examples
url_match
parameterurl_match
parameterxcaps_put
usagexcaps_get
usagexcaps_del
usageTable of Contents
This module provides an XCAP server functionaly inside Kamailio and SER SIP servers.
Benefits brought by this integrated XCAP server:
reuse of SIP router transport layer - XCAP documents can be sent via SIP (UDP, TCP, TLS and SCTP) and via HTTP (TCP or TLS (HTTPS)). For HTTP/S, you neet to load XHTTP module to handle HTTP/S requests.
the Presence server has access imediatelly to the latest version of XCAP documents. No more need to trigger refresh of XCAP documents via MI command
can be used stand-alone, with a different Presence server. It is not specific for Kamailio or SER. Documents can be fetched via GET
no exotic dependencies, it is written in C. It depends on libxml2, sl module and a database module (required to store the xcap documents).
you can do digest authentication using database, radius, ldap, etc. Can reuse authorization mechanisms provided by SIP server.
flexibility - the XCAP server is controlled from config file of SIP server, therefore you can blend the XCAP logic with features provided by core or other modules.
Important: be sure you have global parameter: 'tcp_accept_no_cl=yes'.
The following modules must be loaded before this module:
sl - stateless reply module
db - a database engine module
xhttp - embedded HTTP server if you want to get XCAP documents via HTTP.
Database URL.
Default value is “mysql://openser:openserrw@localhost/openser”.
Example 1.1. Set the “db_url” parameter
... modparam("xcap_server", "db_url", "mysql://user:passwd@host.com/dbname") ...
The name of table where to store the xcap documents.
Default value is “xcap”.
Example 1.2. Set the “xcap_table” parameter
... modparam("xcap_server", "xcap_table", "xcapdocs") ...
XCAP root URL.
Default value is '/xcap-root/'.
Size of local buffer for handling XCAP documents.
Default value is “1024”.
Register extra XML namespaces to be used with XPath. You can set the parameter many times to add more namespaces. The format is 'prefix=href'.
Default value is 'null'.
Example 1.5. Set url_match
parameter
... modparam("xcap_server", "xml_ns", "rl=urn:ietf:params:xml:ns:resource-lists") modparam("xcap_server", "xml_ns", "my=urn:my:prefix") ...
Handle XCAP PUT command.
Example 1.6. xcaps_put
usage
... event_route[xhttp:request] { if($hu=~"^/xcap-root/") { # xcap ops switch($rm) { case "PUT": xcaps_put("sip:101@$Ri", "$hu", "$rb"); exit; break; } } } ...
$xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key can be: data, uri, root, auid, type, tree, xuid, file, node.
Exported pseudo-variables are documented at http://www.kamailio.org/dokuwiki/.
Example 1.9. $xcapuri(...) PV
... $xcapuri(u=>data) = $hu; xdbg("SCRIPT: xcap service $xcapuri(u=>auid) for $xcapuri(u=>xuid)\n"); ...
Example 1.10. sample xcap server
... tcp_accept_no_cl=yes ... loadmodule "xhttp.so" loadmodule "xcap_server.so" ... # ----- xcap_server params ----- modparam("xcap_server", "db_url", "mysql://openser:openserrw@localhost/openser") ... event_route[xhttp:request] { if (!www_authorize("xcap", "subscriber")) { www_challenge("xcap", "0"); exit; } if($hu=~"^/xcap-root/") { set_reply_close(); set_reply_no_connect(); # xcap ops - break down http uri to get xcap user id $xcapuri(u=>data) = $hu; if($xcapuri(u=>xuid)=~"^sip:.+@.+") $var(uri) = $xcapuri(u=>xuid); else $var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri; # handle XCAP capability request if($rm=="GET" && $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; } # be sure auth user access only its documents if ($au!=$(var(uri){uri.user})) { xhttp_reply("403", "Forbidden", "text/html", "operation not allowed"); exit; } xdbg("SCRIPT: xcap service $xcapuri(u=>auid) for $xcapuri(u=>xuid)\n"); switch($rm) { case "PUT": xcaps_put("$var(uri)", "$hu", "$rb"); if($xcapuri(u=>auid)=~"pres-rules") { pres_update_watchers("$var(uri)", "presence"); pres_refresh_watchers("$var(uri)", "presence", 1); } exit; break; case "GET": xcaps_get("$var(uri)", "$hu"); exit; break; case "DELETE": xcaps_del("$var(uri)", "$hu"); if($xcapuri(u=>auid)=~"pres-rules") { pres_update_watchers("$var(uri)", "presence"); pres_refresh_watchers("$var(uri)", "presence", 1); } exit; break; } } # other http requests xhttp_reply("200", "OK", "text/html", "<html><body>OK: $si:$sp</body></html>"); exit; } ...
The URL for XCAP has to be:
http://_your_sip_server_ip_:_your_sip_server_port_/xcap-root/...
For example, if your SIP server IP is 10.1.1.10 and it is listening on TCP port 5060 and TLS port 5061, following XCAP URLs can be used:
http://10.1.1.10:5060/xcap-root/...
https://10.1.1.10:5061/xcap-root/...