Browse Source

tm: option to compile without reason support

If compiled with -DNO_CANCEL_REASON_SUPPORT, the reason header
support will not be enabled.
Andrei Pelinescu-Onciul 15 years ago
parent
commit
bf5d1d6f1d

+ 2 - 0
modules/tm/h_table.c

@@ -138,8 +138,10 @@ void free_cell( struct cell* dead_cell )
 		sip_msg_free_unsafe( dead_cell->uas.request );
 		sip_msg_free_unsafe( dead_cell->uas.request );
 	if ( dead_cell->uas.response.buffer )
 	if ( dead_cell->uas.response.buffer )
 		shm_free_unsafe( dead_cell->uas.response.buffer );
 		shm_free_unsafe( dead_cell->uas.response.buffer );
+#ifdef CANCEL_REASON_SUPPORT
 	if (unlikely(dead_cell->uas.cancel_reas))
 	if (unlikely(dead_cell->uas.cancel_reas))
 		shm_free_unsafe(dead_cell->uas.cancel_reas);
 		shm_free_unsafe(dead_cell->uas.cancel_reas);
+#endif /* CANCEL_REASON_SUPPORT */
 
 
 	/* callbacks */
 	/* callbacks */
 	for( cbs=(struct tm_callback*)dead_cell->tmcb_hl.first ; cbs ; ) {
 	for( cbs=(struct tm_callback*)dead_cell->tmcb_hl.first ; cbs ; ) {

+ 2 - 0
modules/tm/h_table.h

@@ -191,8 +191,10 @@ typedef struct ua_server
 	 * we need them for dialog-wise matching of ACKs;
 	 * we need them for dialog-wise matching of ACKs;
 	 * the pointer shows to shmem-ed reply */
 	 * the pointer shows to shmem-ed reply */
 	str				 local_totag;
 	str				 local_totag;
+#ifdef CANCEL_REASON_SUPPORT
 	struct cancel_reason* cancel_reas; /* pointer to cancel reason, used
 	struct cancel_reason* cancel_reas; /* pointer to cancel reason, used
 										  for e2e cancels */
 										  for e2e cancels */
+#endif /* CANCEL_REASON_SUPPORT */
 	unsigned int     status;
 	unsigned int     status;
 }ua_server_type;
 }ua_server_type;
 
 

+ 17 - 5
modules/tm/t_cancel.c

@@ -123,7 +123,9 @@ int cancel_uacs( struct cell *t, struct cancel_info* cancel_data, int flags)
 			r=cancel_branch(
 			r=cancel_branch(
 				t,
 				t,
 				i,
 				i,
+#ifdef CANCEL_REASON_SUPPORT
 				&cancel_data->reason,
 				&cancel_data->reason,
+#endif /* CANCEL_REASON_SUPPORT */
 				flags | ((t->uac[i].request.buffer==NULL)?
 				flags | ((t->uac[i].request.buffer==NULL)?
 					F_CANCEL_B_FAKE_REPLY:0) /* blind UAC? */
 					F_CANCEL_B_FAKE_REPLY:0) /* blind UAC? */
 			);
 			);
@@ -206,7 +208,10 @@ int cancel_all_uacs(struct cell *trans, int how)
  *          - checking for buffer==0 under REPLY_LOCK is no enough, an 
  *          - checking for buffer==0 under REPLY_LOCK is no enough, an 
  *           atomic_cmpxhcg or atomic_get_and_set _must_ be used.
  *           atomic_cmpxhcg or atomic_get_and_set _must_ be used.
  */
  */
