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?

Regards,
Ivan

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

Hello,

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
everything.

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

Cheers,
Daniel

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,
Ivan
_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda