Kamailio Advanced Training
Click here for more details!

Learn how to build RTC services with Kamailio!

Thursday, September 10, 2009

SIP Router: Apply Changes to SIP Message in Config File

One of the most discussed architectural aspects of configuration file was the way changes done to received SIP messages are handled – even new headers are added, old are removed or different parts of message were updated, the changes were not immediately visibile.

The latest GIT repository includes a new config function – msg_apply_changes() – exported by module textops from modules_k folder. Once this function is used, all changes done up to that point are applied and further processing within config will see the new message content.

The new function can be used only in request route for now. Be carefully when using it, since it changes the expectation you had so far of always working on initially received SIP message. Once the function is used, initial content is lost forever. As it builds a new buffer and re-parses, it is not very recommended to use it extensively.

Example of usage:

append_hf(”My-Header: yes\r\n”);
if(msg_apply_changes())
{
# msg buffer has a new content
if(is_present_hf(”My-Header”))
{
# will get always here
}
}

Readme of the module:

http://sip-router.org/docbook/sip-router/branch/master/modules_k/textops/textops.html

The functionality will be part of upcoming Kamailio (OpenSER) 3.0 release.

No comments:

Post a Comment