-int cancel_branch( struct cell *t, int branch, struct cancel_reason* reason,
+int cancel_branch( struct cell *t, int branch,
+	#ifdef CANCEL_REASON_SUPPORT
+					struct cancel_reason* reason,
+	#endif /* CANCEL_REASON_SUPPORT */
 					int flags )
 					int flags )
 {
 {
 	char *cancel;
 	char *cancel;
@@ -278,11 +283,18 @@ int cancel_branch( struct cell *t, int branch, struct cancel_reason* reason,
 	if (cfg_get(tm, tm_cfg, reparse_invite)) {
 	if (cfg_get(tm, tm_cfg, reparse_invite)) {
 		/* build the CANCEL from the INVITE which was sent out */
 		/* build the CANCEL from the INVITE which was sent out */
 		cancel = build_local_reparse(t, branch, &len, CANCEL, CANCEL_LEN,
 		cancel = build_local_reparse(t, branch, &len, CANCEL, CANCEL_LEN,
-									 &t->to, reason);
+									 &t->to
+	#ifdef CANCEL_REASON_SUPPORT
+									 , reason
+	#endif /* CANCEL_REASON_SUPPORT */
+									 );
 	} else {
 	} else {
-		/* build the CANCEL from the reveived INVITE */
-		cancel = build_local(t, branch, &len, CANCEL, CANCEL_LEN, &t->to,
-							 reason);
+		/* build the CANCEL from the received INVITE */
+		cancel = build_local(t, branch, &len, CANCEL, CANCEL_LEN, &t->to
+	#ifdef CANCEL_REASON_SUPPORT
+								, reason
+	#endif /* CANCEL_REASON_SUPPORT */
+								);
 	}
 	}
 	if (!cancel) {
 	if (!cancel) {
 		LOG(L_ERR, "ERROR: attempt to build a CANCEL failed\n");
 		LOG(L_ERR, "ERROR: attempt to build a CANCEL failed\n");

+ 4 - 1
modules/tm/t_cancel.h

@@ -83,7 +83,10 @@
 void prepare_to_cancel(struct cell *t, branch_bm_t *cancel_bm, branch_bm_t s);
 void prepare_to_cancel(struct cell *t, branch_bm_t *cancel_bm, branch_bm_t s);
 int cancel_uacs( struct cell *t, struct cancel_info* cancel_data, int flags );
 int cancel_uacs( struct cell *t, struct cancel_info* cancel_data, int flags );
 int cancel_all_uacs(struct cell *trans, int how);
 int cancel_all_uacs(struct cell *trans, int how);
-int cancel_branch( struct cell *t, int branch, struct cancel_reason* reason,
+int cancel_branch( struct cell *t, int branch,
+#ifdef CANCEL_REASON_SUPPORT
+					struct cancel_reason* reason,
+#endif /* CANCEL_REASON_SUPPORT */
 					int flags );
 					int flags );
 
 
 typedef int(*cancel_uacs_f)( struct cell *t, branch_bm_t cancel_bm,
 typedef int(*cancel_uacs_f)( struct cell *t, branch_bm_t cancel_bm,

+ 16 - 2
modules/tm/t_fwd.c

@@ -918,7 +918,11 @@ int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel,
 			"thus lumps are not applied to the message!\n");
 			"thus lumps are not applied to the message!\n");
 		}
 		}
 		shbuf=build_local_reparse( t_invite, branch, &len, CANCEL,
 		shbuf=build_local_reparse( t_invite, branch, &len, CANCEL,
-									CANCEL_LEN, &t_invite->to, 0);
+									CANCEL_LEN, &t_invite->to
+#ifdef CANCEL_REASON_SUPPORT
+									, 0
+#endif /* CANCEL_REASON_SUPPORT */
+									);
 		if (unlikely(!shbuf)) {
 		if (unlikely(!shbuf)) {
 			LOG(L_ERR, "e2e_cancel_branch: printing e2e cancel failed\n");
 			LOG(L_ERR, "e2e_cancel_branch: printing e2e cancel failed\n");
 			ret=ser_error=E_OUT_OF_MEM;
 			ret=ser_error=E_OUT_OF_MEM;
@@ -951,6 +955,7 @@ error:
 
 
 
 
 
 
+#ifdef CANCEL_REASON_SUPPORT
 /** create a cancel reason structure packed into a single shm. block.
 /** create a cancel reason structure packed into a single shm. block.
   * From a cause and a pointer to a str or cancel_msg, build a
   * From a cause and a pointer to a str or cancel_msg, build a
   * packed cancel reason structure (CANCEL_REAS_PACKED_HDRS), using a
   * packed cancel reason structure (CANCEL_REAS_PACKED_HDRS), using a
@@ -975,6 +980,8 @@ static struct cancel_reason* cancel_reason_pack(short cause, void* data,
 		reason_len = 0;
 		reason_len = 0;
 		txt = 0;
 		txt = 0;
 		e2e_cancel = 0;
 		e2e_cancel = 0;
+		reas1 = 0;
+		reas_last = 0;
 		if (likely(cause == CANCEL_REAS_RCVD_CANCEL &&
 		if (likely(cause == CANCEL_REAS_RCVD_CANCEL &&
 					data && !(t->flags & T_NO_E2E_CANCEL_REASON))) {
 					data && !(t->flags & T_NO_E2E_CANCEL_REASON))) {
 			/* parse the entire cancel, to get all the Reason headers */
 			/* parse the entire cancel, to get all the Reason headers */
@@ -1046,6 +1053,7 @@ static struct cancel_reason* cancel_reason_pack(short cause, void* data,
 error:
 error:
 	return 0;
 	return 0;
 }
 }
+#endif /* CANCEL_REASON_SUPPORT */
 
 
 
 
 
 
@@ -1055,7 +1063,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	branch_bm_t cancel_bm;
 	branch_bm_t cancel_bm;
 #ifndef E2E_CANCEL_HOP_BY_HOP
 #ifndef E2E_CANCEL_HOP_BY_HOP
 	branch_bm_t tmp_bm;
 	branch_bm_t tmp_bm;
-#else /* def E2E_CANCEL_HOP_BY_HOP */
+#elif defined (CANCEL_REASON_SUPPORT)
 	struct cancel_reason* reason;
 	struct cancel_reason* reason;
 	int free_reason;
 	int free_reason;
 #endif /* E2E_CANCEL_HOP_BY_HOP */
 #endif /* E2E_CANCEL_HOP_BY_HOP */
@@ -1103,6 +1111,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	 * have 0 branches and we check for the branch number in 
 	 * have 0 branches and we check for the branch number in 
 	 * t_reply_matching() ).
 	 * t_reply_matching() ).
 	 */
 	 */
+#ifdef CANCEL_REASON_SUPPORT
 	free_reason = 0;
 	free_reason = 0;
 	reason = 0;
 	reason = 0;
 	if (likely(t_invite->uas.cancel_reas == 0)){
 	if (likely(t_invite->uas.cancel_reas == 0)){
@@ -1116,6 +1125,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 			free_reason = 1;
 			free_reason = 1;
 		}
 		}
 	}
 	}
