From openSIPS

Documentation: Script Operators - 3.5

Documentation -> Manuals -> Manual devel -> Script Operators

Pages for other versions: devel 3.4 3.3 3.2 3.1 Older versions: 3.0 2.4 2.3 2.2 2.1 1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4


Script Operators v3.5
PrevNext

Table of Content (hide)

  1. 1. Assignment
  2. 2. String operations
  3. 3. Arithmetic and bitwise operations

Assignments, string and arithmetic operations can be done directly in the configuration file.

1. Assignment

Assignments can be done like in C, via '=' (equal) operator. Not that not all variables (from script) can be written, some are read-only. Check with listing of variables to see which ones can be written too.

$var(a) = 123;
$ru = "sip:user@domain";

There is a special assign operator ':=' (colon equal) that can be used with AVPs. If the right value is null, all AVPs with that name are deleted. If different, the new value will overwrite any existing values for the AVPs with than name (on other words, delete existing AVPs with same name, add a new one with the right side value).

$avp(val) := 123;

2. String operations

For strings, '+' is available to concatenate.

$var(a) = "test";
$var(b) = "sip:" + $var(a) + "@" + $fd;

3. Arithmetic and bitwise operations

For numbers, one can use:

Example:

$var(a) = 4 + ( 7 & ( ~2 ) );

NOTE: to ensure the priority of operands in expression evaluations do use __parenthesis__.

Arithmetic expressions can be used in condition expressions via test operator ' [ ... ] '.

if( [ $var(a) & 4 ] )
    log("var a has third bit set\n");
Retrieved from https://www.opensips.org/Documentation/Script-Operators-3-5
Page last modified on March 20, 2014, at 08:28 PM