%docentities; ]> &adminguide;
Overview 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'.
Dependencies
&kamailio; Modules 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.
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: libxml2 - libxml2 library for runtime and libxml2-dev for compilation.
Parameters
<varname>db_url</varname> (string) Database &url;. Default value is mysql://openser:openserrw@localhost/openser. Set the <quote>db_url</quote> parameter ... modparam("xcap_server", "db_url", "mysql://user:passwd@host.com/dbname") ...
<varname>xcap_table</varname> (string) The name of table where to store the xcap documents. Default value is xcap. Set the <quote>xcap_table</quote> parameter ... modparam("xcap_server", "xcap_table", "xcapdocs") ...
<varname>xcap_root</varname> (str) XCAP root URL. Default value is '/xcap-root/'. Set <varname>url_match</varname> parameter ... modparam("xcap_server", "xcap_root", "/xcap-root/") ...
<varname>buf_size</varname> (int) Size of local buffer for handling XCAP documents. Default value is 1024. Set the <quote>buf_size</quote> parameter ... modparam("xcap_server", "buf_size", 2048) ...
<varname>xml_ns</varname> (str) 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'. Set <varname>url_match</varname> parameter ... modparam("xcap_server", "xml_ns", "rl=urn:ietf:params:xml:ns:resource-lists") modparam("xcap_server", "xml_ns", "my=urn:my:prefix") ...
Functions
<function moreinfo="none">xcaps_put(uri, path, doc)</function> Handle XCAP PUT command. <function>xcaps_put</function> usage ... event_route[xhttp:request] { if($hu=~"^/xcap-root/") { # xcap ops switch($rm) { case "PUT": xcaps_put("sip:101@$Ri", "$hu", "$rb"); exit; break; } } } ...
<function moreinfo="none">xcaps_get(uri, path)</function> Handle XCAP GET command. <function>xcaps_get</function> usage ... event_route[xhttp:request] { if($hu=~"^/xcap-root/") { # xcap ops switch($rm) { case "GETT": xcaps_get("sip:101@$Ri", "$hu"); exit; break; } } } ...
<function moreinfo="none">xcaps_del(uri, path)</function> Handle XCAP DELETE command. <function>xcaps_del</function> usage ... event_route[xhttp:request] { if($hu=~"^/xcap-root/") { # xcap ops switch($rm) { case "DELETE": xcaps_del("sip:101@$Ri", "$hu"); exit; break; } } } ...
Exported pseudo-variables $xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key can be: data, uri, root, auid, type, tree, xuid, file, node, target, domain, uri_adoc. Exported pseudo-variables are documented at &kamwikilink;. $xcapuri(...) PV ... $xcapuri(u=>data) = $hu; xdbg("SCRIPT: xcap service $xcapuri(u=>auid) for $xcapuri(u=>xuid)\n"); ...
Simple XCAP Server Config 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/...