+#endif /* CANCEL_REASON_SUPPORT */
 	for (i=0; i<t_invite->nr_of_outgoings; i++)
 	for (i=0; i<t_invite->nr_of_outgoings; i++)
 		if (cancel_bm & (1<<i)) {
 		if (cancel_bm & (1<<i)) {
 			/* it's safe to get the reply lock since e2e_cancel is
 			/* it's safe to get the reply lock since e2e_cancel is
@@ -1125,7 +1135,9 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 			ret=cancel_branch(
 			ret=cancel_branch(
 				t_invite,
 				t_invite,
 				i,
 				i,
+#ifdef CANCEL_REASON_SUPPORT
 				reason,
 				reason,
+#endif /* CANCEL_REASON_SUPPORT */
 				cfg_get(tm,tm_cfg, cancel_b_flags)
 				cfg_get(tm,tm_cfg, cancel_b_flags)
 					| ((t_invite->uac[i].request.buffer==NULL)?
 					| ((t_invite->uac[i].request.buffer==NULL)?
 						F_CANCEL_B_FAKE_REPLY:0) /* blind UAC? */
 						F_CANCEL_B_FAKE_REPLY:0) /* blind UAC? */
@@ -1133,10 +1145,12 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 			if (ret<0) cancel_bm &= ~(1<<i);
 			if (ret<0) cancel_bm &= ~(1<<i);
 			if (ret<lowest_error) lowest_error=ret;
 			if (ret<lowest_error) lowest_error=ret;
 		}
 		}
