<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=""><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=""></body></html>