[OpenSIPS-Users] I need some help in attr matching while forming the Branch .

Ben Newlin Ben.Newlin at genesys.com
Fri Oct 27 13:32:28 UTC 2023


Without seeing the specific exact code, I can’t say what is causing that error. It seems like it may be a syntax issue. For example, in your email you are missing the semicolon after the line setting the count. I don’t know if it is that way in your config script. I recommend double checking all your syntax, and if you still get the error please provide the exact code from your script for review.

For #2, I can’t really be very specific there because I don’t know all of your logic, nor am I very knowledgeable about the registrar module. My first thought is to not do any filtering/checking in the request route. Just allow the registrar module to load all contacts in branches, but arm a branch_route. Then perform the check in the branch route for each branch. If the Contact for the branch doesn’t match what you want, you can drop the branch [1].

[1] https://www.opensips.org/Documentation/Script-Routes-3-2#toc2

Ben Newlin

From: Users <users-bounces at lists.opensips.org> on behalf of Sasmita Panda <spanda at 3clogic.com>
Date: Friday, October 27, 2023 at 6:17 AM
To: OpenSIPS users mailling list <users at lists.opensips.org>
Subject: Re: [OpenSIPS-Users] I need some help in attr matching while forming the Branch .
 EXTERNAL EMAIL - Please use caution with links and attachments

________________________________
Ahhh , Ok .
Now it's very  complicated . When you said a loop that's looping in my mind . Sorry for the bad joke .

In case , the number of elements in each Invite won't be fixed . So the number of loops will vary from one Invite to another .
I was thinking of counting the number of elements first , then as the index starts from 0 I will loop till count-1 to fetch every element properly .

Example :
$var(count) = $(hdr(Call-Info){csv.count})    ## if the number is 3 then loop will be for 3 times starting from 0 to 2

 $var(i) = 0;
    while($var(i) < $var(count) )
    {
        xlog("counter: $var(i)\n");
        $var(i) = $var(i) + 1;
    }

This was my initial thought . But while finding the count it gave me an error .  $var(count) = $(hdr(Call-Info){csv.count})  Is this not in the correct format ?

parse error in /usr/local/etc/opensips/opensips-p2p.cfg:267:26-55: unknown script variable

As I have earlier mentioned my header will look like .
Call-Info: sales,en,level20,en (this can be anything but format will be like this . )  . How do I count the number of values ?

2. As I am doing this matching to filter out contacts, where should I do this ? If I am doing this while giving a call to the contacts , for the 1st transaction it is doing the comparison , after that for the next branch it processes the call without matching . Which is not right . For every contact this comparison should loop

Thanks & Regards
Sasmita Panda
Senior Network Testing and Software Engineer
3CLogic , ph:07827611765


On Thu, Oct 26, 2023 at 7:19 PM Ben Newlin <Ben.Newlin at genesys.com<mailto:Ben.Newlin at genesys.com>> wrote:
Sasmita,

Apologies, I replied yesterday but the message is being held by the list as the quoted replies have made it too large. I’ve removed some of the quoted replies and I’m copying my response below:

Yes, a substring match means the exact complete string exists somewhere in the string being searched . In your example, the $avp(attr) does not contain any substring that matches $hdr(Call-Info), so it is correctly failing.

If you want to check for the presence of each element, you need to loop through the elements in $hdr(Call-Info) and check for each one in the $avp(attr) using the s.index mechanism.

The best options for looping on the header are probably s.select [1] or the csv tranformations [2].

[1] https://www.opensips.org/Documentation/Script-Tran-3-2#toc7<https://www.opensips.org/Documentation/Script-Tran-3-2#toc7>
[2] https://www.opensips.org/Documentation/Script-Tran-3-2#toc82<https://www.opensips.org/Documentation/Script-Tran-3-2#toc82>

Ben Newlin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20231027/57b644a2/attachment-0001.html>


More information about the Users mailing list