+#ifdef CANCEL_REASON_SUPPORT
 	if (unlikely(free_reason)) {
 	if (unlikely(free_reason)) {
 		/* reason was not set as the global reason => free it */
 		/* reason was not set as the global reason => free it */
 		shm_free(reason);
 		shm_free(reason);
 	}
 	}
+#endif /* CANCEL_REASON_SUPPORT */
 #else /* ! E2E_CANCEL_HOP_BY_HOP */
 #else /* ! E2E_CANCEL_HOP_BY_HOP */
 	/* fix label -- it must be same for reply matching (the label is part of
 	/* fix label -- it must be same for reply matching (the label is part of
 	 * the generated via branch for the cancels sent upstream and if it
 	 * the generated via branch for the cancels sent upstream and if it

+ 28 - 5
modules/tm/t_msgbuilder.c

@@ -86,8 +86,11 @@
    customers of this function are local ACK and local CANCEL
    customers of this function are local ACK and local CANCEL
  */
  */
 char *build_local(struct cell *Trans,unsigned int branch,
 char *build_local(struct cell *Trans,unsigned int branch,
-	unsigned int *len, char *method, int method_len, str *to,
-	struct cancel_reason* reason)
+	unsigned int *len, char *method, int method_len, str *to
+#ifdef CANCEL_REASON_SUPPORT
+	, struct cancel_reason* reason
+#endif /* CANCEL_REASON_SUPPORT */
+	)
 {
 {
 	char                *cancel_buf, *p, *via;
 	char                *cancel_buf, *p, *via;
 	unsigned int         via_len;
 	unsigned int         via_len;
@@ -97,8 +100,10 @@ char *build_local(struct cell *Trans,unsigned int branch,
 	str branch_str;
 	str branch_str;
 	str via_id;
 	str via_id;
 	struct hostport hp;
 	struct hostport hp;
+#ifdef CANCEL_REASON_SUPPORT
 	int reason_len, code_len;
 	int reason_len, code_len;
 	struct hdr_field *reas1, *reas_last;
 	struct hdr_field *reas1, *reas_last;
+#endif /* CANCEL_REASON_SUPPORT */
 
 
 	/* init */
 	/* init */
 	via_id.s=0;
 	via_id.s=0;
@@ -163,6 +168,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 	}
 	}
 	/* Content Length, EoM */
 	/* Content Length, EoM */
 	*len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
 	*len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
+#ifdef CANCEL_REASON_SUPPORT
 	reason_len = 0;
 	reason_len = 0;
 	reas1 = 0;
 	reas1 = 0;
 	reas_last = 0;
 	reas_last = 0;
@@ -193,6 +199,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 			BUG("unhandled reason cause %d\n", reason->cause);
 			BUG("unhandled reason cause %d\n", reason->cause);
 	}
 	}
 	*len+= reason_len;
 	*len+= reason_len;
+#endif /* CANCEL_REASON_SUPPORT */
 	*len+= CRLF_LEN; /* end of msg. */
 	*len+= CRLF_LEN; /* end of msg. */
 
 
 	cancel_buf=shm_malloc( *len+1 );
 	cancel_buf=shm_malloc( *len+1 );
@@ -235,6 +242,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 	}
 	}
 	/* Content Length */
 	/* Content Length */
 	append_str(p, CONTENT_LENGTH "0" CRLF, CONTENT_LENGTH_LEN + 1 + CRLF_LEN);
 	append_str(p, CONTENT_LENGTH "0" CRLF, CONTENT_LENGTH_LEN + 1 + CRLF_LEN);
