Author |
Message |
jasongreb Brekeke Newbie
Joined: 25 Aug 2022 Posts: 4
Location: North Carolina
|
Posted: Thu Jun 01, 2023 5:32 pm Post subject: Using $eval to determine if string exists |
|
|
1. Brekeke Product Name and Version: SIP Server
2. Java version: 11.0.15
3. OS type and the version: Windows Server 2019
4. UA (phone), gateway or other hardware/software involved: Responder/FreePBX
5. Your problem:
I am attempting to determine if a particular string exists in the caller ID - $getDisplayName(From) field - and take action if it does by modifying the SIP message and then $continue = true. I have a matching pattern that breaks up the From field into three pieces. I am attempting to determine if %3 contains that string with an $eval function. I have tried various versions of $eval(%3 = My String) = ^true with quotes around the various components, no quotes, etc. What is the proper way to use the eval function? Searching for "eval" on the forum is useless as it only brings up people talking about the evaluation edition. And the Wiki has only one example and it doesn't include variables. |
|
Back to top |
|
Laurie Brekeke Master Guru
Joined: 07 Jan 2008 Posts: 245
|
Posted: Fri Jun 02, 2023 11:35 am Post subject: |
|
|
You can write the matching pattern like this for example
Matching Patterns | $request = ^INVITE $getDisplayName(From) = (\d+) (\d+) (.+) "%3" = My String
|
With $eval, the above can be written as the following.
Matching Patterns | $request = ^INVITE $getDisplayName(From) = (\d+) (\d+) (.+) $eval("\"%3\" = My String") = ^true
|
If you want to use %3 in a later rule, store the %3 to a variable like &my.value3.
Rule-1: Parse Caller ID
Matching Patterns | $request = ^INVITE $getDisplayName(From) = (\d+) (\d+) (.+)
| Deploy Patterns | &my.value1 = %1 &my.value2 = %2 &my.value3 = %3 $continue = true
|
Rule-2: Find My String
Matching Patterns | $request = ^INVITE &my.value3 = My String
|
|
|
Back to top |
|
jasongreb Brekeke Newbie
Joined: 25 Aug 2022 Posts: 4
Location: North Carolina
|
Posted: Fri Jun 02, 2023 2:26 pm Post subject: |
|
|
That worked great, thank you! One last question you may be able to answer. I'd like to modify the SDP body. In particular, the c= line. Do you know if there is a deploy function specific to that? I see a long list of potential variables/functions, but no description of them. Is there a document that describes all of these in detail where I could determine that myself? |
|
Back to top |
|
Laurie Brekeke Master Guru
Joined: 07 Jan 2008 Posts: 245
|
|
Back to top |
|
jasongreb Brekeke Newbie
Joined: 25 Aug 2022 Posts: 4
Location: North Carolina
|
Posted: Fri Jun 02, 2023 5:17 pm Post subject: |
|
|
As odd as it may sound, what I'm attempting to do is make it so the phone that receives the call with that particular string can't communicate back. I want the INVITE to make it to the phone, but any return communication to never make it back so that the calling system thinks that the phone is still ringing and then eventually time out after about 120 seconds. Ideally, I'd rather block the 200 OK status from the phone itself so that Trying and Ringing still make it back.
I've looked at the docs on that page but it's hit or miss which ones are there, and there isn't much of an explanation. |
|
Back to top |
|
Laurie Brekeke Master Guru
Joined: 07 Jan 2008 Posts: 245
|
Posted: Sun Jun 04, 2023 9:50 am Post subject: |
|
|
Remove these &net.rtp.ifdst / &net.rtp.ifsrc, and insert $rtp=true in Matching Patterns.
$rtp=true makes the SIP Server handles RTP-relay.
https://docs.brekeke.com/sip/rtp |
|
Back to top |
|
|