Module: kamailio
Branch: master
Commit: 03117d74262388e38cf06ccf6d38ffdf51da6732
URL: 
https://github.com/kamailio/kamailio/commit/03117d74262388e38cf06ccf6d38ffdf51da6732

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-20T14:41:19+01:00

core: split sip_msg_apply_changes() to have a function without route type checks

- copy over msg->add_to_branch_s field on applying changes

---

Modified: src/core/msg_translator.c
Modified: src/core/msg_translator.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/03117d74262388e38cf06ccf6d38ffdf51da6732.diff
Patch: 
https://github.com/kamailio/kamailio/commit/03117d74262388e38cf06ccf6d38ffdf51da6732.patch

---

diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index 8671e6753d4..be8f8ee8bb5 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -3655,6 +3655,9 @@ int sip_msg_update_buffer(sip_msg_t *msg, str *obuf)
        msg->dst_uri = tmp.dst_uri;
        msg->path_vec = tmp.path_vec;
 
+       memcpy(msg->add_to_branch_s, tmp.add_to_branch_s, MAX_BRANCH_PARAM_LEN);
+       msg->add_to_branch_len = tmp.add_to_branch_len;
+
        memcpy(msg->buf, obuf->s, obuf->len);
        msg->len = obuf->len;
        msg->buf[msg->len] = '\0';
@@ -3708,17 +3711,12 @@ int sip_msg_eval_changes(sip_msg_t *msg, str *obuf)
 /**
  *
  */
-int sip_msg_apply_changes(sip_msg_t *msg)
+int sip_msg_apply_changes_now(sip_msg_t *msg)
 {
        int ret;
        dest_info_t dst;
        str obuf;
 
-       if(msg->first_line.type != SIP_REPLY && get_route_type() != 
REQUEST_ROUTE) {
-               LM_ERR("invalid usage - not in request route or a reply\n");
-               return -1;
-       }
-
        init_dest_info(&dst);
        dst.proto = PROTO_UDP;
        if(msg->first_line.type == SIP_REPLY) {
@@ -3744,3 +3742,15 @@ int sip_msg_apply_changes(sip_msg_t *msg)
 
        return ret;
 }
+
+/**
+ *
+ */
+int sip_msg_apply_changes(sip_msg_t *msg)
+{
+       if(msg->first_line.type != SIP_REPLY && get_route_type() != 
REQUEST_ROUTE) {
+               LM_ERR("invalid usage - not in request route or a reply\n");
+               return -1;
+       }
+       return sip_msg_apply_changes_now(msg);
+}
diff --git a/src/core/msg_translator.h b/src/core/msg_translator.h
index d44caed8a1f..4b1ef6b928f 100644
--- a/src/core/msg_translator.h
+++ b/src/core/msg_translator.h
@@ -203,4 +203,6 @@ int sip_msg_eval_changes(sip_msg_t *msg, str *obuf);
  */
 int sip_msg_apply_changes(sip_msg_t *msg);
 
+int sip_msg_apply_changes_now(sip_msg_t *msg);
+
 #endif

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to