[SR-Users] Changing $fU or $fn in branch_route

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 17 23:08:10 CEST 2019


Hello,

changing content in SIP headers is practically done as two operations:

  - delete old value
  - insert the new value where the old value started

By doing two changes to the same content (without an intermediate msg
apply changes), practically you insert two new values where the old
value started. The result being that the two new values appear one after
the other.

Cheers,
Daniel

On 17.10.19 22:11, Jurijs Ivolga wrote:
> Hi Daniel,
>
> I got that changes are not applied immediately. When I check SIP
> packet itself what was sent out I see that from header has user part
> equal to "1234567+123456". I think this might be a bug...
>
> Thank you!
>
> On Thu, 17. Oct 2019 at 22:22, Daniel-Constantin Mierla
> <miconda at gmail.com <mailto:miconda at gmail.com>> wrote:
>
>     Hello,
>
>     assigning to $fn, $fu or $fU is offered as a convenience way to
>     update parts of From header, but the changes are not applied
>     immediately, like the other operations done over the SIP headers
>     -- see more details in the FAQ:
>
>       -
>     https://www.kamailio.org/wiki/tutorials/faq/main#why_changes_made_to_headers_or
>
>     In your case, try to do those changes only in branch_route.
>
>     Cheers,
>     Daniel
>
>     On 17.10.19 20:59, Jurijs Ivolga wrote:
>>     Hi,
>>
>>     Just to add one more point that $fU & $fn I'm checking not in
>>     script but in SIP packet. So using sngrep i see in SIP packet
>>     from header where $fU and $fn are "1234567+123456".
>>
>>     Jurijs
>>
>>
>>     On Thu, Oct 17, 2019 at 1:06 PM Jurijs Ivolga
>>     <jurijs.ivolga at gmail.com <mailto:jurijs.ivolga at gmail.com>> wrote:
>>
>>         Hi!
>>
>>         I have small problem. When I assign $fU or $fn in
>>         request-route and then one more time I make new assignment in
>>         branch_route.  Instead of rewriting it is just concatenate
>>         needed value at the end. lets assume $avp(cli)=1234567 and
>>         $avp(cliplus)=+1234567. So if in request_route I
>>         do $fU=$avp(cli); and then in
>>         branch_route $fU=$avp(cliplus);. $fU becomes one string:
>>         "1234567+1234567". Is it a bug or I missing something?
>>
>>         Here is config snippet:
>>
>>         request_route {
>>         ...
>>         route(MY);
>>         ...
>>         }
>>
>>         route[MY] {
>>
>>         ...
>>                 $avp(cli) = "1234567"
>>                 $avp(cliplus) = "+"+$avp(cli);
>>                 $fU=$avp(cli); # here $fU=1234567
>>                 $fn=$avp(cli); # here $fn=1234567
>>                 route(LCR_ROUTE);
>>                 exit;
>>         }
>>
>>         route[LCR_ROUTE]
>>         {
>>                 if(!is_method("INVITE"))
>>                         return;
>>                 if (!load_gws("1",$rU,$avp(cli))) {
>>                         send_reply("503", "Error loading gateways");
>>                         exit;
>>                 }
>>
>>                 $var(i)=0;
>>                 while($(avp(lcr_gw_uri)[$var(i)])!= $null){
>>                         xlog("L_INFO", "loaded
>>         gw_uri_avp[$var(i)]=$(avp(lcr_gw_uri)[$var(i)]) \n");
>>                         $var(i) = $var(i)+1;
>>                 }
>>
>>                 if (!next_gw()) {
>>                         send_reply("503", "No available gateways");
>>                         exit;
>>                 }
>>
>>                 xlog("L_INFO", "request-uri $ru \n");
>>                 xlog("L_INFO", "$avp(lcr_gw_uri), $avp(lcr_id)\n");
>>
>>                 xlog("L_INFO", "flag $avp(lcr_flag) \n");
>>
>>                 t_set_fr(0, 4000);
>>                 t_on_failure("RTF_LCR_ROUTE");
>>                 t_on_branch("BRANCH_CUST");
>>                 route(RELAY);
>>                 exit;
>>         }
>>
>>         branch_route[BRANCH_CUST] {
>>                 if ( $avp(lcr_flag) == 4) {
>>                         $fU=$avp(cliplus); #here $fU=1234567+1234567
>>                         $fn=$avp(cliplus); #here $fn=1234567+1234567
>>                 }
>>         }
>>
>>         Jurijs
>>
>>
>>     _______________________________________________
>>     Kamailio (SER) - Users Mailing List
>>     sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>     -- 
>     Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com>
>     www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
>     Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat
>
> -- 
> Jurijs

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20191017/0ee1a909/attachment.html>


More information about the sr-users mailing list