Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Using $eval to determine if string exists
Author Message
jasongreb
Brekeke Newbie


Joined: 25 Aug 2022
Posts: 4
Location: North Carolina

PostPosted: Thu Jun 01, 2023 5:32 pm    Post subject: Using $eval to determine if string exists Reply with quote

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
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Fri Jun 02, 2023 11:35 am    Post subject: Reply with quote

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
View user's profile
jasongreb
Brekeke Newbie


Joined: 25 Aug 2022
Posts: 4
Location: North Carolina

PostPosted: Fri Jun 02, 2023 2:26 pm    Post subject: Reply with quote

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
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Fri Jun 02, 2023 3:30 pm    Post subject: Reply with quote

Why do you want to modify the c= line of SDP?
It should be a destination IP address for RTP packets.

Anyway does &net.rtp.ifdst or &net.rtp.ifsrc meet the requirement?
https://docs.brekeke.com/sip/net-rtp-ifdst
https://docs.brekeke.com/sip/net-rtp-ifsrc

> Is there a document that describes all of these in detail where I could determine that myself?

Have you looked at the link below?
https://docs.brekeke.com/sip/dial-plan-reference
Back to top
View user's profile
jasongreb
Brekeke Newbie


Joined: 25 Aug 2022
Posts: 4
Location: North Carolina

PostPosted: Fri Jun 02, 2023 5:17 pm    Post subject: Reply with quote

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
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Sun Jun 04, 2023 9:50 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1