Browse code

- fix: ser generated ACKs and CANCELs via is built in the same way as the$ INVITE via (when forwarding on tcp, the ACK/CANCEL Via did miss the i=$ param which is added to the INVITE via) Note that by default 2.1 reparses the sent INVITE so this fix is needed only in a non-default config.

Andrei Pelinescu-Onciul authored on 01/10/2007 12:42:54
Showing 2 changed files
... ...
@@ -103,8 +103,13 @@ char *build_local(struct cell *Trans,unsigned int branch,
103 103
 	char branch_buf[MAX_BRANCH_PARAM_LEN];
104 104
 	int branch_len;
105 105
 	str branch_str;
106
+	str via_id;
106 107
 	struct hostport hp;
107 108
 
109
+	/* init */
110
+	via_id.s=0;
111
+	via_id.len=0;
112
+
108 113
 	/* method, separators, version: "CANCEL sip:p2@iptel.org SIP/2.0" */
109 114
 	*len=SIP_VERSION_LEN + method_len + 2 /* spaces */ + CRLF_LEN;
110 115
 	*len+=Trans->uac[branch].uri.len;
... ...
@@ -116,8 +121,29 @@ char *build_local(struct cell *Trans,unsigned int branch,
116 116
 	branch_str.s=branch_buf;
117 117
 	branch_str.len=branch_len;
118 118
 	set_hostport(&hp, (is_local(Trans))?0:(Trans->uas.request));
119
+#ifdef USE_TCP
120
+	if (!is_local(Trans) && ((Trans->uas.request->rcv.proto==PROTO_TCP)
121
+#ifdef USE_TLS
122
+				|| (Trans->uas.request->rcv.proto==PROTO_TLS)
123
+#endif /* USE_TLS */
124
+		)){
125
+		if ((via_id.s=id_builder(Trans->uas.request,
126
+									(unsigned int*)&via_id.len))==0){
127
+			LOG(L_ERR, "ERROR: build_local: id builder failed\n");
128
+			/* try to continue without id */
129
+		}
130
+	}
131
+#endif /* USE_TCP */
119 132
 	via=via_builder(&via_len, &Trans->uac[branch].request.dst,
120
-		&branch_str, 0, &hp );
133
+		&branch_str, via_id.s?&via_id:0 , &hp );
134
+	
135
+	/* via_id.s not needed anylonger => free it */
136
+	if (via_id.s){
137
+		pkg_free(via_id.s);
138
+		via_id.s=0;
139
+		via_id.len=0;
140
+	}
141
+	
121 142
 	if (!via)
122 143
 	{
123 144
 		LOG(L_ERR, "ERROR: build_local: "
... ...
@@ -113,6 +113,8 @@ int branch_builder( unsigned int hash_index,
113 113
 	/* output value: string and actual length */
114 114
 	char *branch_str, int *len );
115 115
 
116
+char* id_builder(struct sip_msg* msg, unsigned int *id_len);
117
+
116 118
 /* check if IP address in Via != source IP address of signaling */
117 119
 int received_test( struct sip_msg *msg );
118 120