+#ifdef CANCEL_REASON_SUPPORT
 	/* add reason if needed */
 	/* add reason if needed */
 	if (reason_len) {
 	if (reason_len) {
 		if (likely(reason->cause > 0)) {
 		if (likely(reason->cause > 0)) {
@@ -262,6 +270,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 			}
 			}
 		}
 		}
 	}
 	}
+#endif /* CANCEL_REASON_SUPPORT */
 	append_str(p, CRLF, CRLF_LEN); /* msg. end */
 	append_str(p, CRLF, CRLF_LEN); /* msg. end */
 	*p=0;
 	*p=0;
 
 
@@ -280,8 +289,11 @@ error:
  * Can not be used to build other type of requests!
  * Can not be used to build other type of requests!
  */
  */
 char *build_local_reparse(struct cell *Trans,unsigned int branch,
 char *build_local_reparse(struct cell *Trans,unsigned int branch,
-	unsigned int *len, char *method, int method_len, str *to,
-	struct cancel_reason *reason)
+	unsigned int *len, char *method, int method_len, str *to
+#ifdef CANCEL_REASON_SUPPORT
+	, struct cancel_reason *reason
+#endif /* CANCEL_REASON_SUPPORT */
+	)
 {
 {
 	char	*invite_buf, *invite_buf_end;
 	char	*invite_buf, *invite_buf_end;
 	char	*cancel_buf;
 	char	*cancel_buf;
@@ -289,8 +301,11 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 	short	invite_len;
 	short	invite_len;
 	enum _hdr_types_t	hf_type;
 	enum _hdr_types_t	hf_type;
 	int	first_via, to_len;
 	int	first_via, to_len;
-	int cancel_buf_len, reason_len, code_len;
+	int cancel_buf_len;
+#ifdef CANCEL_REASON_SUPPORT
+	int reason_len, code_len;
 	struct hdr_field *reas1, *reas_last, *hdr;
 	struct hdr_field *reas1, *reas_last, *hdr;
+#endif /* CANCEL_REASON_SUPPORT */
 
 
 	invite_buf = Trans->uac[branch].request.buffer;
 	invite_buf = Trans->uac[branch].request.buffer;
 	invite_len = Trans->uac[branch].request.buffer_len;
 	invite_len = Trans->uac[branch].request.buffer_len;
@@ -305,6 +320,7 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 		goto error;
 		goto error;
 	}
 	}
 	
 	
+#ifdef CANCEL_REASON_SUPPORT
 	reason_len = 0;
 	reason_len = 0;
 	reas1 = 0;
 	reas1 = 0;
 	reas_last = 0;
 	reas_last = 0;
@@ -334,6 +350,7 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 		} else if (unlikely(reason->cause < CANCEL_REAS_MIN))
 		} else if (unlikely(reason->cause < CANCEL_REAS_MIN))
 			BUG("unhandled reason cause %d\n", reason->cause);
 			BUG("unhandled reason cause %d\n", reason->cause);
 	}
 	}
+#endif /* CANCEL_REASON_SUPPORT */
 
 
 	invite_buf_end = invite_buf + invite_len;
 	invite_buf_end = invite_buf + invite_len;
 	s = invite_buf;
 	s = invite_buf;
@@ -343,7 +360,11 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 	I just extend it with the length of new To HF to be sure.
 	I just extend it with the length of new To HF to be sure.
 	Ugly, but we avoid lots of checks and memory allocations this way */
 	Ugly, but we avoid lots of checks and memory allocations this way */
 	to_len = to ? to->len : 0;
 	to_len = to ? to->len : 0;
+#ifdef CANCEL_REASON_SUPPORT
 	cancel_buf_len = invite_len + to_len + reason_len;
 	cancel_buf_len = invite_len + to_len + reason_len;
