[SR-Users] Strange behavior with $T_branch_idx in failure_route

Daniel-Constantin Mierla miconda at gmail.com
Thu Mar 25 13:06:13 CET 2021


Hello,

indeed, the docs for it were outdated, the code evolved and the docs
were not updated. I tried to bring them correlated with the code, hope I
haven't missed anything in the code:

  *
https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#t_branch_idx

Cheers,
Daniel

On 24.03.21 17:35, Victor Litvinov wrote:
> Hello.
>
> We faced an issue that $T_branch_idx called from failure_route
> returned a strange result.
>
> Few words about our setup. 
> We use branch indexes like key in avp when we store via-branch value
> for rtpengine.
>
> route[RTPMANAGE]
> ...
> if ( is_request() and is_method("INVITE") and !has_totag() and
> t_is_branch_route() )
> {
> $avp(viabranch$T_branch_idx) = $branch_str;
> }
> $avp(extra_branch_id) = $avp(viabranch$T_branch_idx);
> $var(rtpkey) = $var(rtpkey) + " via-branch=extra";
> ......
> rtpengine_manage($var(rtpkey));
>
> Call this route in branch_route and in failure_route. 
> In branch_route T_branch_idx is 0, in failure_route is 1. 
>
> In documentation:
> the index (starting with 1 for the first branch) of the branch for
> which is executed the branch_route[]. If used outside of
> branch_route[] block, the value is '0'.
>
> But in source code behavior is different. (modules/tmx/t_var.c:480):
> for BRANCH_FAILURE_ROUTE and BRANCH_ROUTE it is idx =
> tcx->branch_index, but for FAILURE_ROUTE it is idx =
> t->nr_of_outgoings + nr_branches; 
>
> Can you describe why for failure_route it is different and what we can
> do in our case? And can you update documentation for this variable if
> it is wrong?
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210325/0cbcfd05/attachment.htm>


More information about the sr-users mailing list