[Kamailio-Users] Rewrite $tU

Daniel-Constantin Mierla miconda at gmail.com
Fri Dec 11 09:03:07 CET 2009


Hello,

with the latest version there are alternatives you can use:

On 12/10/09 5:06 PM, David wrote:
> Hey,
>
> I won't pretend to be an expert in Kamailio, someone will probably 
> suggest a better way. But here is how I rewrote my SIP packet's TO 
> header before relaying it to the next hop :
>
> # Rewrite RURI
> avp_printf("$rU", "prefix_$rU");

$rU = "prefix_" + $rU;

>
> # Remove existing header
> remove_hf("To") ;
>
> # Add new header which is copied from RURI
> insert_hf("To: $ru\r\n", "From");

you can do in one step, so you avoid operations on r-uri:

insert_hf("To: sip:prefix_$rU@$rd\r\n", "From");

>
>
> DISCLAIMER : Several threads have said that changing the TO header is 
> a bad idea, so I only recommend using this as a last resort.

If devices are RFC3261 (SIP 2.0), then it is ok. If there are SIP 1.0 
devices, then you have to preserve To/From header.

For the future, I would add options to change the From/To values via 
pseudo-variables. It is the admin to decide to use it or not -- now 
people need and do workarounds with subst or append_hf().

Cheers,
Daniel

>
> David
>
>
>
>
>
> David a écrit :
>> Hey,
>>
>> I do understand that normally the TO header should not be written, my
>> problem is that I am using the presence_dialoginfo module which uses the
>> TO header and not the RURI, which means that in order to tell the
>> difference between customer A's extension 101 and Customer B's extension
>> 101, I rewrite the TO header to add context.
>>
>> This is actually the ame problem that I started discussing here :
>> http://lists.kamailio.org/pipermail/users/2009-August/024316.html
>>
>> Trouble is I have not had time to work on this since then.
>>
>> Thanks,
>>
>> David
>>
>> Olle E. Johansson a écrit :
>>> 10 dec 2009 kl. 15.04 skrev Iñaki Baz Castillo:
>>>
>>>
>>>> El Jueves, 10 de Diciembre de 2009, David escribió:
>>>>> Hey,
>>>>>
>>>>> I need to rewrite the $tU variable on a packet before it is 
>>>>> relayed. It
>>>>> is ok if the change is only on the relayed packet and the $tU 
>>>>> variable
>>>>> change. The important thing is that I modify the To header, it seems
>>>>> that rewritting $tU would be the easiest.
>>>> $tU is not writable, but just readable.
>>>> If you want to change the "To" header you should do some "dirty" 
>>>> replacing operation (see textops module).
>>>
>>> This is propably something we need to change and make the To and 
>>> From headers writable.
>>> It's not dirty to change them any more.
>>>
>>> David: In the original SIP 1.0 protocol the To/From headers was part 
>>> of the dialog identification, thus you where not allowed to change 
>>> them in a proxy. THis was kept in RFC3261 - sip v2 - but has been 
>>> removed in an additional RFC a short while ago (seen from SIP history).
>>>
>>> Regards,
>>> /O
>>> _______________________________________________
>>> Kamailio (OpenSER) - Users mailing list
>>> Users at lists.kamailio.org
>>> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>>> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>>
>>
>>
>> _______________________________________________
>> Kamailio (OpenSER) - Users mailing list
>> Users at lists.kamailio.org
>> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>
>
> _______________________________________________
> Kamailio (OpenSER) - Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>

-- 
Daniel-Constantin Mierla
* http://www.asipto.com/




More information about the Users mailing list