+#else
+	cancel_buf_len = invite_len + to_len;
+#endif /* CANCEL_REASON_SUPPORT */
 	cancel_buf = shm_malloc(sizeof(char)*cancel_buf_len);
 	cancel_buf = shm_malloc(sizeof(char)*cancel_buf_len);
 	if (!cancel_buf)
 	if (!cancel_buf)
 	{
 	{
@@ -437,6 +458,7 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 
 
 			case HDR_EOH_T:
 			case HDR_EOH_T:
 				/* end of SIP message found */
 				/* end of SIP message found */
+#ifdef CANCEL_REASON_SUPPORT
 				/* add reason if needed */
 				/* add reason if needed */
 				if (reason_len) {
 				if (reason_len) {
 					/* if reason_len !=0, no need for any reason enabled
 					/* if reason_len !=0, no need for any reason enabled
@@ -469,6 +491,7 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 						}
 						}
 					}
 					}
 				}
 				}
+#endif /* CANCEL_REASON_SUPPORT */
 				/* final (end-of-headers) CRLF */
 				/* final (end-of-headers) CRLF */
 				append_str(d, CRLF, CRLF_LEN);
 				append_str(d, CRLF, CRLF_LEN);
 				*len = d - cancel_buf;
 				*len = d - cancel_buf;

+ 11 - 4
modules/tm/t_msgbuilder.h

@@ -37,6 +37,7 @@
 #include "../../ip_addr.h"
 #include "../../ip_addr.h"
 #include "defs.h"
 #include "defs.h"
 #include "dlg.h"
 #include "dlg.h"
+#include "h_table.h"
 
 
 
 
 #define CSEQ "CSeq: "
 #define CSEQ "CSeq: "
@@ -54,12 +55,18 @@
 
 
 
 
 char *build_local(struct cell *Trans, unsigned int branch,
 char *build_local(struct cell *Trans, unsigned int branch,
-	unsigned int *len, char *method, int method_len, str *to,
-	struct cancel_reason* reason);
+	unsigned int *len, char *method, int method_len, str *to
+#ifdef CANCEL_REASON_SUPPORT
+	, struct cancel_reason* reason
+#endif /* CANCEL_REASON_SUPPORT */
+	);
 
 
 char *build_local_reparse(struct cell *Trans, unsigned int branch,
 char *build_local_reparse(struct cell *Trans, unsigned int branch,
-	unsigned int *len, char *method, int method_len, str *to,
-	struct cancel_reason* reason);
+	unsigned int *len, char *method, int method_len, str *to
+#ifdef CANCEL_REASON_SUPPORT
+	, struct cancel_reason* reason
+#endif /* CANCEL_REASON_SUPPORT */
+	);
 
 
 char *build_uac_request(  str msg_type, str dst, str from,
 char *build_uac_request(  str msg_type, str dst, str from,
 	str fromtag, int cseq, str callid, str headers, 
 	str fromtag, int cseq, str callid, str headers, 

+ 20 - 2
modules/tm/t_reply.c

@@ -392,11 +392,19 @@ static char *build_ack(struct sip_msg* rpl,struct cell *trans,int branch,
 	if (cfg_get(tm, tm_cfg, reparse_invite)) {
 	if (cfg_get(tm, tm_cfg, reparse_invite)) {
 		/* build the ACK from the INVITE which was sent out */
 		/* build the ACK from the INVITE which was sent out */
 		return build_local_reparse( trans, branch, ret_len,
 		return build_local_reparse( trans, branch, ret_len,
-					ACK, ACK_LEN, &to, 0 );
+					ACK, ACK_LEN, &to
+	#ifdef CANCEL_REASON_SUPPORT
+					, 0
+	#endif /* CANCEL_REASON_SUPPORT */
+					);
 	} else {
 	} else {
 		/* build the ACK from the reveived INVITE */
 		/* build the ACK from the reveived INVITE */
 		return build_local( trans, branch, ret_len,
 		return build_local( trans, branch, ret_len,
-					ACK, ACK_LEN, &to, 0 );
+					ACK, ACK_LEN, &to
+	#ifdef CANCEL_REASON_SUPPORT
+					, 0
+	#endif /* CANCEL_REASON_SUPPORT */
+					);
 	}
 	}
 }
 }
 
 
@@ -594,7 +602,9 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 		cleanup_uac_timers( trans );
 		cleanup_uac_timers( trans );
 		if (is_invite(trans)){
 		if (is_invite(trans)){
 			prepare_to_cancel(trans, &cancel_data.cancel_bitmap, 0);
 			prepare_to_cancel(trans, &cancel_data.cancel_bitmap, 0);
+#ifdef CANCEL_REASON_SUPPORT
 			cancel_data.reason.cause=code;
 			cancel_data.reason.cause=code;
+#endif /* CANCEL_REASON_SUPPORT */
 			cancel_uacs( trans, &cancel_data, F_CANCEL_B_KILL );
 			cancel_uacs( trans, &cancel_data, F_CANCEL_B_KILL );
 		}
 		}
 		start_final_repl_retr(  trans );
 		start_final_repl_retr(  trans );
@@ -1140,7 +1150,9 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 					  if the 6xx handling is not disabled */
 					  if the 6xx handling is not disabled */
 					prepare_to_cancel(Trans, &cancel_data->cancel_bitmap, 0);
 					prepare_to_cancel(Trans, &cancel_data->cancel_bitmap, 0);
 					Trans->flags|=T_6xx;
 					Trans->flags|=T_6xx;
+#ifdef CANCEL_REASON_SUPPORT
 					cancel_data->reason.cause=new_code;
 					cancel_data->reason.cause=new_code;
+#endif /* CANCEL_REASON_SUPPORT */
 				}
 				}
 			}
 			}
 			return RPS_STORE;
 			return RPS_STORE;
@@ -1295,7 +1307,9 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 		*should_relay= new_code==100? -1 : branch;
 		*should_relay= new_code==100? -1 : branch;
 		if (new_code>=200 ) {
 		if (new_code>=200 ) {
 			prepare_to_cancel( Trans, &cancel_data->cancel_bitmap, 0);
 			prepare_to_cancel( Trans, &cancel_data->cancel_bitmap, 0);
+#ifdef CANCEL_REASON_SUPPORT
 			cancel_data->reason.cause=new_code;
 			cancel_data->reason.cause=new_code;
+#endif /* CANCEL_REASON_SUPPORT */
 			return RPS_COMPLETED;
 			return RPS_COMPLETED;
 		} else return RPS_PROVISIONAL;
 		} else return RPS_PROVISIONAL;
 	}
 	}
