Browse code

I can hardly beleive it but I forgot previously to commit change to msg_translator which eliminated RR from local negative replies. Also, I replaced to-tag literal (UGLY :-X) with a define.

Jiri Kuthan authored on 15/11/2002 18:45:10
Showing 2 changed files
... ...
@@ -82,6 +82,9 @@
82 82
 #define RECEIVED   ";received="
83 83
 #define RECEIVED_LEN 10
84 84
 
85
+#define TOTAG ";tag="
86
+#define TOTAG_LEN (sizeof(TOTAG_LEN)-1)
87
+
85 88
 #define SRV_PREFIX "_sip._udp."
86 89
 #define SRV_PREFIX_LEN 10
87 90
 
... ...
@@ -628,26 +628,28 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text,
628 628
 	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ +
629 629
 		strlen(text) + CRLF_LEN/*new line*/;
630 630
 	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
631
-	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
632
-		switch (hdr->type)
633
-		{
634
-			case HDR_TO:
635
-				if (new_tag)
636
-				{
637
-					to_tag=get_to(msg)->tag_value;
638
-					if (to_tag.s )
639
-						len+=new_tag_len-to_tag.len;
640
-					else
641
-						len+=new_tag_len+5/*";tag="*/;
642
-				}
643
-			case HDR_VIA:
631
+	for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) {
632
+		if (hdr->type==HDR_TO) {
633
+			if (new_tag)
634
+			{
635
+				to_tag=get_to(msg)->tag_value;
636
+				if (to_tag.s )
637
+					len+=new_tag_len-to_tag.len;
638
+				else
639
+					len+=new_tag_len+TOTAG_LEN/*";tag="*/;
640
+			}
641
+		} else if (hdr->type==HDR_VIA) {
644 642
 				if (hdr==msg->h_via1) len += received_len;
645
-			case HDR_FROM:
646
-			case HDR_CALLID:
647
-			case HDR_CSEQ:
648
-			case HDR_RECORDROUTE:
649
-				len += ((hdr->body.s+hdr->body.len )-hdr->name.s )+CRLF_LEN;
643
+		} else if (hdr->type==HDR_RECORDROUTE) {
644
+				/* RR only for 1xx and 2xx replies */
645
+				if (code<180 || code>=300) continue;
646
+		} else if (!(hdr->type==HDR_FROM 
647
+					|| hdr->type==HDR_CALLID
648
+					|| hdr->type==HDR_CSEQ)) {
649
+			continue;
650 650
 		}
651
+		len += ((hdr->body.s+hdr->body.len )-hdr->name.s )+CRLF_LEN;
652
+	}
651 653
 	/*lumps length*/
652 654
 	for(lump=msg->reply_lump;lump;lump=lump->next)
653 655
 		len += lump->text.len;
... ...
@@ -709,7 +711,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text,
709 709
 						append_str_trans( p, hdr->name.s ,
710 710
 							((hdr->body.s+hdr->body.len )-hdr->name.s ),
711 711
 							msg);
712
-						append_str( p, ";tag=",5,msg);
712
+						append_str( p, TOTAG,TOTAG_LEN,msg);
713 713
 						append_str( p, new_tag,new_tag_len,msg);
714 714
 						append_str( p, CRLF,CRLF_LEN,msg);
715 715
 					}
... ...
@@ -722,14 +724,16 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text,
722 722
 					append_str( p, received_buf, received_len, msg);
723 723
 				append_str( p, CRLF,CRLF_LEN,msg);
724 724
 				break;
725
+			case HDR_RECORDROUTE:
726
+				/* RR only for 1xx and 2xx replies */
727
+				if (code<180 || code>=300) break;
725 728
 			case HDR_FROM:
726 729
 			case HDR_CALLID:
727 730
 			case HDR_CSEQ:
728
-			case HDR_RECORDROUTE:
729
-				append_str_trans( p, hdr->name.s ,
730
-					((hdr->body.s+hdr->body.len )-hdr->name.s ),msg);
731
-				append_str( p, CRLF,CRLF_LEN,msg);
732
-		}
731
+					append_str_trans( p, hdr->name.s ,
732
+						((hdr->body.s+hdr->body.len )-hdr->name.s ),msg);
733
+					append_str( p, CRLF,CRLF_LEN,msg);
734
+		} /* for switch */
733 735
 	/*lumps*/
734 736
 	for(lump=msg->reply_lump;lump;lump=lump->next)
735 737
 	{