[sr-dev] git:master:2690a8c3: tm: execute the onsend_route for responses forwarded by tm module

Daniel-Constantin Mierla miconda at gmail.com
Mon Sep 7 16:36:24 CEST 2015


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

Author: Lucian Balaceanu <lucian.balaceanu at 1and1.ro>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-09-07T16:31:11+02:00

tm: execute the onsend_route for responses forwarded by tm module

- not executed for local generated sip responses

---

Modified: modules/tm/t_reply.c

---

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

---

diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 8da3205..213e8a6 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -1729,6 +1729,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	str* to_tag;
 	str reason;
 	struct tmcb_params onsend_params;
+	struct ip_addr ip;
 
 	/* keep compiler warnings about use of uninit vars silent */
 	res_len=0;
@@ -1737,7 +1738,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	relayed_code=0;
 	totag_retr=0;
 
-
 	/* remember, what was sent upstream to know whether we are
 	 * forwarding a first final reply or not */
 
@@ -1921,23 +1921,34 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		if (reply_status == RPS_COMPLETED) {
 			start_final_repl_retr(t);
 		}
-		if (likely(uas_rb->dst.send_sock &&
-					SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0)){
-			if (unlikely(!totag_retr && has_tran_tmcbs(t, TMCB_RESPONSE_OUT))){
-				LOCK_REPLIES( t );
-				run_trans_callbacks_with_buf( TMCB_RESPONSE_OUT, uas_rb, t->uas.request,
-				                              relayed_msg, relayed_code);
-				UNLOCK_REPLIES( t );
+		if (likely(uas_rb->dst.send_sock)) {
+
+			if (onsend_route_enabled(SIP_REPLY) && p_msg && (p_msg != FAKED_REPLY)) {
+				if (run_onsend(p_msg, &uas_rb->dst, buf, res_len)==0){
+					su2ip_addr(&ip, &(uas_rb->dst.to));
+					LOG(L_ERR, "forward_reply: reply to %s:%d(%d) dropped"
+							" (onsend_route)\n", ip_addr2a(&ip),
+								su_getport(&(uas_rb->dst.to)), uas_rb->dst.proto);
+				}
 			}
-			if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT))){
-				INIT_TMCB_ONSEND_PARAMS(onsend_params, t->uas.request,
-									relayed_msg, uas_rb, &uas_rb->dst, buf,
-									res_len,
-									(relayed_msg==FAKED_REPLY)?TMCB_LOCAL_F:0,
-									uas_rb->branch, relayed_code);
-				LOCK_REPLIES( t );
-				run_trans_callbacks_off_params(TMCB_RESPONSE_SENT, t, &onsend_params);
-				UNLOCK_REPLIES( t );
+
+			if (SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0){
+				if (unlikely(!totag_retr && has_tran_tmcbs(t, TMCB_RESPONSE_OUT))){
+					LOCK_REPLIES( t );
+					run_trans_callbacks_with_buf( TMCB_RESPONSE_OUT, uas_rb, t->uas.request,
+												  relayed_msg, relayed_code);
+					UNLOCK_REPLIES( t );
+				}
+				if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT))){
+					INIT_TMCB_ONSEND_PARAMS(onsend_params, t->uas.request,
+										relayed_msg, uas_rb, &uas_rb->dst, buf,
+										res_len,
+										(relayed_msg==FAKED_REPLY)?TMCB_LOCAL_F:0,
+										uas_rb->branch, relayed_code);
+					LOCK_REPLIES( t );
+					run_trans_callbacks_off_params(TMCB_RESPONSE_SENT, t, &onsend_params);
+					UNLOCK_REPLIES( t );
+				}
 			}
 		} else if (unlikely(uas_rb->dst.send_sock == 0))
 			ERR("no resolved dst to send reply to\n");




More information about the sr-dev mailing list