浏览代码

sl: execute core event SREV_SIP_REPLY_OUT

Daniel-Constantin Mierla 5 年之前
父节点
当前提交
700261dff4
共有 1 个文件被更改,包括 17 次插入4 次删除
  1. 17 4
      src/modules/sl/sl_funcs.c

+ 17 - 4
src/modules/sl/sl_funcs.c

@@ -214,7 +214,8 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
 	mhomed=backup_mhomed;
 
 	keng = sr_kemi_eng_get();
-	if (_sl_evrt_local_response >= 0 || keng!=NULL)
+	if (_sl_evrt_local_response >= 0 || keng!=NULL
+			|| sr_event_enabled(SREV_SIP_REPLY_OUT))
 	{
 		if (likely(build_sip_msg_from_buf(&pmsg, buf.s, buf.len,
 				inc_msg_no()) == 0))
@@ -226,10 +227,8 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
 			onsnd_info.send_sock=dst.send_sock;
 			onsnd_info.buf=buf.s;
 			onsnd_info.len=buf.len;
-			p_onsend=&onsnd_info;
 
-			if (unlikely(!IS_SIP(msg)))
-			{
+			if (unlikely(!IS_SIP(msg))) {
 				/* This is an HTTP reply...  So fudge in a CSeq into
 				 * the parsed message message structure so that $rm will
 				 * work in the route */
@@ -293,6 +292,20 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
 				}
 			}
 
+			if(IS_SIP(msg) && sr_event_enabled(SREV_SIP_REPLY_OUT)) {
+				sr_event_param_t evp;
+				memset(&evp, 0, sizeof(sr_event_param_t));
+				evp.obuf = buf;
+				evp.rcv = &msg->rcv;
+				evp.dst = &dst;
+				evp.req = msg;
+				evp.rpl = &pmsg;
+				evp.rplcode = code;
+				evp.mode = 1;
+				sr_event_exec(SREV_SIP_REPLY_OUT, &evp);
+			}
+
+			p_onsend=&onsnd_info;
 			backup_rt = get_route_type();
 			set_route_type(LOCAL_ROUTE);
 			init_run_actions_ctx(&ctx);