Copyright © 2008, 2005, 2003 1&1 Internet AG, FhG Fokus, voice-system
Revision History | |
---|---|
Revision $Revision: 4872 $ | $Date: 2008-09-09 17:39:38 +0200 (Di, 09 Sep 2008) $ |
Table of Contents
ring_insert_callid()
options_reply()
is_user(username)
has_totag()
uri_param(param)
uri_param(param,value)
add_uri_param(param)
tel2sip()
is_uri_user_e164(pseudo-variable)
encode_contact(encoding_prefix,hostpart)
decode_contact()
decode_contact_header()
cmp_uri(str1, str2)
cmp_aor(str1, str2)
List of Examples
ring_timeout
parameteroptions_accept
parameteroptions_accept_encoding
parameterdb_url
parameteroptions_accept_language
parameteroptions_support
parameterring_insert_callid()
usageoptions_reply
usageis_user
usagehas_totag
usageuri_param
usageuri_param
usageadd_uri_param
usagetel2sip
usageis_uri_user_e164
usageencode_contact
usagedecode_contact
usagedecode_contact_header
usagecmp_uri
usagecmp_aor
usageTable of Contents
ring_insert_callid()
options_reply()
is_user(username)
has_totag()
uri_param(param)
uri_param(param,value)
add_uri_param(param)
tel2sip()
is_uri_user_e164(pseudo-variable)
encode_contact(encoding_prefix,hostpart)
decode_contact()
decode_contact_header()
cmp_uri(str1, str2)
cmp_aor(str1, str2)
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 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 which 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).
The following modules must be loaded before this module:
sl -- Stateless replies.
Timeout value in seconds, define how long the call-id is stored in the internal list. A reasonable value is “30”.
Default value is “0”.
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 “*/*”.
Example 1.2. Set options_accept
parameter
... modparam("siputils", "options_accept", "application/*") ...
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 “”.
Example 1.3. Set options_accept_encoding
parameter
... modparam("siputils", "options_accept_encoding", "gzip") ...
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 “*”.
then an encoded uri might look sip:user-password-ip-port-protocol@PublicIP
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 much devices around which support other languages then the default English.
Default value is “en”.
Example 1.5. Set options_accept_language
parameter
... modparam("siputils", "options_accept_language", "de") ...
This parameter is the content of the Support header field. 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 “”.
Example 1.6. Set options_support
parameter
... modparam("siputils", "options_support", "100rel") ...
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 not 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.
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.
Example 1.8. options_reply
usage
... if (uri==myself) { if ((method==OPTIONS) && (! uri=~"sip:.*[@]+.*")) { options_reply(); } } ...
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.
Check if To header field uri contains tag parameter.
This function can be used from REQUEST_ROUTE.
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.
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.
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.
Converts RURI, if it is tel URI, to SIP URI. Returns true only if conversion succeeded or if no conversion was needed (like RURI was not tel URI).
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 host is formed using the From URI host.
This function can be used from REQUEST_ROUTE.
Example 1.14. tel2sip
usage
... # RURI: tel:+(34)-999-888-777 tel2sip(); # RURI: sip:+34999888777@foo.com;user=phone # RURI: tel:+12-(34)-56-78;Ext=200;ISUB=+123-456 tel2sip(); # RURI: sip:+12345678;ext=200;isub=+123-456@foo.com;user=phone ...
Checks if userpart of URI stored in pseudo variable is E164 number.
This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
Example 1.15. is_uri_user_e164
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 ... }; ...
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 paramters (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.
Example 1.16. encode_contact
usage
... if (src_ip == 10.0.0.0/8) encode_contact("natted_client","1.2.3.4"); ...
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.
This function will decode URIs 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.
Example 1.18. decode_contact_header
usage
... reply_route[2] { ... decode_contact_header(); ... } ...
The function returns true if the two parameters matches as SIP URI.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and BRANCH_ROUTE.
Example 1.19. cmp_uri
usage
... if(cmp_uri("$ru", "sip:kamailio@kamailio.org")) { # do interesting stuff here } ...
The function returns true if the two parameters matches as AoR. The parameters have to be SIP URIs.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and BRANCH_ROUTE.
Example 1.20. cmp_aor
usage
... if(cmp_aor("$rU@KaMaIlIo.org", "sip:kamailio@$fd")) { # do interesting stuff here } ...