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 121
 	branch_str.s=branch_buf;
117 122
 	branch_str.len=branch_len;
118 123
 	set_hostport(&hp, (is_local(Trans))?0:(Trans->uas.request));
124
+#ifdef USE_TCP
125
+	if (!is_local(Trans) && ((Trans->uas.request->rcv.proto==PROTO_TCP)
126
+#ifdef USE_TLS
127
+				|| (Trans->uas.request->rcv.proto==PROTO_TLS)
128
+#endif /* USE_TLS */
129
+		)){
130
+		if ((via_id.s=id_builder(Trans->uas.request,
131
+									(unsigned int*)&via_id.len))==0){
132
+			LOG(L_ERR, "ERROR: build_local: id builder failed\n");
133
+			/* try to continue without id */
134
+		}
135
+	}
136
+#endif /* USE_TCP */
119 137
 	via=via_builder(&via_len, &Trans->uac[branch].request.dst,
120
-		&branch_str, 0, &hp );
138
+		&branch_str, via_id.s?&via_id:0 , &hp );
139
+	
140
+	/* via_id.s not needed anylonger => free it */
141
+	if (via_id.s){
142
+		pkg_free(via_id.s);
143
+		via_id.s=0;
144
+		via_id.len=0;
145
+	}
146
+	
121 147
 	if (!via)
122 148
 	{
123 149
 		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