%docentities; ]> &adminguide;
Overview This module implement various functions and checks related to SIP message handling and URI handling. It offers some functions related to handle ringing. In a parallel forking scenario you get several 183s with SDP. You don't want that your customers hear more than one ringtone or answer machine in parallel on the phone. So its necessary to drop the 183 in this cases and send a 180 instead. This module also provides a function to answer OPTIONS requests which are directed to the server itself. This means an OPTIONS request which has the address of the server in the request URI, and no username in the URI. The request will be answered with a 200 OK with the capabilities of the server. To answer OPTIONS request directed to your server is the easiest way for is-alive-tests on the SIP (application) layer from remote (similar to ICMP echo requests, also known as ping, on the network layer).
Dependencies
&kamailio; Modules The following modules must be loaded before this module: sl -- Stateless replies.
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: None.
Parameters
<varname>ring_timeout</varname> (int) Timeout value in seconds, define how long the call-id is stored in the internal list kept for replacing 183 messages with 180. A reasonable value is 30. Default value is 0. This means functionality is disabled. Set <varname>ring_timeout</varname> parameter ... modparam("siputils", "ring_timeout", 30) ...
<varname>options_accept</varname> (string) This parameter is the content of the Accept header field. Note: it is not clearly written in RFC3261 if a proxy should accept any content (the default */*) because it does not care about content. Or if it does not accept any content, which is . Default value is */*. Set <varname>options_accept</varname> parameter ... modparam("siputils", "options_accept", "application/*") ...
<varname>options_accept_encoding</varname> (string) This parameter is the content of the Accept-Encoding header field. Please do not change the default value because &kamailio; does not support any encodings yet. Default value is . Set <varname>options_accept_encoding</varname> parameter ... modparam("siputils", "options_accept_encoding", "gzip") ...
<varname>contact_flds_separator</varname> (string) First char of this parameter is used as separator for encoding/decoding Contact header. First char of this field must be set to a value which is not used inside username,password or other fields of contact. Otherwise it is possible for the decoding step to fail/produce wrong results. Default value is *. Set <varname>contact_flds_separator</varname> parameter ... modparam("siputils", "contact_flds_separator", "-") ... then an encoded uri might look sip:user-password-ip-port-protocol@PublicIP
<varname>options_accept_language</varname> (string) This parameter is the content of the Accept-Language header field. You can set any language code which you prefer for error descriptions from other devices, but presumably there are not many devices around which support other languages than the default English. Default value is en. Set <varname>options_accept_language</varname> parameter ... modparam("siputils", "options_accept_language", "de") ...
<varname>options_support</varname> (string) This parameter is the content of the Support header field, indicating SIP extensions. Please do not change the default value, because &kamailio; currently does not support any of the SIP extensions registered at the IANA. Default value is . Set <varname>options_support</varname> parameter ... modparam("siputils", "options_support", "100rel") ...
<varname>rpid_prefix</varname> (string) Prefix to be added to Remote-Party-ID header field just before the URI returned from either radius or database. Default value is . rpid_prefix parameter example modparam("auth", "rpid_prefix", "Whatever <")
<varname>rpid_suffix</varname> (string) Suffix to be added to Remote-Party-ID header field after the URI returned from either radius or database. Default value is ;party=calling;id-type=subscriber;screen=yes. rpid_suffix parameter example modparam("auth", "rpid_suffix", "@1.2.3.4>")
<varname>rpid_avp</varname> (string) Full AVP specification for the AVP which stores the RPID value. It used to transport the RPID value from authentication backend modules (auth_db or auth_radius) or from script to the auth function append_rpid_hf and is_rpid_user_e164. If defined to NULL string, all RPID functions will fail at runtime. Default value is $avp(s:rpid). rpid_avp parameter example modparam("auth", "rpid_avp", "$avp(myrpid)")
Functions
<function moreinfo="none">ring_insert_callid()</function> Inserting the call-id in the internal list, which is checked when further replies arrive. Any 183 reply that is received during the timeout value will be converted to a 180 message. Please note that you need to set a positive timeout value in order to use this function. The function returns TRUE on success, and FALSE during processing failures. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE. <function>ring_insert_callid()</function> usage ... ring_insert_callid(); ...
<function moreinfo="none">options_reply()</function> This function checks if the request method is OPTIONS and if the request URI does not contain an username. If both is true the request will be answered stateless with 200 OK and the capabilities from the modules parameters. It sends 500 Server Internal Error for some errors and returns false if it is called for a wrong request. The check for the request method and the missing username is optional because it is also done by the function itself. But you should not call this function outside the myself check because in this case the function could answer OPTIONS requests which are sent to you as outbound proxy but with an other destination then your proxy (this check is currently missing in the function). This function can be used from REQUEST_ROUTE. <function>options_reply</function> usage ... if (uri==myself) { if ((method==OPTIONS) && (! uri=~"sip:.*[@]+.*")) { options_reply(); } } ...
<function moreinfo="none">is_user(username)</function> Check if the username in credentials matches the given username. Meaning of the parameters is as follows: username - Username string. This function can be used from REQUEST_ROUTE. <function>is_user</function> usage ... if (is_user("john")) { ... }; ...
<function moreinfo="none">has_totag()</function> Check if To header field uri contains tag parameter. This function can be used from ANY_ROUTE. <function>has_totag</function> usage ... if (has_totag()) { ... }; ...
<function moreinfo="none">uri_param(param)</function> Find if Request URI has a given parameter with no value Meaning of the parameters is as follows: param - parameter name to look for. This function can be used from REQUEST_ROUTE. <function>uri_param</function> usage ... if (uri_param("param1")) { ... }; ...
<function moreinfo="none">uri_param(param,value)</function> Find if Request URI has a given parameter with matching value Meaning of the parameters is as follows: param - parameter name to look for. value - parameter value to match. This function can be used from REQUEST_ROUTE. <function>uri_param</function> usage ... if (uri_param("param1","value1")) { ... }; ...
<function moreinfo="none">add_uri_param(param)</function> Add to RURI a parameter (name=value); Meaning of the parameters is as follows: param - parameter to be appended in name=value format. This function can be used from REQUEST_ROUTE. <function>add_uri_param</function> usage ... add_uri_param("nat=yes"); ...
<function moreinfo="none">get_uri_param(name, var)</function> Get the value of RURI parameter. Meaning of the parameters is as follows: name - the name of R-URI parameter var - the variable where to store the value of the parameter This function can be used from REQUEST_ROUTE. <function>add_uri_param</function> usage ... get_uri_param("nat", "$var(nat)"); ...
<function moreinfo="none">tel2sip(uri, hostpart, result)</function> Converts URI in first param (pseudo variable or string) to SIP URI, if it is a tel URI. If conversion was done, writes resulting SIP URI to third param (pseudo variable). Returns 1 if conversion succeeded, 2 if no conversion was needed, and -1 in case of error. The conversion follows the rules in RFC 3261 section 19.1.6: Visual separators ( "-", ".", "(", ")" ) are removed from tel URI number before converting it to SIP URI userinfo. tel URI parameters are downcased before appending them to SIP URI userinfo The SIP URI hostpart is taken from second param (pseudo variable or string). This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE, or ONREPLY_ROUTE. <function>tel2sip</function> usage ... # $ru: tel:+(34)-999-888-777 # $fu: sip:test@foo.com tel2sip("$ru", $fd", "$ru"); # $ru: sip:+34999888777@foo.com;user=phone # $ru: tel:+12-(34)-56-78;Ext=200;ISUB=+123-456 # $fu: sip:test@foo.com tel2sip("$ru", $fd", "$ru"); # $ru: sip:+12345678;ext=200;isub=+123-456@foo.com;user=phone ...
<function moreinfo="none">is_e164(pseudo-variable)</function> Checks if string value of pseudo variable argument is an E164 number. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, and LOCAL_ROUTE. <function>is_e164</function> usage ... if (is_164("$fU")) { # Check From header URI user part ... } if (is_e164("$avp(i:705)") { # Check stgring value stored in avp i:705 ... }; ...
<function moreinfo="none">is_uri_user_e164(pseudo-variable)</function> Checks if userpart of URI stored in pseudo variable is E164 number. This function can be used from ANY_ROUTE. <function>is_uri_user_e164</function> usage ... if (is_uri_user_e164("$fu")) { # Check From header URI user part ... } if (is_uri_user_e164("$avp(i:705)") { # Check user part of URI stored in avp i:705 ... }; ...
<function moreinfo="none">is_tel_number(tval)</function> Checks if the parameter value is a telephone number: starting with one optional +, followed by digits. The parameter can include variables. This function can be used from ANY_ROUTE. <function>is_tel_number</function> usage ... if (is_tel_number("$rU")) { # Test if R-URI user is telephone number ... } if (is_tel_number("+24242424") { ... } ...
<function moreinfo="none">is_numeric(tval)</function> Checks if the parameter value consists solely of decimal digits. The parameter can include variables. This function can be used from ANY_ROUTE. <function>is_numeric</function> usage ... if (is_numeric($rU)) { # Test if R-URI user consists of decimal digits ... } ...
<function moreinfo="none">encode_contact(encoding_prefix,hostpart)</function> This function will encode uri-s inside Contact header in the following manner sip:username:password@ip:port;transport=protocol goes sip:encoding_prefix*username*ip*port*protocol@hostpart. * is the default separator and can be changed by setting the contact_flds_separator module parameter. Note: This function discards all of the URI parameters. Thus, none of the parameters (except the transport parameter which is encoded into the userpart) can be restored. The function returns negative on error, 1 on success. Meaning of the parameters is as follows: encoding_prefix - Something to allow us to determine that a contact is encoded. hostpart - An IP address or a hostname. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE. <function>encode_contact</function> usage ... if (src_ip == 10.0.0.0/8) encode_contact("natted_client","1.2.3.4"); ...
<function moreinfo="none">decode_contact()</function> This function will decode the request URI. If the RURI is in the format sip:encoding_prefix*username*ip*port*protocol@hostpart it will be decoded to sip:username:password@ip:port;transport=protocol It uses the default set parameter for contact encoding separator. The function returns negative on error, 1 on success. Meaning of the parameters is as follows: This function can be used from REQUEST_ROUTE. <function>decode_contact</function> usage ... if (uri =~ "^sip:natted_client") { decode_contact(); } ...
<function moreinfo="none">decode_contact_header()</function> This function will decode &uri;s inside Contact header. If the URI in the format sip:encoding_prefix*username*ip*port*protocol@hostpart it will be decoded to sip:username:password@ip:port;transport=protocol. It uses the default set parameter for contact encoding separator. The function returns negative on error, 1 on success. Meaning of the parameters is as follows: This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE. <function>decode_contact_header</function> usage ... reply_route[2] { ... decode_contact_header(); ... } ...
<function moreinfo="none">cmp_uri(str1, str2)</function> The function returns true if the two parameters matches as SIP URI. This function can be used from ANY_ROUTE. <function>cmp_uri</function> usage ... if(cmp_uri("$ru", "sip:kamailio@kamailio.org")) { # do interesting stuff here } ...
<function moreinfo="none">cmp_aor(str1, str2)</function> The function returns true if the two parameters matches as AoR. The parameters have to be SIP URIs. This function can be used from ANY_ROUTE. <function>cmp_aor</function> usage ... if(cmp_aor("$rU@KaMaIlIo.org", "sip:kamailio@$fd")) { # do interesting stuff here } ...
<function moreinfo="none">append_rpid_hf()</function> Appends to the message a Remote-Party-ID header that contains header 'Remote-Party-ID: ' followed by the saved value of the SIP URI received from the database or radius server followed by the value of module parameter radius_rpid_suffix. The function does nothing if no saved SIP URI exists. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE. append_rpid_hf usage ... append_rpid_hf(); # Append Remote-Party-ID header field ...
<function moreinfo="none">append_rpid_hf(prefix, suffix)</function> This function is the same as . The only difference is that it accepts two parameters--prefix and suffix to be added to Remote-Party-ID header field. This function ignores rpid_prefix and rpid_suffix parameters, instead of that allows to set them in every call. Meaning of the parameters is as follows: prefix - Prefix of the Remote-Party-ID URI. The string will be added at the begining of body of the header field, just before the URI. suffix - Suffix of the Remote-Party-ID header field. The string will be appended at the end of the header field. It can be used to set various URI parameters, for example. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE. append_rpid_hf(prefix, suffix) usage ... # Append Remote-Party-ID header field append_rpid_hf("", ";party=calling;id-type=subscriber;screen=yes"); ...
<function moreinfo="none">is_rpid_user_e164()</function> The function checks if the SIP URI received from the database or radius server and will potentially be used in Remote-Party-ID header field contains an E164 number (+followed by up to 15 decimal digits) in its user part. Check fails, if no such SIP URI exists (i.e. radius server or database didn't provide this information). This function can be used from REQUEST_ROUTE. is_rpid_user_e164 usage ... if (is_rpid_user_e164()) { # do something here }; ...
<function moreinfo="none">set_uri_user(uri, user)</function> Sets userpart of SIP URI stored in writable pseudo variable 'uri' to value of pseudo variable 'user'. This function can be used from ANY_ROUTE. set_uri_user usage ... $var(uri) = "sip:user@host"; $var(user) = "new_user"; set_uri_user("$var(uri)", "$var(user)"); ...
<function moreinfo="none">set_uri_host(uri, host)</function> Sets hostpart of SIP URI stored in writable pseudo variable 'uri' to value of pseudo variable 'host'. This function can be used from ANY_ROUTE. set_uri_host usage ... $var(uri) = "sip:user@host"; $var(host) = "new_host"; set_uri_host("$var(uri)", "$var(host)"); ...
<function moreinfo="none">is_request()</function> Return true if the SIP message is a request. This function can be used from ANY_ROUTE. <function>is_request</function> usage ... if (is_request()) { ... } ...
<function moreinfo="none">is_reply()</function> Return true if the SIP message is a reply. This function can be used from ANY_ROUTE. <function>is_reply</function> usage ... if (is_reply()) { ... } ...
<function moreinfo="none">is_gruu([uri])</function> The function returns true if the uri is GRUU ('gr' parameter is present): 1 - pub-gruu; 2 - temp-gruu. Meaning of the parameters is as follows: uri - the SIP URI to check for GRUU parameter. It is optional, when missing, the value of R-URI is used. This function can be used from ANY_ROUTE. is_gruu() usage ... if(is_gruu()) { ... } ...
<function moreinfo="none">is_supported(option)</function> Function returns true if given option is listed in Supported header(s) (if any) of the request. Currently the following options are known: path, 100rel, timer, eventlist, gruu, and outbound. This function can be used from ANY_ROUTE. is_supported() usage ... if (is_supported("outbound")) { ... } ...
<function moreinfo="none">is_first_hop()</function> The function returns true if the proxy is first hop after the original sender. For incoming SIP requests, it means there is only one Via header. For incoming SIP replies, it means that top Record-Route URI is 'myself' and source address is not matching it (to avoid detecting in case of local loops). Note that it does not detect spirals, which can have the condition for replies true also in the case of additional SIP reply receival. This function can be used from ANY_ROUTE. is_first_hop() usage ... if(is_first_hop()) { ... } ...
<function moreinfo="none">sip_p_charging_vector(flags)</function> Manage the P-Charging-Vector header (RFC3455). The flags can be: 'r' - remove; 'g' - generate; 'f' - force (remove + generate). This function can be used from ANY_ROUTE. sip_p_charging_vector() usage ... sip_p_charging_vector("g"); ...