[sr-dev] git:master: modules/tm: Added event_route[tm:local-response]

Peter Dunkley peter.dunkley at crocodile-rcs.com
Tue Mar 6 19:36:26 CET 2012


Module: sip-router
Branch: master
Commit: 74a13d86340de56602f31c6a8bf9536ee0123911
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=74a13d86340de56602f31c6a8bf9536ee0123911

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Tue Mar  6 18:13:56 2012 +0000

modules/tm: Added event_route[tm:local-response]

- Event route that is run (immediately after) sending a locally
  generated, transaction stateful, response.
- Because the response has already been sent there is no point
  trying to change anything in this event_route.

---

 modules/tm/t_reply.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index e8a8d6a..0e8de0b 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -152,6 +152,8 @@
 #include "t_fwd.h"
 #include "../../fix_lumps.h"
 #include "../../sr_compat.h"
+#include "../../receive.h"
+#include "../../onsend.h"
 #include "t_stats.h"
 #include "uac.h"
 
@@ -565,6 +567,9 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 	unsigned int buf_len;
 	struct cancel_info cancel_data;
 	struct tmcb_params onsend_params;
+	int rt, backup_rt;
+	struct run_act_ctx ctx;
+	struct sip_msg pmsg;
 
 	init_cancel_info(&cancel_data);
 	if (!buf)
@@ -668,6 +673,31 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 				run_trans_callbacks_off_params(TMCB_RESPONSE_SENT, trans,
 				                               &onsend_params);
 			}
+
+			rt = route_lookup(&event_rt, "tm:local-response");
+			if (unlikely(rt >= 0 && event_rt.rlist[rt] != NULL))
+			{
+				if (likely(build_sip_msg_from_buf(&pmsg, buf, len, inc_msg_no()) == 0))
+				{
+					struct onsend_info onsnd_info;
+
+					onsnd_info.to=&(trans->uas.response.dst.to);
+					onsnd_info.send_sock=trans->uas.response.dst.send_sock;
+					onsnd_info.buf=buf;
+					onsnd_info.len=len;
+					p_onsend=&onsnd_info;
+
+					backup_rt = get_route_type();
+					set_route_type(LOCAL_ROUTE);
+					init_run_actions_ctx(&ctx);
+					run_top_route(event_rt.rlist[rt], &pmsg, 0);
+					set_route_type(backup_rt);
+					p_onsend=0;
+
+					free_sip_msg(&pmsg);
+				}
+			}
+
 		}
 		DBG("DEBUG: reply sent out. buf=%p: %.20s..., shmem=%p: %.20s\n",
 			buf, buf, rb->buffer, rb->buffer );




More information about the sr-dev mailing list