rem: t_check( p_msg  , 0 );
add: if (t_check( p_msg , 0 )==-1) return -1;
context: int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int dest_port_param ){	unsigned int dest_ip     = dest_ip_param;	unsigned int dest_port  = dest_port_param;	int	branch;	unsigned int len;   	char               *buf;	struct retrans_buff *rb;	buf=NULL;	branch = 0;	/* we don't do any forking right now */	/* it's about the same transaction or not? */	t_check( p_msg  , 0 );	/*if T hasn't been found after all -> return not found (error) */	if ( !T )	{		DBG("DEBUG: t_forward: no transaction found for request forwarding\n");		return -1;	}	/*if it's an ACK and the status is not final or is final, but error the      ACK is not forwarded*/	if ( p_msg->REQ_METHOD==METHOD_ACK  && (T->status/100)!=2 ) {		DBG("DEBUG: t_forward: local ACK; don't forward\n");		return 1;	}	/* if it's forwarded for the first time ; else the request is retransmited 	 * from the transaction buffer	 * when forwarding an ACK, this condition will br all the time false because	 * the forwarded INVITE is in the retransmission buffer */	if ( T->outbound_request[branch]==NULL )	{		DBG("DEBUG: t_forward: first time forwarding\n");		/* special case : CANCEL */		if ( p_msg->REQ_METHOD==METHOD_CANCEL  )		{			DBG("DEBUG: t_forward: it's CANCEL\n");			/* find original cancelled transaction; if found, use its 			   next-hops; otherwise use those passed by script */			if ( T->T_canceled==T_UNDEFINED )				T->T_canceled = t_lookupOriginalT( hash_table , p_msg );			/* if found */			if ( T->T_canceled!=T_NULL )			{				T->T_canceled->T_canceler = T;				/* if in 1xx status, send to the same destination */				if ( (T->T_canceled->status/100)==1 )				{					DBG("DEBUG: t_forward: it's CANCEL and I will send "						"to the same place where INVITE went\n");					dest_ip=T->T_canceled->outbound_request[branch]->						to.sin_addr.s_addr;					dest_port = T->T_canceled->outbound_request[branch]->						to.sin_port;				} else { /* transaction exists, but nothing to cancel */               				DBG("DEBUG: t_forward: it's CANCEL but "						"I have nothing to cancel here\n");					/* continue forwarding CANCEL as a stand-alone transaction */					/*	return 1; */				} 			} else { /* transaction doesnot exists  */            			DBG("DEBUG: t_forward: canceled request not found! "				"nothing to CANCEL\n");            			return 1;         		}      		}/* end special case CANCEL*/		/* allocates a new retrans_buff for the outbound request */		DBG("DEBUG: t_forward: building outbound request\n");		T->outbound_request[branch] = rb = 			(struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );		if (!rb)		{			LOG(L_ERR, "ERROR: t_forward: out of shmem\n");			goto error;		}		memset( rb , 0 , sizeof (struct retrans_buff) );		rb->retr_timer.payload =  rb;		rb->fr_timer.payload =  rb;		rb->to.sin_family = AF_INET;		rb->my_T =  T;		T->nr_of_outgoings = 1;		if ( add_branch_label( T, T->inbound_request , branch )==-1) 			goto error;		if ( add_branch_label( T, p_msg , branch )==-1) 			goto error;		if ( !(buf = build_req_buf_from_sip_req  ( p_msg, &len))) 			goto error;		rb->bufflen = len ;		if ( !(rb->retr_buffer = (char*)sh_malloc( len ))) 		{			LOG(L_ERR, "ERROR: t_forward: shmem allocation failed\n");			goto error;		}		memcpy( rb->retr_buffer , buf , len );		free( buf ) ; buf=NULL;		DBG("DEBUG: t_forward: starting timers (retrans and FR) %d\n",get_ticks() );		/*sets and starts the FINAL RESPONSE timer */		set_timer( hash_table, &(rb->fr_timer), FR_TIMER_LIST );		/* sets and starts the RETRANS timer */		rb->retr_list = RT_T1_TO_1;		set_timer( hash_table, &(rb->retr_timer), RT_T1_TO_1 );	}/* end for the first time */	/* if we are forwarding an ACK*/	if (  p_msg->REQ_METHOD==METHOD_ACK &&		T->relaied_reply_branch>=0 && 		T->relaied_reply_branch<=T->nr_of_outgoings)	{		DBG("DEBUG: t_forward: forwarding ACK [%d]\n",T->relaied_reply_branch);		t_build_and_send_ACK( T, branch , 			T->inbound_response[T->relaied_reply_branch] );		T->inbound_request_isACKed = 1;		return 1;	} else /* if we are forwarding a CANCEL*/	if (  p_msg->REQ_METHOD==METHOD_CANCEL )	{		DBG("DEBUG: t_forward: forwarding CANCEL\n");		/* if no transaction to CANCEL */      /* or if the canceled transaction has a final status -> drop the CANCEL*/		if ( T->T_canceled==T_NULL || T->T_canceled->status>=200)		{			reset_timer( hash_table, &(rb->fr_timer ));			reset_timer( hash_table, &(rb->retr_timer ));           		return 1;       		}   	}	/* send the request */   	/* known to be in network order */	rb->to.sin_port     =  dest_port;	rb->to.sin_addr.s_addr =  dest_ip;	rb->to.sin_family = AF_INET;	SEND_BUFFER( rb );   return 1;error:	if ( rb && rb->retr_buffer) sh_free( rb->retr_buffer );	if (rb) {		sh_free(rb);		T->outbound_request[branch]=NULL;	}	if (buf) free( buf );	return -1;}