[OpenSIPS-Users] replace_all not working on CANCEL messages

Bogdan-Andrei Iancu bogdan at opensips.org
Mon Feb 18 16:40:51 CET 2013


Hi Stian,

You can "see" the original TO and FROM uris via $tu and $fu (each can be 
broken into $fU (username) and $fd (domain) ). Based on these RO 
variables, you can build the new values, like:

uac_replace_from("","sip:$fU@$fd");

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com


On 02/18/2013 02:07 PM, Stian Øvrevåge wrote:
> Thank you.
>
> Using subst_uri I have got rid of the field in the URI.
>
> I'm not sure how to apply the UAC functions.
>
> It is my understanding that they replace the whole To/From fields and
> do not return values. The search and replace functions I know of are
> in textops and works on the messages. So how do I save the original
> To/From, search and replace a part of them, save the result into a new
> variable? (And then feed this variable to uac_replace_x).
>
> Brgds,
> Stian Øvrevåge
>
>
> On Sun, Feb 17, 2013 at 9:54 AM, Bogdan-Andrei Iancu
> <bogdan at opensips.org>  wrote:
>> Hi Stian,
>>
>> The CANCEL is a hop by hop request, which means it is not forwarded by a SIP
>> proxy, but rather re-generated each time (based on the INVITE is cancels).
>>
>> So, you cannot change the CANCEL in script, as built based on the INVITE.
>>
>> Now, the changes you do over the INVITE are not SIP-wise - you cannot simply
>> change the FROM / TO with text ops, as such changes will not be persistent
>> during the entire SIP dialog (and as first result, the CANCEL does not
>> contain the changes you do over the INVITE).
>>
>> RURI can be changed via textops (see subst_uri() or subst_user() from
>> textops - http://www.opensips.org/html/docs/modules/1.9.x/textops.html).
>>
>> For the FROM and TO hdr, use uac_replace_[to|from]() functions from the uac
>> module - http://www.opensips.org/html/docs/modules/1.9.x/uac.html#id250475 /
>>
>> Do the changes only over the initial INVITE ! CANCEL and rest will be
>> automatically changed, no need for script handling for this.
>>
>> Best regards,
>>
>> Bogdan-Andrei Iancu
>> OpenSIPS Founder and Developer
>> http://www.opensips-solutions.com
>>
>>
>>
>> On 02/16/2013 04:24 PM, Stian Øvrevåge wrote:
>>> Hi list,
>>>
>>> Our upstream SIP provider recently started sending a new field that
>>> makes our UAs ignore most SIP packets. To mediate this I added a
>>> replace_all to remove this field:
>>>
>>> replace_all(";phone-context=national", "");
>>>
>>> I have moved this to the top of my main route{} block to be as wide as
>>> possible while troubleshooting.
>>>
>>> It works great for INVITEs:
>>>
>>> Incomming request from upstream:
>>> Request-URI: sip:UserB;phone-context=national at knett.no;user=phone
>>> From:<sip:UserA;phone-context=national at knett.no;user=phone>;tag=8322
>>> To:<sip:UserB;phone-context=national at knett.no;user=phone>
>>>
>>> Message routed to UA:
>>> Request-URI: sip:UserB at u.a.i.p:5060
>>> From:<sip:UserA at knett.no;user=phone>;tag=8322
>>> To:<sip:UserB at knett.no;user=phone>
>>>
>>> And all is good.
>>>
>>> However, if a CANCEL message is either relayed from upstream or
>>> generated in OpenSIPS, the fields are still present, causing the UA to
>>> not recognize the dialog and continue ringing.
>>>
>>> Request-URI: sip:UserB;phone-context=national at knett.no;user=phone
>>> From:<sip:UserA;phone-context=national at knett.no;user=phone>;tag=8322
>>> To:<sip:UserB;phone-context=national at knett.no;user=phone>
>>>
>>> Request-URI: sip:UserB at u.a.i.p:5060
>>> From:<sip:UserA;phone-context=national at knett.no;user=phone>;tag=8322
>>> To:<sip:UserB;phone-context=national at knett.no;user=phone>
>>>
>>> I have also added the replace_all to onreply_route[2]{} and
>>> failure_route[1]{}.
>>>
>>> In my main block I have a section for CANCEL processing, I started by
>>> adding the replacement there and writing to the log $hdr(From) etc.
>>> But no matter what I did it logged the original values.
>>>
>>> How do I fix my CANCEL messages?
>>>
>>> And what would be the correct way to log the value of some fields in
>>> an outgoing packet after modification?
>>>
>>> Using opensips 1.8.0-notls (x86_64/linux).
>>>
>>> Brgds,
>>> Stian Øvrevåge
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>



More information about the Users mailing list