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

Sasmita Panda spanda at 3clogic.com
Fri Oct 27 10:15:34 UTC 2023


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> 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
>
> [2] https://www.opensips.org/Documentation/Script-Tran-3-2#toc82
>
>
>
> Ben Newlin
>
>
>
> *From: *Users <users-bounces at lists.opensips.org> on behalf of Sasmita
> Panda <spanda at 3clogic.com>
> *Date: *Thursday, October 26, 2023 at 8:46 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 *
>
>
> ------------------------------
>
> Is there any update on this ?
>
>
>
> On Wed, 25 Oct 2023, 19:27 Sasmita Panda, <spanda at 3clogic.com> wrote:
>
> Hi Ben ,
>
>
>
> Please correct me if I am wrong .
>
>
>
> *$avp(attr) : sales,level20,en,true*
>
> *$hdr(Call-Info) : sales,en*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> * if ($(avp(attr){s.index, $hdr(Call-Info)}) != NULL)
>       {                                xlog("found $hdr(Call-Info)  in
> $avp(attr) \n");                                 if (next_branches()){
>                                     t_on_failure("1");
>             }                           }                          else {
>                              sl_send_reply(500,"Unable to load contacts");
>                                 exit;                          }*
>
>
>
> In this case , although $hdr(Call-Info) is a substring of $avp(attr) still
> it's going in the else block and giving me *500  Unable to load contacts*
> .
>
>
>
> Does the substring must contain continuous values ?
>
>
>
>
>
>
>
>
>
> *Thanks & Regards*
>
> *Sasmita Panda*
>
> *Senior Network Testing and Software Engineer*
>
> *3CLogic , ph:07827611765*
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20231027/d248c05d/attachment.html>


More information about the Users mailing list