%docentities; ]> &adminguide;
Overview This module implements various utility functions that are not SIP related. Function http_query allows &kamailio; to issue an HTTP GET request and get access to parts of the reply. The forward functionality allows &kamailio; to configure forwarding at runtime with FIFO commands. The forwarding is executed in the pre script call back and therefore handled before the routing script is executed on the current message. The callback is not installed on default, thus this functionality has no runtime overhead when its deactivated. Function xcap_auth_status can be used to check from presence server database, if watcher is authorized to subscribe event presence of presentity.
Dependencies
&kamailio; Modules The following modules must be loaded before this module: a database module if xcap_auth_status function is enabled.
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: libcurl.
Exported Parameters
<varname>http_query_timeout</varname> (int) Defines in seconds how long &kamailio; waits response from HTTP server. Default value is null, i.e., xcap_auth_status function is disabled. Set <varname>http_query_timeout</varname> parameter ... modparam("utils", "http_query_timeout", 2) ...
<varname>forward_active</varname> (int) Defines if the forwarding callback should be installed. Default value is 0. Set <varname>forward_active</varname> parameter ... modparam("utils", "forward_active", 1) ...
<varname>pres_db_url</varname> (string) Defines presence server database URL. If not given, xcap_auth_status function is disabled. There is no default value. Set <varname>pres_db_url</varname> parameter ... modparam("utils", "pres_db_url", "mysql://foo:secret@localhost/pres") ...
<varname>xcap_table</varname> (string) Defines name of xcap table in presence server database. Default value is xcap. Set <varname>xcap_table</varname> parameter ... modparam("utils", "xcap_table", "pres_xcap") ...
Exported Functions
<function moreinfo="none">http_query(url, result)</function> Sends HTTP GET request according to URL given in url parameter, which is a string that may contain pseudo variables. If HTTP server returns a class 2xx or 3xx reply, first line of reply's body (if any) is stored in result parameter, which must be a writable pseudo variable. Function returns reply code of HTTP reply or -1 if something went wrong. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, and BRANCH_ROUTE. <function>http_query()</function> usage ... http_query("http://tutpro.com/index.php?r_uri=$(ru{s.escape.param})&f_uri=$(fu{s.escape.param})", "$var(result)") switch ($retcode) { ... } ...
<function moreinfo="none">xcap_auth_status(watcher_uri, presentity_uri)</function> Function checks from presence server database if watcher is authorized to subscribe event presence of presentity. Sphere checking is not included. Both watcher_uri and presentity_uri are pseudo variables. Function returns ACTIVE_STATUS, if subscription is allowed and PENDING_STATUS, TERMINATED_STATUS, or WAITING_STATUS otherwise. See presence/subscribe.h for the corresponding integer codes. In case of error, function returns -1. Function can be used from REQUEST_ROUTE. <function>xcap_auth_status()</function> usage ... if (method=="MESSAGE") { xcap_auth_status("$fu", $ru"); if ($retcode == 1) { t_relay(); } else { send_reply("403", "Forbidden"); } } ...
<acronym>MI</acronym> Commands
<function moreinfo="none">forward_list</function> List active forward rules. No parameters. <function>forward_list</function> usage ... &ctltool; fifo forward_list id switch filter proxy 0 off REGISTER:INVITE:SUBSCRIBE host-a.domain-a:5060 ...
<function moreinfo="none">forward_switch</function> This command can be used to activate or deactivate forwarding rules. The syntax of this configuration string is described in 1.6. (switch_setting_list). <function>forward_switch</function> usage ... &ctltool; fifo sp_forward_switch 0=on ...
<function moreinfo="none">forward_filter</function> Can be used to specify the filter for a certain id. Messages will only be forwarded if one of the filters matches the message. There are special filters and regular filters. Special filters are: REQUEST (matches on every request) REPLY (matches on every reply) Regular filters are arbitrary strings not containing the delimiter ':'. They are matched against the request method names of the sip messages. The syntax of this configuration string is described in 1.6. (filter_setting_list). <function>forward_filter</function> usage ... &ctltool; fifo sp_forward_filter 0=REGISTER:INVITE ...
<function moreinfo="none">forward_proxy</function> This command can be used to configure forwarding rules. Specifies the destination for a certain id. Messages will be forwarded to this destination if the preconditions hold (matching id, filter, and switch). The syntax of this configuration string is described in 1.6. (proxy_setting_list). <function>forward_proxy</function> usage ... &ctltool; fifo sp_forward_proxy 0=host-c.domain-c:5060 ...
Configuration syntax This grammar specify the usable configuration syntax switch_setting_list ::= switch_setting { "," switch_setting } filter_setting_list ::= switch_setting { "," switch_setting } proxy_setting_list ::= proxy_setting { "," proxy_setting } switch_setting ::= id "=" switch filter_setting ::= id "=" filter_list proxy_setting ::= id "=" proxy switch ::= ( "off" | "on" ) filter_list ::= filter { ":" filter } proxy ::= host ":" port filter ::= ( special_filter | regular_filter ) special_filter ::= ( "REQUEST" | "REPLY" ) regular_filter ::= ? [^:]* ? host ::= char { char } char ::= ? A-Za-z0-9.-_ ? id ::= number port ::= number number ::= digit {digit} digit ::= ? 0-9 ?