[Kamailio-Users] append_hf

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 24 10:58:06 CET 2008


On 11/24/08 11:34, Iñaki Baz Castillo wrote:
> El Lunes, 24 de Noviembre de 2008, Daniel-Constantin Mierla escribió:
>   
>> Hello,
>>
>> On 11/24/08 04:01, Matteo D'Amato wrote:
>>     
>>> Hello,
>>> 	 I'm trying to append trunk group information to my Contact header
>>> so I'm, using append_hf as follows
>>>
>>>
>>>     append_hf("tgrp=30001 \r\n", "Contact");
>>>       
>> this appends a new header. For what you need try subst() or
>> search_append() functions.
>>
>> Alternative:
>>
>> remove_hf("Contact");
>>
>> append_hf("Contact: $hdr(contact);tgrp=30001\r\n", "Contact");
>>     
>
> Anyway I consider operations like this on SIP URI very dangerous
SIP is always dangerous :-) ...

>  due to 
> complex SIP URI syntax:
>
>
> a) Contact: sip:user at domain.org;param=AAA
> Here "param=AAA" is a *header* param since SIP URI uses addr_spec form (there 
> is no < > enclosing the SIP URI).
>   
right.
> b) Contact: <sip:user at domain.org>;param=AAA
> Here "param=AAA" is a *header* param since SIP URI uses name_addr form (there 
> are < >) and the param is out of the < >.
>   
right.
> c) Contact: <sip:user at domain.org;param=AAA>
> Here "param=AAA" is a *SIP URI* param since SIP URI uses name_addr form (there 
> are < >) and the param is INTO the < >.
>   
right.
> If Matteo want to adds a header param then the above solution will work, but 
> if he wants to add a SIP URI param then it won't work.
>   

subst() is a solution here. It is up to him to identify and use best 
option. I just gave some hints.

As you said, he can use transformations for more precise processing.
> Note that when creating an in-dialog request, the Request URI must be the 
> Contact previously received in the initial INVITE (or 200 OK), and the RURI 
> must include Contact *SIP URI* params (case c), but *NOT* the Contact header 
> params (cases a and b).
>
>
> There are URI Transformations to get URI params:
>   
> http://kamailio.org/dokuwiki/doku.php/transformations:devel#uri_transformations
> but they don't allow adding/modifying/deleting a param, just reading it.
>   
Indeed, still one can use them to build a new contact header as he 
wishes. There will be some config file scripting, but you get what you 
want at the end.

>
> PD: I consider SIP URI BNF grammar a pain.
>   
Is there a fan club? I seriously consider subscribing ;-) ...

Cheers,
Daniel

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





More information about the sr-users mailing list