@@ -2041,6 +2055,7 @@ int reply_received( struct sip_msg  *p_msg )
 				 * if BUSY or set just exit, a cancel will be (or was) sent 
 				 * if BUSY or set just exit, a cancel will be (or was) sent 
 				 * shortly on this branch */
 				 * shortly on this branch */
 				DBG("tm: reply_received: branch CANCEL created\n");
 				DBG("tm: reply_received: branch CANCEL created\n");
+#ifdef CANCEL_REASON_SUPPORT
 				if (t->uas.cancel_reas) {
 				if (t->uas.cancel_reas) {
 					/* cancel reason was saved, use it */
 					/* cancel reason was saved, use it */
 					cancel_branch(t, branch, t->uas.cancel_reas,
 					cancel_branch(t, branch, t->uas.cancel_reas,
@@ -2055,6 +2070,9 @@ int reply_received( struct sip_msg  *p_msg )
 					cancel_branch(t, branch, &cancel_data.reason,
 					cancel_branch(t, branch, &cancel_data.reason,
 														F_CANCEL_B_FORCE_C);
 														F_CANCEL_B_FORCE_C);
 				}
 				}
+#else /* CANCEL_REASON_SUPPORT */
+				cancel_branch(t, branch, F_CANCEL_B_FORCE_C);
+#endif /* CANCEL_REASON_SUPPORT */
 			}
 			}
 			goto done; /* nothing to do */
 			goto done; /* nothing to do */
 		}
 		}

+ 22 - 2
modules/tm/t_reply.h

