Access a Variable across the Dialplans
Moderator: Brekeke Support Team
Access a Variable across the Dialplans
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
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
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
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
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
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
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
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
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?
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?