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

Author: Xenofon Karamanos <x...@gilawa.com>
Committer: Henning Westerholt <h...@gilawa.com>
Date: 2025-08-08T11:17:34+02:00

tm: Trigger local-request event for ACK on negative replies

---

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

---

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

---

diff --git a/src/modules/tm/config.h b/src/modules/tm/config.h
index dd9c13c77f8..6a70829389f 100644
--- a/src/modules/tm/config.h
+++ b/src/modules/tm/config.h
@@ -88,8 +88,14 @@
 #define CANCEL_DONE "ok -- no more pending branches"
 #define CANCELED "Request canceled"
 
-/* execute event_route[tm:local-request] for hop-by-hop CANCEL */
-#define TM_EVLREQ_CANCEL_HBH 1
+/* execute event_route[tm:local-request] for hop-by-hop messages
+1 = execute for Cancel
+2 = execute for ACK
+3 = execute for both
+*/
+#define TM_EVLREQ_CANCEL_HBH (1 << 0)
+#define TM_EVLREQ_ACK_HBH (1 << 1)
+#define TM_EVLREQ_BOTH_HBH (TM_EVLREQ_CANCEL_HBH | TM_EVLREQ_ACK_HBH) // 3
 
 /* to-tag separator for stateful processing */
 #define TM_TAG_SEPARATOR '-'
diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 0299ea2dc7b..01138a63675 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -100,6 +100,7 @@ static int goto_on_reply = 0;
 /* where to go on receipt of reply without transaction context */
 int goto_on_sl_reply = 0;
 extern str on_sl_reply_name;
+extern int _tm_evlreq_mode;
 
 extern str _tm_event_callback_lres_sent;
 
@@ -2460,6 +2461,26 @@ int reply_received(struct sip_msg *p_msg)
                                                        
run_trans_callbacks_off_params(
                                                                        
TMCB_REQUEST_SENT, t, &onsend_params);
                                                }
+/* trigger tm:local-request event route for negative reply ACK --- */
+#ifdef WITH_EVENT_LOCAL_REQUEST
+                                               if(goto_on_local_req >= 0
+                                                               && 
(_tm_evlreq_mode & TM_EVLREQ_ACK_HBH)) {
+                                                       struct sip_msg ack_msg;
+                                                       memset(&ack_msg, 0, 
sizeof(struct sip_msg));
+                                                       
if(build_sip_msg_from_buf(
+                                                                          
&ack_msg, ack, ack_len, inc_msg_no())
+                                                                       == 0) {
+                                                               
run_top_route(event_rt.rlist[goto_on_local_req],
+                                                                               
&ack_msg, 0);
+                                                               
free_sip_msg(&ack_msg);
+                                                       } else {
+                                                               LM_ERR("failed 
to build sip msg structure for "
+                                                                          
"negative reply ACK event route\n");
+                                                       }
+                                               }
+#endif /* WITH_EVENT_LOCAL_REQUEST */
+
+                                               /* trigger tm:local-request 
event route for negative reply ACK --- */
                                        }
                                        shm_free(ack);
                                }
@@ -2773,7 +2794,7 @@ int reply_received(struct sip_msg *p_msg)
 #endif
                restart_rb_fr(&uac->request, t->fr_inv_timeout);
                uac->request.flags |= F_RB_FR_INV; /* mark fr_inv */
-       }                                                                       
   /* provisional replies */
+       } /* provisional replies */
 
 done:
        if(unlikely(replies_locked)) {

_______________________________________________
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