Browse code

topoh: don't encode/decode content for local generated messages

- requests generated by kamailio don't have headers that should be
hidden
- replies to them don't have anything hidden
- update as part of report from FS#390

Daniel-Constantin Mierla authored on 21/02/2014 16:58:19
Showing 1 changed files
... ...
@@ -222,6 +222,13 @@ int th_prepare_msg(sip_msg_t *msg)
222 222
 		return 2;
223 223
 	}
224 224
 
225
+	/* force 2nd via parsing here - it helps checking it later */
226
+	if (parse_headers(msg, HDR_VIA2_F, 0)==-1
227
+		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
228
+	{
229
+		LM_DBG("no second via in this message \n");
230
+	}
231
+
225 232
 	if(parse_from_header(msg)<0)
226 233
 	{
227 234
 		LM_ERR("cannot parse FROM header\n");
... ...
@@ -308,6 +315,13 @@ int th_msg_received(void *data)
308 315
 		}
309 316
 	} else {
310 317
 		/* reply */
318
+		if(msg.via2==0)
319
+		{
320
+			/* one Via in received reply -- it is for local generated request
321
+			 * - nothing to unhide */
322
+			goto done;
323
+		}
324
+
311 325
 		th_unmask_via(&msg, &th_cookie_value);
312 326
 		th_flip_record_route(&msg, 0);
313 327
 		if(th_cookie_value.s[0]=='u')
... ...
@@ -371,6 +385,12 @@ int th_msg_sent(void *data)
371 385
 		th_del_cookie(&msg);
372 386
 	if(msg.first_line.type==SIP_REQUEST)
373 387
 	{
388
+		if(msg.via2==0)
389
+		{
390
+			/* one Via in request sent out -- it is local generated
391
+			 * - nothing to hide */
392
+			goto done;
393
+		}
374 394
 		direction = (th_cookie_value.s[0]=='u')?1:0; /* upstream/downstram */
375 395
 		dialog = (get_to(&msg)->tag_value.len>0)?1:0;
376 396
 		local = (th_cookie_value.s[0]!='d'&&th_cookie_value.s[0]!='u')?1:0;