Table of Contents
List of Examples
http_query_timeout
parameterforward_active
parameterpres_db_url
parameterxcap_table
parameterhttp_query()
usagexcap_auth_status()
usageforward_list
usageforward_switch
usageforward_filter
usageforward_proxy
usageTable of Contents
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.
The following modules must be loaded before this module:
a database module if xcap_auth_status function is enabled.
Defines in seconds how long Kamailio waits for response from HTTP server.
Default value is zero, i.e., that the http_query_timeout function is disabled.
Defines if the forwarding callback should be installed.
Default value is “0” - disabled.
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, the first line of the 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.
Example 1.5. http_query()
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 checks in the presence server database if a watcher is authorized to subscribe to event “presence” of presentity. Sphere checking is not included.
Both watcher_uri and presentity_uri are pseudo variables. The function returns ACTIVE_STATUS, if a 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.
Example 1.6. xcap_auth_status()
usage
... if (method=="MESSAGE") { xcap_auth_status("$fu", $ru"); if ($retcode == 1) { t_relay(); } else { send_reply("403", "Forbidden"); } } ...
List active forward rules.
No parameters.
Example 1.7. forward_list
usage
... kamctl fifo forward_list id switch filter proxy 0 off REGISTER:INVITE:SUBSCRIBE host-a.domain-a:5060 ...
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).
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:
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).
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).
This grammar specify the usable configuration syntax