KEx Module

Daniel-Constantin Mierla

asipto.com

Edited by

Daniel-Constantin Mierla


Table of Contents

1. Admin Guide
1. Overview
2. Dependencies
2.1. Kamailio Modules
2.2. External Libraries or Applications
3. Exported Functions
3.1. setsflag(flag)
3.2. issflagset(flag)
3.3. resetsflag(flag)
3.4. setbflag(flag [, branch])
3.5. isbflagset(flag [, branch])
3.6. resetsflag(flag [, branch])
3.7. km_append_branch([uri])
3.8. setdsturi(uri)
3.9. resetdsturi()
3.10. isdsturiset()
3.11. pv_printf(var, str)
4. Exported MI Functions
4.1. arg
4.2. kill
4.3. pwd
4.4. uptime
4.5. version
4.6. which

List of Examples

1.1. setsflag usage
1.2. setsflag usage
1.3. resetsflag usage
1.4. setbflag usage
1.5. setbflag usage
1.6. resetsflag usage
1.7. km_append_branch usage
1.8. >setdsturi usage
1.9. >resetdsturi usage
1.10. >isdsturiset usage
1.11. >pv_printf usage

Chapter 1. Admin Guide

1. Overview

This module collects extensions from Kamailio core.

Kamailio Core CookBook is available at: http://kamailio.org/dokuwiki/

2. Dependencies

2.1. Kamailio Modules

The following modules must be loaded before this module:

  • No dependencies on other Kamailio modules.

2.2. External Libraries or Applications

The following libraries or applications must be installed before running Kamailio with this module loaded:

  • None.

3. Exported Functions

3.1. setsflag(flag)

Set the script flag.

Meaning of the parameters is as follows:

  • flag - the index of the script flag to be set. Can be integer or pseudo-variable with integer value.

This function can be used from ANY_ROUTE.

Example 1.1. setsflag usage

...
setsflag("1");
...
$var(flag) = 11;
setsflag("$var(flag)");
...

3.2. issflagset(flag)

Return true of the script flag is set.

Meaning of the parameters is as follows:

  • flag - the index of the script flag to be tested. Can be integer or pseudo-variable with integer value.

This function can be used from ANY_ROUTE.

Example 1.2. setsflag usage

...
if(issflagset("1"))
{
    ...
}
...

3.3. resetsflag(flag)

Reset the script flag.

Meaning of the parameters is as follows:

  • flag - the index of the script flag to be reset. Can be integer or pseudo-variable with integer value.

This function can be used from ANY_ROUTE.

Example 1.3. resetsflag usage

...
resetsflag("1");
...

3.4. setbflag(flag [, branch])

Set the branch flag.

Meaning of the parameters is as follows:

  • flag - the index of the branch flag to be set. Can be integer or pseudo-variable with integer value.

  • branch - the index of the branch whose flag to be set. Can be integer or pseudo-variable with integer value. If omitted, then branch 0 is used (R-URI).

This function can be used from ANY_ROUTE.

Example 1.4. setbflag usage

...
setbflag("1");
...
$var(flag) = 11;
setbflag("$var(flag)", "1");
...

3.5. isbflagset(flag [, branch])

Return true of the branch flag is set.

Meaning of the parameters is as follows:

  • flag - the index of the branch flag to be tested. Can be integer or pseudo-variable with integer value.

  • branch - the index of the branch whose flag to be set. Can be integer or pseudo-variable with integer value. If omitted, then branch 0 is used (R-URI).

This function can be used from ANY_ROUTE.

Example 1.5. setbflag usage

...
if(isbflagset("1"))
{
    ...
}
...

3.6. resetsflag(flag [, branch])

Reset the script flag.

Meaning of the parameters is as follows:

  • flag - the index of the script flag to be reset. Can be integer or pseudo-variable with integer value.

  • branch - the index of the branch whose flag to be set. Can be integer or pseudo-variable with integer value. If omitted, then branch 0 is used (R-URI).

This function can be used from ANY_ROUTE.

Example 1.6. resetsflag usage

...
resetbflag("1");
...

3.7. km_append_branch([uri])

Append a new branch to SIP request.

Meaning of the parameters is as follows:

  • uri - SIP URI of the new destination. If omitted then the R-URI is used. It can be static string or a string with pseudo-variables that will be evaluated at runtime.

This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.

Example 1.7. km_append_branch usage

...
km_append_branch();
...
km_append_branch("sip:alice@sip-router.org");
...

3.8. setdsturi(uri)

Set the destination address URI (outbound proxy address).

Meaning of the parameters is as follows:

  • uri - Valid SIP URI representing the address where to send the request. It must be a static string, no variables are evaluated at runtime. If you need to set outbound proxy address via a variable, use assginment to $du.

This function can be used from ANY_ROUTE.

Example 1.8. >setdsturi usage

...
setdsturi("sip:10.0.0.10");
...

3.9. resetdsturi()

Reset the destination address URI (outbound proxy address).

This function can be used from ANY_ROUTE.

Example 1.9. >resetdsturi usage

...
resetdsturi();
...

3.10. isdsturiset()

Check if the destination address URI (outbound proxy address) is set.

This function can be used from ANY_ROUTE.

Example 1.10. >isdsturiset usage

...
if(isdsturiset())
{
   ...
}
...

3.11. pv_printf(var, str)

Evalues the str and sets the resulted value to variable var. For backward compatibility reasons, same function can be executed via 'avp_printf(var, str)'.

Meaning of the parameters is as follows:

  • var - name of a writable variable

  • str - string that may contain variables which will be evaluated at runtime.

This function can be used from ANY_ROUTE.

Example 1.11. >pv_printf usage

...
pv_printf("$ru", "sip:$rU@$fd");
pv_printf("$avp(x)", "From: $fU - To: $tU");
...

4. Exported MI Functions

4.1.  arg

Print command line arguments.

Name: arg

Parameters: none.

MI FIFO Command Format:

		:arg:_reply_fifo_file_
		_empty_line_

4.2.  kill

Kill the application.

Name: kill

Parameters: none.

MI FIFO Command Format:

		:kill:_reply_fifo_file_
		_empty_line_

4.3.  pwd

Print working directory.

Name: pwd

Parameters: none.

MI FIFO Command Format:

		:pwd:_reply_fifo_file_
		_empty_line_

4.4.  uptime

Print uptime.

Name: uptime

Parameters: none.

MI FIFO Command Format:

		:uptime:_reply_fifo_file_
		_empty_line_

4.5.  version

Print version information.

Name: version

Parameters: none.

MI FIFO Command Format:

		:version:_reply_fifo_file_
		_empty_line_

4.6.  which

Print list of available MI commands.

Name: which

Parameters: none.

MI FIFO Command Format:

		:which:_reply_fifo_file_
		_empty_line_