<div dir="ltr">Hi Ben , <div><br></div><div><br><br>failure_route[1] {<br> if ( t_check_status("404|477|480|481|408|486|50[234]")){ <br> if (next_branches())<br> {<br> t_on_branch("attr");<br> }<br> <br> } <br>}<br><br><br>branch_route[attr]<br>{<br>$var(count) = $(hdr(Call-Info){csv.count});<br><br>$var(i) = 0;<br>$var(match-count) = 0;<br><br>while($var(i) < $(var(count))){<br><br> if ($(avp(attr){s.index, $(hdr(Call-Info){csv.value,$var(i)})}) != NULL){<br> xlog("counter: $var(i)th index matched in attribute \n");<br> $var(match-count)= $var(match-count) + 1;<br> }<br> xlog("counter: $var(i)\n");<br> $var(i) = $var(i) + 1;<br>}<br><br> if ($var(i) == $var(match-count)){<br>## Here I want to give call to that contact .. if that fails then again it should come to next branch and again compare <br> t_on_failure("1");<br> route(1);<br> }<br> else{<br># Here if the condition does not match . then i want to do the comparison again <br> if (next_branches()){<br> t_on_branch("attr");<br> }<br> # drop();<br> }<br>}<br></div><div><br></div><div>As for my expectation, it's not working . How does it work ? Where should I use T_branch_Idx ? Can I get some examples of this ?</div><div><br></div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b><i>Thanks & Regards</i></b><div><i>Sasmita Panda</i></div><div><i>Senior Network Testing and Software Engineer</i></div><div><i>3CLogic , ph:07827611765</i></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 27, 2023 at 7:10 PM Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com">Ben.Newlin@genesys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg6262538053711369304">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_6262538053711369304WordSection1">
<p class="MsoNormal"><span style="font-size:11pt">Just wanted to add that with the solution I recommended below, you would want to make sure you properly handle the case where all branches were dropped because none matched. The proper handling in that case
for your system would be defined by your requirements.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:black">Ben Newlin</span><span style="font-size:11pt"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div id="m_6262538053711369304mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">From:
</span></b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">Users <<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>> on behalf of Ben Newlin <<a href="mailto:Ben.Newlin@genesys.com" target="_blank">Ben.Newlin@genesys.com</a>><br>
<b>Date: </b>Friday, October 27, 2023 at 9:33 AM<br>
<b>To: </b>OpenSIPS users mailling list <<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>><br>
<b>Subject: </b>Re: [OpenSIPS-Users] I need some help in attr matching while forming the Branch .</span><span style="font-size:12pt;font-family:Aptos,sans-serif"><u></u><u></u></span></p>
</div>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-size:11pt">
<hr size="0" width="100%" align="center">
</span></div>
</div>
<p class="MsoNormal"><span style="font-size:11pt">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.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">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].</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">[1] <a href="https://www.opensips.org/Documentation/Script-Routes-3-2#toc2" target="_blank">
https://www.opensips.org/Documentation/Script-Routes-3-2#toc2</a></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;color:black">Ben Newlin</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div id="m_6262538053711369304mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">From:
</span></b><span style="font-size:12pt;font-family:Aptos,sans-serif;color:black">Users <<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>> on behalf of Sasmita Panda <<a href="mailto:spanda@3clogic.com" target="_blank">spanda@3clogic.com</a>><br>
<b>Date: </b>Friday, October 27, 2023 at 6:17 AM<br>
<b>To: </b>OpenSIPS users mailling list <<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>><br>
<b>Subject: </b>Re: [OpenSIPS-Users] I need some help in attr matching while forming the Branch .</span><span style="font-size:9pt;font-family:Helvetica;color:black"> </span><u></u><u></u></p>
</div>
<div>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-size:11pt">
<hr size="0" width="100%" align="center">
</span></div>
</div>
<p class="MsoNormal"><span style="font-size:11pt">Ahhh , Ok . </span><u></u><u></u></p>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Now it's very complicated . When you said a loop that's looping in my mind . Sorry for the bad joke . </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">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 . </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">I was thinking of counting the number of elements first , then as the index starts from 0 I will loop till
<b>count-1</b> to fetch every element properly . </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Example : </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">$var(count) = $(hdr(Call-Info){csv.count}) ## if the number is 3 then loop will be for 3 times starting from 0 to 2 </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> $var(i) = 0;<br>
while($var(i) < $var(count) )<br>
{<br>
xlog("counter: $var(i)\n");<br>
$var(i) = $var(i) + 1;<br>
}</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">This was my initial thought . But while finding the count it gave me an error . <b> $var(count) = $(hdr(Call-Info){csv.count}) Is this not in the correct format ? </b></span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt">parse error in /usr/local/etc/opensips/opensips-p2p.cfg:267:26-55: unknown script variable</span></b><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt">As I have earlier mentioned my header will look like . </span></b><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt">Call-Info: sales,en,level20,en (this can be anything but format will be like this . ) . How do I count the number of values ?</span></b><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt">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 </span></b><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:11pt"><br clear="all">
</span></b><u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><b><i><span style="font-size:11pt">Thanks & Regards</span></i></b><u></u><u></u></p>
<div>
<p class="MsoNormal"><i><span style="font-size:11pt">Sasmita Panda</span></i><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><i><span style="font-size:11pt">Senior Network Testing and Software Engineer</span></i><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><i><span style="font-size:11pt">3CLogic , ph:07827611765</span></i><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">On Thu, Oct 26, 2023 at 7:19 PM Ben Newlin <</span><a href="mailto:Ben.Newlin@genesys.com" target="_blank"><span style="font-size:11pt">Ben.Newlin@genesys.com</span></a><span style="font-size:11pt">> wrote:</span><u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Sasmita,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">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:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">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.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">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.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">The best options for looping on the header are probably s.select [1] or the csv tranformations [2].</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">[1] </span><a href="https://www.opensips.org/Documentation/Script-Tran-3-2#toc7" title="https://www.opensips.org/Documentation/Script-Tran-3-2#toc7" target="_blank"><span style="font-size:11pt">https://www.opensips.org/Documentation/Script-Tran-3-2#toc7</span></a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">[2] </span><a href="https://www.opensips.org/Documentation/Script-Tran-3-2#toc82" title="https://www.opensips.org/Documentation/Script-Tran-3-2#toc82" target="_blank"><span style="font-size:11pt">https://www.opensips.org/Documentation/Script-Tran-3-2#toc82</span></a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;color:black">Ben Newlin</span><u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></blockquote></div>