[sr-dev] Why sip_msg_apply_changes can't be executed from BRANCH_FAILURE_ROUTE?

Henning Westerholt hw at skalatan.de
Mon Jul 19 16:13:26 CEST 2021


does you actually tried it without msg_apply_changes? This are the actual docs:

“Note: it may be required that msg_apply_changes() from textopsx module has to be executed if there are other operations over the new body.”

So I think if you do not need any further modifications on the new body, it should be fine.



Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com<https://gilawa.com/>

From: sr-dev <sr-dev-bounces at lists.kamailio.org> On Behalf Of Ivan Ribakov
Sent: Monday, July 19, 2021 4:09 PM
To: sr-dev at lists.kamailio.org
Subject: Re: [sr-dev] Why sip_msg_apply_changes can't be executed from BRANCH_FAILURE_ROUTE?

Still looking for an answer to how make body multipart for each of the forked INVITEs or a confirmation of the fact that this can not be done due to the complications around TX + msg_apply_changes().


On 14 Jul 2021, at 13:24, Ivan Ribakov <i.ribakov at zaleos.net<mailto:i.ribakov at zaleos.net>> wrote:

Does anyone have any idea about this?

On 7 Jul 2021, at 15:04, Ivan Ribakov <i.ribakov at zaleos.net<mailto:i.ribakov at zaleos.net>> wrote:

Hi Daniel,

According to textops module documentation, use of “set_body_multipart” requires the execution of “msg_apply_changes()” (tested) - https://kamailio.org/docs/modules/5.2.x/modules/textops.html#textops.f.set_body_multipart

Also tested patching Kamailio to allow execution of “msg_apply_changes()” from branch route but that caused a core dump so didn’t look further in that direction.

Can you recommend a way to add different body parts to egress INVITEs depending on the branch?


On 7 Jul 2021, at 08:10, Daniel-Constantin Mierla <miconda at gmail.com<mailto:miconda at gmail.com>> wrote:


you do not need to use explicitly msg_apply_changes(), the modifications
done to sip message are applied when it is sent out.

The restriction to use msg_apply_changes() after transaction is created
comes from the complexity of transaction structure and its states. There
can be retransmissions at various stages for outgoing branches, internal
callbacks executed, timer checks, ... referencing to the message that
created the transaction. msg_apply_changes() will change it, impacting

But again, you can add/remove headers, etc ... in branch routes and
changes will be applied when sending out.


On 06.07.21 15:34, Ivan Ribakov wrote:

Hi all,

I need to modify headers and body of the ingress INVITE in the BRANCH_FAILURE_ROUTE block to reflect failure to deliver message to the first destination and include some additional information. However checking the documentation of the “sip_msg_apply_changes” (https://github.com/kamailio/kamailio/blob/master/src/core/msg_translator.c#L3342-L3345) I can see that it can only be executed from request and reply routes. That seems overly restrictive. Can someone shine some light on why is that and whether it’s safe to patch this part of the code to allow function execution from  BRANCH_FAILURE_ROUTE as well?

Thanks in advance,
Kamailio (SER) - Development Mailing List
sr-dev at lists.kamailio.org<mailto:sr-dev at lists.kamailio.org>

Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com/>
www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20210719/24bdaf2a/attachment-0001.htm>

More information about the sr-dev mailing list