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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-04-07T08:17:01+02:00

tm: added rpc command tm.retransmit_reply_callid

---

Modified: src/modules/tm/t_reply.c
Modified: src/modules/tm/t_reply.h
Modified: src/modules/tm/tm.c

---

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

---

diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 670260d93e8..7f3e70ae7cb 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -3123,6 +3123,50 @@ void rpc_reply_callid(rpc_t *rpc, void *c)
        }
 }
 
+/*
+ * Syntax:
+ *
+ * ":tm.retransmit_reply:[response file]\n
+ * callid
+ * cseq
+ * \n"
+ */
+void rpc_retransmit_reply_callid(rpc_t *rpc, void *c)
+{
+       int ret;
+       tm_cell_t *trans;
+       tm_cell_t *orig_t = NULL;
+       int orig_branch;
+       str callid = {0, 0};
+       str cseq = {0, 0};
+
+       if(rpc->scan(c, "S", &callid) < 1) {
+               rpc->fault(c, 400, "Call-ID expected");
+               return;
+       }
+
+       if(rpc->scan(c, "S", &cseq) < 1) {
+               rpc->fault(c, 400, "CSeq expected");
+               return;
+       }
+
+       tm_get_tb(&orig_t, &orig_branch);
+       if(t_lookup_callid(&trans, callid, cseq) < 0) {
+               rpc->fault(c, 404, "Transaction not found");
+               return;
+       }
+       /* it is refcounted now */
+       ret = t_retransmit_reply(trans);
+       UNREF(trans);
+       tm_set_tb(orig_t, orig_branch);
+
+       if(ret < 0) {
+               LM_ERR("Reply retransmission failed\n");
+               rpc->fault(c, 500, "Reply retransmission failed");
+               return;
+       }
+}
+
 /*
  * Syntax:
  *
diff --git a/src/modules/tm/t_reply.h b/src/modules/tm/t_reply.h
index 0fe1c09eb81..5e3d0451768 100644
--- a/src/modules/tm/t_reply.h
+++ b/src/modules/tm/t_reply.h
@@ -227,6 +227,7 @@ void t_drop_replies(int v);
 void rpc_reply(rpc_t *rpc, void *c);
 void rpc_reply_callid(rpc_t *rpc, void *c);
 void rpc_retransmit_reply(rpc_t *rpc, void *c);
+void rpc_retransmit_reply_callid(rpc_t *rpc, void *c);
 
 int faked_env(struct cell *t, struct sip_msg *msg, int is_async_env);
 struct sip_msg *fake_req(struct sip_msg *shmem_msg, int extra_flags,
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 0df18a8bd1b..b33c66f63fc 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -2869,6 +2869,11 @@ static const char *rpc_retransmit_reply_doc[2] = {
        0
 };
 
+static const char *rpc_retransmit_reply_callid_doc[2] = {
+       "Retransmit the transaction reply by call-id",
+       0
+};
+
 static const char *rpc_reply_callid_doc[2] = {
        "Reply transaction by call-id",
        0
@@ -2943,6 +2948,8 @@ static rpc_export_t tm_rpc[] = {
        {"tm.cancel", rpc_cancel, rpc_cancel_doc, 0},
        {"tm.reply", rpc_reply, rpc_reply_doc, 0},
        {"tm.retransmit_reply", rpc_retransmit_reply, rpc_retransmit_reply_doc, 
0},
+       {"tm.retransmit_reply_callid", rpc_retransmit_reply_callid,
+               rpc_retransmit_reply_callid_doc, 0},
        {"tm.reply_callid", rpc_reply_callid, rpc_reply_callid_doc, 0},
        {"tm.stats", tm_rpc_stats, tm_rpc_stats_doc, 0},
        {"tm.hash_stats", tm_rpc_hash_stats, tm_rpc_hash_stats_doc, 0},

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to