Module: kamailio
Branch: master
Commit: 35c7f25713c822bacf4390b5c752539d776afd6c
URL: 
https://github.com/kamailio/kamailio/commit/35c7f25713c822bacf4390b5c752539d776afd6c

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-08T20:41:42+01:00

tm: added t_msg_apply_changes() function

---

Modified: src/modules/tm/tm.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/35c7f25713c822bacf4390b5c752539d776afd6c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/35c7f25713c822bacf4390b5c752539d776afd6c.patch

---

diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 8e875eb54f0..bfa03010783 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -217,6 +217,7 @@ static int w_t_get_status_code(sip_msg_t *msg, char *p1, 
char *p2);
 static int t_clean(struct sip_msg *msg, char *key, char *value);
 static int w_t_exists(struct sip_msg *msg, char *p1, char *p2);
 static int w_t_cell_append_branches(sip_msg_t *msg, char *pindex, char 
*plabel);
+static int w_t_msg_apply_changes(sip_msg_t *msg, char *p1, char *p2);
 
 /* by default the fr timers avps are not set, so that the avps won't be
  * searched for nothing each time a new transaction is created */
@@ -459,6 +460,7 @@ static cmd_export_t cmds[] = {
        {"t_next_contact_flow", t_next_contact_flow, 0, 0, 0, REQUEST_ROUTE},
        {"t_clean", t_clean, 0, 0, 0, ANY_ROUTE},
        {"t_exists", w_t_exists, 0, 0, 0, ANY_ROUTE},
+       {"t_msg_apply_changes", w_t_msg_apply_changes, 0, 0, 0, ANY_ROUTE},
        {"t_cell_append_branches", w_t_cell_append_branches, 2, fixup_igp_igp,
                        fixup_free_igp_igp, ANY_ROUTE},
 
@@ -3399,6 +3401,32 @@ static int w_t_cell_append_branches(sip_msg_t *msg, char 
*pindex, char *plabel)
        return (ret == 0) ? 1 : ret;
 }
 
+static int w_t_msg_apply_changes(sip_msg_t *msg, char *p1, char *p2)
+{
+       tm_cell_t *t;
+
+       if(t_check(msg, 0) == -1)
+               return 1;
+       t = get_t();
+       if(!t || !t->uas.request) {
+               return -1;
+       }
+       if(ksr_msg_apply_changes_mode == 1) {
+               if(sip_msg_apply_changes(msg) < 0) {
+                       return E_BAD_REQ;
+               }
+               if(parse_headers(msg, HDR_EOH_F, 0)) {
+                       LM_ERR("parse_headers failed\n");
+                       return E_BAD_REQ;
+               }
+               if((msg->parsed_flag & HDR_EOH_F) != HDR_EOH_F) {
+                       LM_ERR("EoH not parsed\n");
+                       return E_UNEXPECTED_STATE;
+               }
+       }
+       return 1;
+}
+
 #ifdef USE_DNS_FAILOVER
 /* parse reply codes for failover given in module parameter */
 static int t_failover_parse_reply_codes()

_______________________________________________
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