[SR-Users] Branch variables in branch_failure_route

Paul Smith paul.smith at claritytele.com
Wed Sep 14 19:53:45 CEST 2016

Makes sense.   I thought I was missing something.  Hash table will work well.
 Thanks Daniel.

> On 14 Sep 2016, at 15:36, Daniel-Constantin Mierla <miconda at gmail.com> wrote:
> Hello,
> 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).
> 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.
> Cheers,
> Daniel
> On 14/09/16 16:11, Paul Smith wrote:
>> Hi,
>> 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?
>> 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.
>> 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.
>> 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.  
>> 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 
>> 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
>> 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.  
>> event_route[tm:branch-failure:SRTP] { # Handle failure response
>>         xlog("L_INFO", "Handling $T_reply_code response to $rm to ru: <$ru> and du: $du\n");
>>         if(t_check_status("488") && is_method("INVITE")) {
>>                 if ($avp(triedsrtpout)==1) {
>>                         # set $ru seems to create a new branch ... even when we set it to its current value.
>>                         # we want to generate a new SIP INVITE to the same AOR but with different SDP
>>                         $avp(buffer)=$ru;
>>                         $ru=$avp(buffer);
>>                         xlog("L_INFO","488 caught. Resending to $ru");
>>                         # try with unencrypted RTP/AVP
>>                         rtpengine_delete();
>>                         rtpengine_offer("to-tag trust-address replace-origin replace-session-connection ICE=force RTP/AVP");
>>                         if (!t_relay()) {
>>                                 sl_reply_error();
>>                         }
>>                 }
>>         }
>> }
>> I am using kamailio 4.2 debian package for this registrar.
>> Sorry for the rambling question … I don’t understand enough to write the short version!
>> Paul
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org <mailto:sr-users at lists.sip-router.org>
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users <http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users>
> -- 
> Daniel-Constantin Mierla
> http://www.asipto.com <http://www.asipto.com/> - http://www.kamailio.org <http://www.kamailio.org/>
> http://twitter.com/#!/miconda <http://twitter.com/#!/miconda> - http://www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>_______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160914/8c59f8a3/attachment.html>

More information about the sr-users mailing list