Forums Read-only archive

Access a Variable across the Dialplans

16 posts · Brekeke SIP Server Forum

skb007 Original post
1. Brekeke Product Name and Version:BSS Adv Ver 3.5.2

2. Java version:1.8

3. OS type and the version:RHEL 6.1

4. UA (phone), gateway or other hardware/software involved:SIPP

5. Your problem:
I need to save the value in a variable and use the variable in the next dial plan.
In the first dial plan, I want to run a webget and retrieve the value from a remote server. If the returned value is 404 then I want to get the action to 404. In the next dial plan I want to check if returned value is 503 then I want to set the action as 503. If the length of the retuened value is more than 3 then I wan to terminate the call as explain in the last dial plan.


Matching Patterns
$addr = 192.168.2.180
$request =^INVITE
To = sip:(.+)@
From = sip:(.+)@
$web.webget("http://192.168.2.100/getValue.php?param1=%1") = (.+)

Deploy Patterns
$myVariable = %3
$log = TEST-VARIABLE:$myVariable
$log = TEST:%3
$continue

Matching Patterns
$myVariable = 404

Deploy Patterns
$action = 404


Matching Patterns
$myVariable = 503

Deploy Patterns
$action = 503

Matching Patterns
$math.gt($str.length($myVariable),3) = true

Deploy Patterns
To =sip:$myVariable@192.168.2.130
Harold
Use &VARIABLE_NAME
Refer this: http://wiki.brekeke.com/wiki/Global-and ... -Dial-Plan

Rule-1: WebGet
[Matching Patterns]
$request = ^INVITE
$addr = 192.168.2.180
To = sip:(.+)@
$web.webget("http://192.168.2.100/getValue.php?param1=%1") = (.+)

[Deploy Patterns]
&my.variable = %2
$log = TEST-VARIABLE:&my.variable
$log = TEST:%2
$continue = true

Rule-2: Return Response
[Matching Patterns]
&my.variable = ^[456][0-9][0-9]$

[Deploy Patterns]
$response = %{&my.variable}

Rule-3: Route Call
[Matching Patterns]
$math.gt($str.length(&my.variable),3) = true

[Deploy Patterns]
To = sip:%{&my.variable}@192.168.2.130
skb007
Thanks and appreciate your help.
skb007
This works perfectly fine but I am not able to pass on the INVITE Parameters. to Leg-B

for example I recieve the INVITE as :

INVITE sip:+111@192.168.2.5:5060;user=phone SIP/2.0

and I am sending out the INVITE as

INVITE sip:+222@192.168.2.55:5060 SIP/2.0
Harold
Change Rule-3 as this.

[Matching Patterns]
$math.gt($str.length(&my.variable),3) = true

[Deploy Patterns]
To/uri = sip:%{&my.variable}@192.168.2.130
skb007
Appreciate your response.

One final request. How to enhance the rule-3 with failover option
For example, first attempt should goto 192.168.2.130 and in case .130 does not respond or respond with roll over cause code then second attempt should be attempted to 192.168.2.131
janP
FYI:
http://wiki.brekeke.com/wiki/How-to-mak ... -Dial-Plan

[Deploy Patterns]
To/uri = sip:%{&my.variable}@192.168.2.130
$session = failover sip:%{&my.variable}@192.168.2.131
skb007
Math.gt function is throwing java exception. Following is the output from the dial plan log.





Warning: plug-in = public static boolean com.brekeke.net.sip.sv.rule.matching.plugins.math.gt(java.lang.String[],com.brekeke.net.sip.SIPpacket,java.util.Properties) throws java.lang.Exception message=java.lang.NumberFormatException: For input string: ""
DialPlan: Exception: 09/10/18 15:39:12.004
java.lang.NumberFormatException: For input string: "": (depth=14)
java.lang.NumberFormatException.forInputString (NumberFormatException.java:65)
java.lang.Long.parseLong (Long.java:601)
java.lang.Long.parseLong (Long.java:631)
com.brekeke.net.sip.sv.rule.matching.plugins.math.gt (null:-1)
sun.reflect.GeneratedMethodAccessor3.invoke (null:-1)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
com.brekeke.net.sip.sv.rule.RuleTable.invokeMethod (null:-1)
com.brekeke.net.sip.sv.rule.RuleTable.execMatchingPlugin (null:-1)
com.brekeke.net.sip.sv.rule.RuleTable.getSpecialValue (null:-1)
com.brekeke.net.sip.sv.rule.RuleTable.getValue (null:-1)
com.brekeke.net.sip.sv.rule.RuleTable.evalRule (null:-1)
com.brekeke.net.sip.sv.rule.RuleTable.getMatch (null:-1)
com.brekeke.net.sip.sv.Dispatcher.run (null:-1)

Pattern: $math.gt($str.length(&my.variable),3) = true
Input: $math.gt($str.length(&my.variable),3) = null
Result: false
janP
put a double-quotation around 3.

$math.gt($str.length(&my.variable),"3")
skb007
Math.gt problem got resolved, thanks for your help.

Following helps to fix the parameters in the TO header but it does not help to replay the paramaters in the INVITE request.

Deploy Patterns
To/uri = sip:%{&my.variable}@192.168.2.130


Incoming Packet INVITE sip:+11111@192.168.2.5:5060;user=phone SIP/2.0
Outgoing Packet INVITE sip:+22222@192.168.2.130 SIP/2.0

How can I main the INVITE params?
Tata
Something wrong in SIP packet or settings.
Check the DialPlan history whether "user=phone" exists or not.

Also can you paste all of DialPlan rules here?
skb007
Here is complete rule-3


Matching Patterns
$math.gt($str.length(&my.variable),"3") = true

Deploy Patterns
To/uri = sip:%{&my.variable}@192.168.2.130
$session = failover sip:%{&my.variable}@192.168.2.131
&failover.timer.inviting = 1
$b2bua = true
$rtp = false
$ifdst = 192.168.2.5
$ifsrc = 192.168.2.6
Tata
Did you check the DialPlan history to see whether "user=phone" exists originally?

If yes, enable "DialPlan" at [Diagnostics]->[Debug Logs] page and check why it is removed.
skb007
Yes, I did. I copy/pasted from the the dialplan history.
Tata
Have you checked the log too?
Tata
Add the line below at [Configuration]->[Advanced] page
---------------------------------------
net.sip.keep.uri-param=true
---------------------------------------