[SR-Users] [sr-dev] recursive calls to failure_route strange behavior
Andres Moya
andres.moya.i at gmail.com
Sat Nov 21 02:56:01 CET 2009
Hi,
I made branch route and changing From there, i decided not to restore from.
ok, i doing calls two times and getting:
first time it set ok:
From: <sip:andres.moya4 at sipdiscount.com>;tag=572ac509.
second time i am getting
From:
<sip:andres.moya4 at sipdiscount.comsip:21100036838 at terrasip.net>;tag=572ac509.
ok
trying
subst('/^From:(.*)sip:[^@]*@[a-zA-Z0-9\.]+(.*)$/From:\1sip:$avp(i:21)@$avp(i:24)\2/i');
first time it substitute ok, on next branch i got result:
From:
<sip:andres.moya4 at sipdiscount.com;transport=UDP>;tag=ee12f132.sip:andres.moya4 at sipdiscount.com
Looks like both methods are broken.
ok, uac_replace is here:
LM_DBG("uri to replace [%.*s]\n",from->uri.len, from->uri.s);
LM_DBG("replacement uri is [%.*s]\n",from_uri->len, from_uri->s);
>>>Nov 21 01:22:35 v /usr/local/sbin/kamailio[32582]: DEBUG: uac
[from.c:305]: uri to replace [sip:mangust at riki.ru;transport=UDP]
>>>Nov 21 01:22:35 v /usr/local/sbin/kamailio[32582]: DEBUG: uac
[from.c:306]: replacement uri is [sip:andres.moya4 at sipdiscount.com]
sip:mangust at riki.ru is original from. It is same all sequence of calls.
This is actually second call, before sending authenticated INVITE.
Actually i am calling two times uac_replace_from, for first INVITE and
for second authenticated. If doing only on first invite is ok with first
authentiation, but crashes with results described in the beginning of a
mail on second one sip provider. In any case second replace always problem.
/* build del/add lumps */
if ((l=del_lump( msg, from->uri.s-msg->buf, from->uri.len, 0))==0)
{
LM_ERR("del lump failed\n");
goto error;
}
p = pkg_malloc( from_uri->len);
if (p==0)
{
LM_ERR("no more pkg mem\n");
goto error;
}
memcpy( p, from_uri->s, from_uri->len);
if (insert_new_lump_after( l, p, from_uri->len, 0)==0)
{
LM_ERR("insert new lump failed\n");
pkg_free(p);
goto error;
}
if (from_restore_mode==FROM_NO_RESTORE)
return 0;
Result is:
From:
<sip:andres.moya4 at sipdiscount.comsip:andres.moya4 at sipdiscount.com>;tag=1307d94b.
if repeat with next step, try to insert sip:21100036838 at terrasip.net, we
get:
From:
<sip:andres.moya4 at sipdiscount.comsip:21100036838 at terrasip.net>;tag=87272c59.
I am sure i am doing something wrong, but Kamailio doing strange things
too ...
Miklos Tirpak wrote:
> [please keep the list CC-d because others may also be interested in
> the solution or may know the answer better.]
>
> On 11/20/2009 07:06 PM, Andres Moya wrote:
>> Can i ask one more question here. It is complicated, i am using
>> uac_replace_from and uac_auth.
>> I am using failure route to process authentication if necessary and
>> redirect on next carrier.
>>
>> If i authenticated with one provider, then fot let say 415 ( i set
>> only speex in UAC to get it ;) ). Ok SER send request to second
>> provider, i use
>> uac_replace_from once again in my LOAD_AUTH route
>> then uac_auth again.
>>
>> Ok. now i see from ngrep that uac_replace_from did nothing in from
>> field and use user at domain for first provider, authentication failed :(
>
> Which authentication fails? The first or the second one?
> The first should work, at least the from header should be rewritten by
> the function.
>
> The second authentication will not work this way (if it requires a
> different from header) because the proxy "remembers" for the header
> changes done before the first t_relay() function call and applies the
> same header modifications also for any other branch added from failure
> route. Hence, the outgoing SIP request to the second provider will
> contain the same from HF as the request to the first provider.
>
> The easiest way is to apply the header modifications in branch route
> if you do not need to reuse them later from failure route.
> Modifications done in branch routes are valid only within that branch.
>
>>
>> I moved uac_replace_from to my failure route to call once again
>> before uac_auth, but got config error as i can't use uac_replace_from
>> in failure_route.
>
> I think you already use this function from failure route because it is
> in a route block that is included from failure route. The only
> difference is that the syntax checker does not recognize the issue. I
> am not familiar with uac_replace_from() but after having a quick look
> at the function I think it is safe to use it from here.
>
>> Ok i will use textops to rewrite, but it is ugly?
>
> The main difference is that uac_replace_from() restores the original
> From HF when the response if forwarded. If you use textops module then
> you need to restore the header manually.
>
>> no. Maybe i should call uac_replace_from in branch route?
>
> I would suggest this way. Both for the first and for the second provider.
>
> Miklos
>
>>
>> Thanks
More information about the sr-users
mailing list