<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Makes sense. I thought I was missing something. Hash table will work well.<div class=""> Thanks Daniel.</div><div class=""><br class="">
<br class=""><div><blockquote type="cite" class=""><div class="">On 14 Sep 2016, at 15:36, Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com" class="">miconda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><p class="">Hello,</p><p class="">there is no variable that is stored in the scope of the branch.
What you can use is a hash table and compose the key from callid
and branch index variables with expires that is same as
transaction lifetime (max retransmission timeout).</p><p class="">And indeed you need to 'touch' the r-uri in order to signal to
kamailio that you have a new destination and want to create a new
branch. It may work to just use append_branch(), otherwise
reassigning $ru to itself should do it.</p><p class="">Cheers,<br class="">
Daniel<br class="">
</p>
<br class="">
<div class="moz-cite-prefix">On 14/09/16 16:11, Paul Smith wrote:<br class="">
</div>
<blockquote cite="mid:AEBCADAF-380F-48DA-A266-EA8DE9F6DD93@claritytele.com" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<div class="">Hi,</div>
<div class="">I am struggling to figure out variable scope in
branches and branch_failure_routes. Is there a way to store a
variable in a branch route so that I can then read it from the
branch failure route if that branch fails? Also does writing
$ru in branch_failure_route append a branch?</div>
<div class=""><br class="">
</div>
<div class="">For example I have multiple SIP devices registered
to Kamailio on the same account credentials. The devices are
behind same NAT, so same public IP. Some devices have SRTP
required and some cannot use SRTP at all, Kamailio does not know
in advance of the call whether the call will use SRTP or RTP.</div>
<div class=""><br class="">
</div>
<div class="">When I send a call to that user Kamailio correctly
parallel forks to all the registered devices. I use rtpengine
offer to send SDP with RTP/SAVP in the initial invites.</div>
<div class=""><br class="">
</div>
<div class="">If one of the devices sends a 488 due to not being
able to handle the RTP/SAVP I then want to run rtpengine_offer
with RTP/AVP and send another invite to the same device. </div>
<div class=""><br class="">
</div>
<div class="">In the branch failure route I seem to have to read
the current $ru and then write it back into $ru before calling
t_relay() or I get </div>
<div class="">
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209, 209,
209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">Sep 14 14:56:06
registrar-secure /usr/sbin/kamailio[10168]: ERROR: tm
[t_fwd.c:1771]: t_forward_nonack(): ERROR: t_forward_nonack:
no branches for forwarding</span></div>
</div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""><br class="">
</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">This code seems to work, but it
feels like I’m doing something very wrong…. in particular
$avp(triedrtpout) is set for the transaction, I should be
setting it separately for each branch. </span></div>
<blockquote style="margin: 0 0 0 40px; border: none; padding:
0px;" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">event_route[tm:branch-failure:SRTP]
{ # Handle failure response</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> xlog("L_INFO",
"Handling $T_reply_code response to $rm to ru: <$ru>
and du: $du\n");</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209); min-height: 17px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class="">
</div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
if(t_check_status("488") && is_method("INVITE")) {</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> if
($avp(triedsrtpout)==1) {</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> #
set $ru seems to create a new branch ... even when we set
it to its current value.</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> # we
want to generate a new SIP INVITE to the same AOR but with
different SDP</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
$avp(buffer)=$ru;</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
$ru=$avp(buffer);</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
xlog("L_INFO","488 caught. Resending to $ru");</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> #
try with unencrypted RTP/AVP</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
rtpengine_delete();</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
rtpengine_offer("to-tag trust-address replace-origin
replace-session-connection ICE=force RTP/AVP");</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> if
(!t_relay()) {</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
sl_reply_error();</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><br class="">
</div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-size: 13px; line-height: normal;
font-family: 'Espresso Mono'; background-color: rgb(209,
209, 209);" class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">}</span></div>
</span></blockquote>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I am using kamailio 4.2 debian package for this
registrar.</div>
<div class=""><br class="">
</div>
<div class="">Sorry for the rambling question … I don’t understand
enough to write the short version!</div>
<div class=""><br class="">
</div>
<div class="">Paul</div>
<br class="">
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre wrap="" class="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br class="">
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://www.asipto.com/">http://www.asipto.com</a> - <a class="moz-txt-link-freetext" href="http://www.kamailio.org/">http://www.kamailio.org</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
</div>
_______________________________________________<br class="">SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br class=""><a href="mailto:sr-users@lists.sip-router.org" class="">sr-users@lists.sip-router.org</a><br class="">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users<br class=""></div></blockquote></div><br class=""></div></body></html>