@@ -30,6 +30,11 @@
 #ifndef _T_REPLY_H
 #ifndef _T_REPLY_H
 #define _T_REPLY_H
 #define _T_REPLY_H
 
 
+/* CANCEL_REASON_SUPPORT on by default */
+#ifndef NO_CANCEL_REASON_SUPPORT
+#define CANCEL_REASON_SUPPORT
+#endif /* NO_CANCEL_REASON_SUPPORT */
+
 #include "defs.h"
 #include "defs.h"
 #include "../../rpc.h"
 #include "../../rpc.h"
 #include "../../tags.h"
 #include "../../tags.h"
@@ -64,6 +69,7 @@ int unmatched_totag(struct cell *t, struct sip_msg *ack);
 /* branch bitmap type */
 /* branch bitmap type */
 typedef unsigned int branch_bm_t;
 typedef unsigned int branch_bm_t;
 
 
+#ifdef CANCEL_REASON_SUPPORT
 
 
 /* reason building blocks (see rfc3326) */
 /* reason building blocks (see rfc3326) */
 #define REASON_PREFIX "Reason: SIP;cause="
 #define REASON_PREFIX "Reason: SIP;cause="
@@ -106,6 +112,20 @@ struct cancel_info {
 		init_cancel_reason(&(ci)->reason); \
 		init_cancel_reason(&(ci)->reason); \
 	}while (0);
 	}while (0);
 
 
+#else /* ! CANCEL_REASON_SUPPORT */
+
+struct cancel_info {
+	branch_bm_t cancel_bitmap; /**< cancel branch bitmap */
+};
+
+#define init_cancel_info(ci) \
+	do {\
+		(ci)->cancel_bitmap=0; \
+	}while (0);
+
+#endif /* CANCEL_REASON_SUPPORT */
+
+
 /* reply export types */
 /* reply export types */
 typedef int (*treply_f)(struct sip_msg * , unsigned int , char * );
 typedef int (*treply_f)(struct sip_msg * , unsigned int , char * );
 typedef int (*treply_wb_f)( struct cell* trans,
 typedef int (*treply_wb_f)( struct cell* trans,
@@ -162,12 +182,12 @@ int t_reply( struct cell *t, struct sip_msg * , unsigned int , char * );
 int t_reply_unsafe( struct cell *t, struct sip_msg * , unsigned int , char * );
 int t_reply_unsafe( struct cell *t, struct sip_msg * , unsigned int , char * );
 
 
 
 
-enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch, 
+enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 	unsigned int msg_status, struct cancel_info *cancel_data,
 	unsigned int msg_status, struct cancel_info *cancel_data,
 	int do_put_on_wait );
 	int do_put_on_wait );
 
 
 enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
-    unsigned int msg_status, struct cancel_info *cancel_data );
+	unsigned int msg_status, struct cancel_info *cancel_data );
 
 
 void set_final_timer( /* struct s_table *h_table,*/ struct cell *t );
 void set_final_timer( /* struct s_table *h_table,*/ struct cell *t );
 
 

+ 4 - 0
modules/tm/timer.c

@@ -339,7 +339,11 @@ static void fake_reply(struct cell *t, int branch, int code )
 					  &cancel_data, 0 );
 					  &cancel_data, 0 );
 	}
 	}
 	/* now when out-of-lock do the cancel I/O */
 	/* now when out-of-lock do the cancel I/O */
+#ifdef CANCEL_REASON_SUPPORT
 	if (do_cancel_branch) cancel_branch(t, branch, &cancel_data.reason, 0);
 	if (do_cancel_branch) cancel_branch(t, branch, &cancel_data.reason, 0);
+#else /* CANCEL_REASON_SUPPORT */
+	if (do_cancel_branch) cancel_branch(t, branch, 0);
+#endif /* CANCEL_REASON_SUPPORT */
 	/* it's cleaned up on error; if no error occurred and transaction
 	/* it's cleaned up on error; if no error occurred and transaction
 	   completed regularly, I have to clean-up myself
 	   completed regularly, I have to clean-up myself
 	*/
 	*/