_
Home
Features
News
Download
Roadmap
Management
Contributions
OpenSER License
Links
Contact Us
Related
EVENTS
OpenSER Summit 2008
OpenSER Pavilion 2008
VoIP Events
Past Events
SUPPORT
Documentation
Install
Mailing lists
Dokuwiki
Forum
VoIP Info
IRC Channel
DEVELOPMENT
SVN
Tracker
Project Page
Doxygen

Script variables and pseudo-variables in script Print

2007-01-29
- using development version (upcoming 1.2.0) you can manage the pseudo-variables directly from configuration file ...

From the annoucement:

<snip> 

OpenSER development version allows now ability to use pseudo-variables directly in configuration file. In addition to old pseudo-variables you know, a new type was introduced: script variables - the format is $var(name) where name can be any string of digits and characters.

Basically this are variables that can have integer or string values and they can be set directly in the configuration file via 'assign operation. The big advantage is that they are directly referenced at runtime, avoiding searching each access time. They are specific per processes and survive over multiple sip message processing (be sure you set the value before testing it -- e.g., $var(counter) = $var(counter) + 1 at the beginning of main route is a counter of messages processed). The script variables are initialized at startup to '0'. You can shift between value types: e.g., '$var(a)=1; $var(a)="openser";'  is valid.

The switch statement can be used now with any valid pseudo-variable ('retcode' must be now replaced with '$retcode' to get old behavior).  switch($rU) will compare the r-uri username with 'case' values. The case 'values' can be string or integer.

switch($rU) {
case "101": xlog("dialed number is 101\n"); break;
case "102": xlog("dialed number is 102\n"); break;
default: xlog("dialed number is $rU\n");
}

Assignments of script variables, AVPs, R-URI parts (username, domain, and URI) and dst URI can be done as well in script.
$avp(i:11) = 1; - sets the value of $avp(i:11) to integer '1'
$avp(i:11) = "1"; - sets the value of $avp(i:11) to string '1'
$ru = "sip:"+$var(user)+"@"+$fd; - sets the R-URI to string composed from value of variable $var(user) and From URI domain

'+' can be used to concatenate strings or do arithmetic addition. Other arithmetic operators:
- '-' - minus
- '/' - divide
- '*' - multiply
- '%' - modulo
- '|' - bitwise OR
- '&' - bitwise AND
- '^' - bitwise XOR
- '~' - bitwise NOT

If you want to evaluate arithmetic operations and test the value in conditions, use the test operator ' [ ... ] ' . This is required to convert the result to internal convention for drop, true and false.

if ( [ $var(a)&4 ] ) {
  xlog("bit 3 is set in var a");

}

</snip> 

See full announcement:

http://openser.org/pipermail/users/2007-January/008831.html

PayPal
Support This Project
FLASHNEWS

15 May 2008 

Version 1.3.2 of OpenSER has been released, including experinces and feedbacks from live operating platforms.....

Read more...

2008-05-06
- OPENSER Devel Guide available online ... 

Read more...
25 April 2008
First OpenSER teaching book  -"Building Telephony Systems with OpenSER"- is now available....
Read more...

2008-04-24
- new module available that allows direct connection to Oracle databases ...

Read more...

2008-04-07

- Post Facts from OpenSER Summit and Pavilion...

Read more...

2008-04-02
- social networking events during April to June 2008...

Read more...

2008-03-31
- OpenSER in the top of Open Source VoIP and reported to route billions of minutes per month... 

Read more...

 

.:: (C) 2005-2007 OpenSER. org::.