瀏覽代碼

- added flags to tm onsend callbacks that should tell if the callbacks is
called due to a retransmission or for a local generated message

Andrei Pelinescu-Onciul 18 年之前
父節點
當前提交
ad99759256
共有 7 個文件被更改,包括 31 次插入18 次删除
  1. 1 1
      modules/tm/t_cancel.c
  2. 2 1
      modules/tm/t_fwd.c
  3. 5 4
      modules/tm/t_hooks.c
  4. 13 5
      modules/tm/t_hooks.h
  5. 8 5
      modules/tm/t_reply.c
  6. 1 1
      modules/tm/timer.c
  7. 1 1
      modules/tm/uac.c

+ 1 - 1
modules/tm/t_cancel.c

@@ -193,7 +193,7 @@ int cancel_branch( struct cell *t, int branch, int flags )
 	DBG("DEBUG: cancel_branch: sending cancel...\n");
 #ifdef TMCB_ONSEND
 	if (SEND_BUFFER( crb )>=0)
-		run_onsend_callbacks(TMCB_REQUEST_SENT, crb, 0);
+		run_onsend_callbacks(TMCB_REQUEST_SENT, crb, TMCB_LOCAL_F);
 #else
 	SEND_BUFFER( crb );
 #endif

+ 2 - 1
modules/tm/t_fwd.c

@@ -511,7 +511,8 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 #ifdef TMCB_ONSEND
 				else{
 					run_onsend_callbacks(TMCB_REQUEST_SENT, 
-											&t_cancel->uac[i].request, 0);
+											&t_cancel->uac[i].request,
+											TMCB_LOCAL_F);
 				}
 #endif
 				if (start_retr( &t_cancel->uac[i].request )!=0)

+ 5 - 4
modules/tm/t_hooks.c

@@ -269,7 +269,7 @@ void run_trans_callbacks( int type , struct cell *trans,
 
 
 #ifdef TMCB_ONSEND
-void run_onsend_callbacks(int type, struct retr_buf* rbuf, int retr)
+void run_onsend_callbacks(int type, struct retr_buf* rbuf, short flags)
 {
 	struct tmcb_params params;
 	struct cell * trans;
@@ -282,7 +282,7 @@ void run_onsend_callbacks(int type, struct retr_buf* rbuf, int retr)
 	params.send_buf.s=rbuf->buffer;
 	params.send_buf.len=rbuf->buffer_len;
 	params.dst=&rbuf->dst;
-	params.is_retr=retr;
+	params.flags=flags;
 	params.branch=rbuf->branch;
 	params.t_rbuf=rbuf;
 	params.code=rbuf->activ_type;
@@ -292,7 +292,8 @@ void run_onsend_callbacks(int type, struct retr_buf* rbuf, int retr)
 
 
 void run_onsend_callbacks2(int type , struct retr_buf* rbuf, char* buf,
-							int buf_len, struct dest_info* dst, int code)
+							int buf_len, struct dest_info* dst, int code,
+							short flags)
 {
 	struct tmcb_params params;
 	struct cell * trans;
@@ -305,7 +306,7 @@ void run_onsend_callbacks2(int type , struct retr_buf* rbuf, char* buf,
 	params.send_buf.s=buf;
 	params.send_buf.len=buf_len;
 	params.dst=dst;
-	params.is_retr=0;
+	params.flags=flags;
 	params.branch=rbuf->branch;
 	params.t_rbuf=rbuf;
 	params.code=code;

+ 13 - 5
modules/tm/t_hooks.h

@@ -301,6 +301,10 @@ struct cell;
 	callback function if necessary.
 */
 
+#ifdef TMCB_ONSEND
+#define TMCB_RETR_F 1
+#define TMCB_LOCAL_F 2
+#endif
 
 /* pack structure with all params passed to callback function */
 struct tmcb_params {
@@ -315,9 +319,12 @@ struct tmcb_params {
 	struct dest_info* dst; /* destination */
 	str send_buf; /* what was/will be sent on the net, used for ACKs
 					(which don't have a retr_buf). */
-	short is_retr; /* set if this is a _ser_ retransmission (but not if
-					 if it's a "forwarded" retr., like a retr. 200 Ok for 
-					 example) */
+	short flags; /* set to a combination of:
+					TMCB_RETR_F if this is a _ser_ retransmission (but 
+					 not if if it's a "forwarded" retr., like a retr. 200 Ok
+					 for example)
+					 TMCB_LOCAL_F if this is a local generated message
+					  (and not forwarded) */
 	unsigned short branch;
 	/* could also be: send_buf, dst, branch */
 #endif
@@ -383,9 +390,10 @@ void run_local_reqin_callbacks( struct cell *trans, struct sip_msg *req,
 		int code );
 
 #ifdef TMCB_ONSEND
-void run_onsend_callbacks(int type, struct retr_buf* rbuf, int retr);
+void run_onsend_callbacks(int type, struct retr_buf* rbuf, short flags);
 void run_onsend_callbacks2(int type , struct retr_buf* rbuf, char* buf,
-							int buf_len, struct dest_info* dst, int code);
+							int buf_len, struct dest_info* dst, int code,
+							short flags);
 #endif
 
 #endif

+ 8 - 5
modules/tm/t_reply.c

@@ -495,7 +495,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 #ifdef TMCB_ONSEND
 		if (SEND_PR_BUFFER( rb, buf, len )>=0)
 			run_onsend_callbacks2(TMCB_RESPONSE_SENT, rb, buf, len, &rb->dst,
-									code);
+									code, TMCB_LOCAL_F);
 #else
 		SEND_PR_BUFFER( rb, buf, len );
 #endif
@@ -1077,7 +1077,9 @@ int t_retransmit_reply( struct cell *t )
 	UNLOCK_REPLIES( t );
 	SEND_PR_BUFFER( & t->uas.response, b, len );
 #ifdef TMCB_ONSEND
-	run_onsend_callbacks(TMCB_RESPONSE_SENT, &t->uas.response, 1);
+	/* we don't know if it's a retransmission of a local reply or a forwarded
+	 * reply */
+	run_onsend_callbacks(TMCB_RESPONSE_SENT, &t->uas.response, TMCB_RETR_F);
 #endif
 	DBG("DEBUG: reply retransmitted. buf=%p: %.9s..., shmem=%p: %.9s\n",
 		b, b, t->uas.response.buffer, t->uas.response.buffer );
@@ -1448,7 +1450,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 			}
 #ifdef TMCB_ONSEND
 			run_onsend_callbacks2(TMCB_RESPONSE_SENT, uas_rb, buf, res_len,
-									&uas_rb->dst, relayed_code);
+									&uas_rb->dst, relayed_code, 
+									(relayed_msg==FAKED_REPLY)?TMCB_LOCAL_F:0);
 #endif
 		}
 		pkg_free( buf );
