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 577
       }
585 578
       T->outbound_response = rb;
586 579
       memset( T->outbound_response , 0 , sizeof (struct retrans_buff) );
580
+
581
+      /* initialize retransmission structure */
582
+     if (update_sock_struct_from_via(  &(T->outbound_response->to),  p_msg->via1 )==-1)
583
+      {
584
+         LOG(L_ERR, "ERROR: t_send_reply: cannot lookup reply dst: %s\n",
585
+                  p_msg->via1->host.s );
586
+        goto error;
587
+      }
588
+
589
+      T->outbound_response->tl[RETRASMISSIONS_LIST].payload = T->outbound_response;
590
+      T->outbound_response->tl[FR_TIMER_LIST].payload = T->outbound_response;
591
+      T->outbound_response->my_T = T;
592
+      T->status = code;
593
+
594
+
595
+
587 596
    }
588 597
 
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 ) ;
598
+   buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
599
+   if (!buf)
600
+   {
601
+      DBG("DEBUG: t_send_reply: response building failed\n");
602
+     goto error;
603
+   }
609 604
 
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
-         {
605
+   T->outbound_response->bufflen = len ;
606
+   T->outbound_response->retr_buffer   = (char*)sh_malloc( len );
607
+   if (!T->outbound_response->retr_buffer)
608
+   {
609
+      T->outbound_response->retr_buffer = NULL;
610
+      LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem buffer\n");
611
+     goto error;
612
+   }
613
+   memcpy( T->outbound_response->retr_buffer , buf , len );
614
+   free( buf ) ;
615
+
616
+   /* make sure that if we send something final upstream, everything else will be cancelled */
617
+   if ( code>=300 &&  p_msg->first_line.u.request.method_value==METHOD_INVITE )
618
+   {
613 619
             T->outbound_response->timeout_ceiling  = RETR_T2;
614 620
             T->outbound_response->timeout_value    = RETR_T1;
615 621
             remove_from_timer_list( hash_table , &(T->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST );
616 622
             insert_into_timer_list( hash_table , &(T->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST , RETR_T1 );
617 623
             remove_from_timer_list( hash_table , &(T->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST );
618 624
             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 );
625
+   }
626
+   else if (code>=200)
627
+            t_put_on_wait( p_msg );
621 628
 
622
-      t_retransmit_reply( p_msg, 0 , 0);
629
+   t_retransmit_reply( p_msg, 0 , 0);
623 630
 
624
-      return 1;
631
+   return 1;
625 632
 
626 633
 error:
627
-	if (rb) { sh_free(rb); T->outbound_response = rb = NULL;}
628
-	if ( buf ) free ( buf );
629
-	return -1;
634
+   if (rb) { sh_free(rb); T->outbound_response = rb = NULL;}
635
+   if ( buf ) free ( buf );
636
+   return -1;
630 637
 }
631 638
 
632 639
 
... ...
@@ -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 596
 			p+=CRLF_LEN;
598 597
 		}
599 598
 	memcpy( p, CRLF, CRLF_LEN );
600
-        p+=CRLF_LEN;
599
+	p+=CRLF_LEN;
601 600
 	*(p++) = 0;
602
-	
603 601
 
604
-	/* *returned_len=len; */
602
+
603
+	/* returned_len=len; */
605 604
 	*returned_len=p-buf;
606 605
 	return buf;
607 606
 error: