Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 03/12/2001 19:04:20
Showing 2 changed files
... ...
@@ -558,13 +558,6 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
558 558
      return -1;
559 559
    }
560 560
 
561
-   buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
562
-   DBG("DEBUG: t_send_reply: after build\n");
563
-   if (!buf)
564
-   {
565
-      DBG("DEBUG: t_send_reply: response building failed\n");
566
-     goto error;
567
-   }
568 561
 
569 562
    if ( T->outbound_response)
570 563
    {
... ...
@@ -584,49 +577,63 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
584 584
       }
585 585
       T->outbound_response = rb;
586 586
       memset( T->outbound_response , 0 , sizeof (struct retrans_buff) );
587
+
588
+      /* initialize retransmission structure */
589
+     if (update_sock_struct_from_via(  &(T->outbound_response->to),  p_msg->via1 )==-1)
590
+      {
591
+         LOG(L_ERR, "ERROR: t_send_reply: cannot lookup reply dst: %s\n",
592
+                  p_msg->via1->host.s );
593
+        goto error;
594
+      }
595
+
596
+      T->outbound_response->tl[RETRASMISSIONS_LIST].payload = T->outbound_response;
597
+      T->outbound_response->tl[FR_TIMER_LIST].payload = T->outbound_response;
598
+      T->outbound_response->my_T = T;
599
+      T->status = code;
600
+
601
+
602
+
587 603
    }
588 604
 
589
-	/* initialize retransmission structure */
590
-	if (update_sock_struct_from_via(  &(T->outbound_response->to),  p_msg->via1 )==-1) {
591
-		LOG(L_ERR, "ERROR: t_send_reply: cannot lookup reply dst: %s\n",
592
-                p_msg->via1->host.s );
593
-		goto error;
594
-	  }
595
-
596
-	T->outbound_response->tl[RETRASMISSIONS_LIST].payload = T->outbound_response;
597
-      	T->outbound_response->tl[FR_TIMER_LIST].payload = T->outbound_response;
598
-      	T->outbound_response->my_T = T;
599
-      	T->status = code;
600
-      	T->outbound_response->bufflen = len ;
601
-      	T->outbound_response->retr_buffer   = (char*)sh_malloc( len );
602
-      	if (!T->outbound_response->retr_buffer) {
603
-		T->outbound_response->retr_buffer = NULL;
604
-		LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem buffer\n");
605
-		goto error;
606
-      	}
607
-      	memcpy( T->outbound_response->retr_buffer , buf , len );
608
-      	free( buf ) ;
605
+   buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
606
+   if (!buf)
607
+   {
608
+      DBG("DEBUG: t_send_reply: response building failed\n");
609
+     goto error;
610
+   }
609 611
 
610
-      /* make sure that if we send something final upstream, everything else will be cancelled */
611
-      if ( code>=300 &&  p_msg->first_line.u.request.method_value==METHOD_INVITE )
612
-         {
612
+   T->outbound_response->bufflen = len ;
613
+   T->outbound_response->retr_buffer   = (char*)sh_malloc( len );
614
+   if (!T->outbound_response->retr_buffer)
615
+   {
616
+      T->outbound_response->retr_buffer = NULL;
617
+      LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem buffer\n");
618
+     goto error;
619
+   }
620
+   memcpy( T->outbound_response->retr_buffer , buf , len );
621
+   free( buf ) ;
622
+
623
+   /* make sure that if we send something final upstream, everything else will be cancelled */
624
+   if ( code>=300 &&  p_msg->first_line.u.request.method_value==METHOD_INVITE )
625
+   {
613 626
             T->outbound_response->timeout_ceiling  = RETR_T2;
614 627
             T->outbound_response->timeout_value    = RETR_T1;
615 628
             remove_from_timer_list( hash_table , &(T->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST );
616 629
             insert_into_timer_list( hash_table , &(T->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST , RETR_T1 );
617 630
             remove_from_timer_list( hash_table , &(T->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST );
618 631
             insert_into_timer_list( hash_table , &(T->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST , FR_TIME_OUT );
619
-         }
620
-      else if (code>=200) t_put_on_wait( p_msg );
632
+   }
633
+   else if (code>=200)
634
+            t_put_on_wait( p_msg );
621 635
 
622
-      t_retransmit_reply( p_msg, 0 , 0);
636
+   t_retransmit_reply( p_msg, 0 , 0);
623 637
 
624
-      return 1;
638
+   return 1;
625 639
 
626 640
 error:
627
-	if (rb) { sh_free(rb); T->outbound_response = rb = NULL;}
628
-	if ( buf ) free ( buf );
629
-	return -1;
641
+   if (rb) { sh_free(rb); T->outbound_response = rb = NULL;}
642
+   if ( buf ) free ( buf );
643
+   return -1;
630 644
 }
631 645
 
632 646
 
... ...
@@ -575,9 +575,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
575 575
 	first_via=1;
576 576
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
577 577
 		if ( hdr->type==HDR_FROM ||
578
-				hdr->type==HDR_CALLID || hdr->type==HDR_TO ||
579
-			(hdr->type==HDR_VIA ?  (first_via ? first_via=0, 0: 1 ) : 0) ||
580
-				hdr->type==HDR_CSEQ )
578
+			hdr->type==HDR_CALLID || hdr->type==HDR_TO ||
579
+			(hdr->type==HDR_VIA || hdr->type==HDR_CSEQ )
581 580
 		{
582 581
 			char *end; int plen;
583 582
 
... ...
@@ -597,11 +596,11 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
597 597
 			p+=CRLF_LEN;
598 598
 		}
599 599
 	memcpy( p, CRLF, CRLF_LEN );
600
-        p+=CRLF_LEN;
600
+	p+=CRLF_LEN;
601 601
 	*(p++) = 0;
602
-	
603 602
 
604
-	/* *returned_len=len; */
603
+
604
+	/* returned_len=len; */
605 605
 	*returned_len=p-buf;
606 606
 	return buf;
607 607
 error: