add: if (  p_msg->first_line.u.request.method_value==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
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;   buf=NULL;   branch = 0;	/* we don't do any forking right now */   /* it's about the same transaction or not? */   if ( global_msg_id != p_msg->id )   {      T = T_UNDEFINED;      global_msg_id = p_msg->id;   }   /* if  T hasn't been previous searched -> search for it */   if ( T == T_UNDEFINED )      t_lookup_request( p_msg, 0 , 0 );   /*if T hasn't been found after all -> return not found (error) */   if ( !T )      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->first_line.u.request.method_value==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 */   if ( T->outbound_request[branch]==NULL )   {      DBG("DEBUG: t_forward: first time forwarding\n");      /* special case : CANCEL */      if ( p_msg->first_line.u.request.method_value==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");               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] = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );      if (!T->outbound_request[branch]) {        LOG(L_ERR, "ERROR: t_forward: out of shmem\n");	goto error;      }      memset( T->outbound_request[branch] , 0 , sizeof (struct retrans_buff) );      T->outbound_request[branch]->tl[RETRASMISSIONS_LIST].payload =  T->outbound_request[branch];      T->outbound_request[branch]->tl[FR_TIMER_LIST].payload =  T->outbound_request[branch];      T->outbound_request[branch]->to.sin_family = AF_INET;      T->outbound_request[branch]->my_T =  T;      T->nr_of_outgoings = 1;      if ( add_branch_label( T, T->inbound_request , branch )==-1) return -1;      if ( add_branch_label( T, p_msg , branch )==-1) return -1;      if ( !(buf = build_req_buf_from_sip_req  ( p_msg, &len))) goto error;      T->outbound_request[branch]->bufflen = len ;      if ( !(T->outbound_request[branch]->retr_buffer   = (char*)sh_malloc( len ))) {	LOG(L_ERR, "ERROR: t_forward: shmem allocation failed\n");	goto error;      }      memcpy( T->outbound_request[branch]->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 */      insert_into_timer( hash_table , (&(T->outbound_request[branch]->tl[FR_TIMER_LIST])) , FR_TIMER_LIST, FR_TIME_OUT );      /* sets and starts the RETRANS timer */      T->outbound_request[branch]->timeout_ceiling  = RETR_T2;      T->outbound_request[branch]->timeout_value    = RETR_T1;      insert_into_timer( hash_table , (&(T->outbound_request[branch]->tl[RETRASMISSIONS_LIST])), RETRASMISSIONS_LIST , RETR_T1 );   }/* end for the first time */    /* if we are forwarding a CANCEL*/   if (  p_msg->first_line.u.request.method_value==METHOD_CANCEL )   {       /* 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)       {           remove_from_timer( hash_table , (&(T->outbound_request[branch]->tl[FR_TIMER_LIST])) , FR_TIMER_LIST);           remove_from_timer( hash_table , (&(T->outbound_request[branch]->tl[RETRASMISSIONS_LIST])), RETRASMISSIONS_LIST );           return 1;       }   }   /* send the request */   /* known to be in network order */   T->outbound_request[branch]->to.sin_port     =  dest_port;   T->outbound_request[branch]->to.sin_addr.s_addr =  dest_ip;   T->outbound_request[branch]->to.sin_family = AF_INET;   udp_send( T->outbound_request[branch]->retr_buffer , T->outbound_request[branch]->bufflen ,                    (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );   return 1;error:	if (T->outbound_request[branch]) sh_free(T->outbound_request[branch]);	if (buf) free( buf );	return -1;}