@@ -1633,7 +1636,7 @@ int reply_received( struct sip_msg  *p_msg )
 						run_onsend_callbacks2(TMCB_REQUEST_SENT,
 									&uac->request, ack, ack_len, 
 									&uac->request.dst,
-									TYPE_LOCAL_ACK);
+									TYPE_LOCAL_ACK, TMCB_LOCAL_F);
 #else
 					SEND_PR_BUFFER(&uac->request, ack, ack_len);
 #endif
@@ -1648,7 +1651,7 @@ int reply_received( struct sip_msg  *p_msg )
 					else
 						run_onsend_callbacks2(TMCB_REQUEST_SENT,
 									&uac->request, ack, ack_len, &lack_dst,
-									TYPE_LOCAL_ACK);
+									TYPE_LOCAL_ACK, TMCB_LOCAL_F);
 #endif
 					shm_free(ack);
 				}

+ 1 - 1
modules/tm/timer.c

@@ -308,7 +308,7 @@ inline static ticks_t retransmission_handler( struct retr_buf *r_buf )
 				return (ticks_t)-1;
 			}
 #ifdef TMCB_ONSEND
-			run_onsend_callbacks(TMCB_REQUEST_SENT, r_buf, 1);
+			run_onsend_callbacks(TMCB_REQUEST_SENT, r_buf, TMCB_RETR_F);
 #endif
 	} else {
 #ifdef EXTRA_DEBUG

+ 1 - 1
modules/tm/uac.c

@@ -355,7 +355,7 @@ static inline void send_prepared_request_impl(struct retr_buf *request, int retr
 #ifdef TMCB_ONSEND
 	else
 		/* we don't know the method here */
-		run_onsend_callbacks(TMCB_REQUEST_SENT, request, 0);
+		run_onsend_callbacks(TMCB_REQUEST_SENT, request, TMCB_LOCAL_F);
 #endif
 	
 	if (retransmit && (start_retr(request)!=0))