Browse code

- warning fixes (icc)

Andrei Pelinescu-Onciul authored on 12/11/2003 18:11:20
Showing 3 changed files
... ...
@@ -413,7 +413,6 @@ static int faked_env(struct sip_msg *fake,
413 413
 	/* set items, which will be duped to pkg_mem, to zero, so that
414 414
 	 * "restore" called on error does not free the original items */
415 415
 	fake->add_rm=0;
416
-	fake->body_lumps=0;
417 416
 	fake->new_uri.s=0; fake->new_uri.len=0; 
418 417
 
419 418
 	/* remember we are back in request processing, but process
... ...
@@ -460,22 +459,12 @@ static int faked_env(struct sip_msg *fake,
460 460
 			goto restore;
461 461
 		}
462 462
 	}
463
-
464
-	if (shmem_msg->body_lumps) {
465
-		fake->body_lumps=dup_lump_list(shmem_msg->body_lumps);
466
-		if (!fake->body_lumps) { /* non_empty->empty ... failure */
467
-			LOG(L_ERR, "ERROR: on_negative_reply: lump dup failed\n");
468
-			goto restore;
469
-		}
470
-	}
471
-	
472 463
 	/* success */
473 464
 	return 1;
474 465
 
475 466
 restore:
476 467
 	/* restore original environment and destroy faked message */
477 468
 	free_duped_lump_list(fake->add_rm);
478
-	free_duped_lump_list(fake->body_lumps);
479 469
 	if (fake->new_uri.s) pkg_free(fake->new_uri.s);
480 470
 	set_t(backup_t);
481 471
 	global_msg_id=backup_msgid;
... ...
@@ -1211,7 +1200,7 @@ int t_reply_with_body( struct cell *trans, unsigned int code,
1211 1211
 
1212 1212
 	rpl.s = build_res_buf_from_sip_req(
1213 1213
 			code, text, &s_to_tag,
1214
-			trans->uas.request, &rpl.len, &bm);
1214
+			trans->uas.request, (unsigned int*)&rpl.len, &bm);
1215 1215
 
1216 1216
 	/* since the msg (trans->uas.request) is a clone into shm memory, to avoid
1217 1217
 	 * memory leak or crashing (lumps are create in private memory) I will
... ...
@@ -53,8 +53,7 @@
53 53
  *             build_req_fomr_sip_req no longer adds 1 for ipv6 via parameter
54 54
  *              position calculations ([] are part of host.s now) (andrei)
55 55
  * 2003-10-02  via+lump dst address/port can be set to preset values (andrei)
56
- * 2003-10-08  receive_test function-alized (jiri)
57
- * 2003-10-20  added body_lump list (sip_msg), adjust_clen (andrei & jan)
56
+ * 2003-10-08 receive_test function-alized (jiri)
58 57
  *
59 58
  */
60 59
 /* Via special params:
... ...
@@ -122,7 +121,6 @@
122 122
 #include "dprint.h"
123 123
 #include "config.h"
124 124
 #include "md5utils.h"
125
-#include "data_lump.h"
126 125
 #include "data_lump_rpl.h"
127 126
 #include "ip_addr.h"
128 127
 #include "resolve.h"
... ...
@@ -218,11 +216,15 @@ static int check_via_address(struct ip_addr* ip, str *name,
218 218
 /* check if IP address in Via != source IP address of signaling */
219 219
 int received_test( struct sip_msg *msg )
220 220
 {
221
+	char backup;
221 222
 	int rcvd;
222 223
 
224
+	/* zero-terminate hostname temporarily in case DNS resolver is used */
225
+	backup = msg->via1->host.s[msg->via1->host.len];
223 226
 	rcvd=msg->via1->received
224 227
 			|| check_via_address(&msg->rcv.src_ip, &msg->via1->host,
225 228
 							msg->via1->port, received_dns);
229
+	msg->via1->host.s[msg->via1->host.len] = backup;
226 230
 	return rcvd;
227 231
 }
228 232
 
... ...
@@ -392,7 +394,7 @@ char* id_builder(struct sip_msg* msg, unsigned int *id_len)
392 392
 
393 393
 
394 394
 
395
-char* clen_builder(struct sip_msg* msg, unsigned int *clen_len, int diff)
395
+char* clen_builder(struct sip_msg* msg, unsigned int *clen_len)
396 396
 {
397 397
 	char* buf;
398 398
 	int len;
... ...
@@ -409,7 +411,7 @@ char* clen_builder(struct sip_msg* msg, unsigned int *clen_len, int diff)
409 409
 					" (missing crlf?)");
410 410
 		return 0;
411 411
 	}
412
-	value=msg->len-(int)(body-msg->buf)+diff;
412
+	value=msg->len-(int)(body-msg->buf);
413 413
 	value_s=int2str(value, &value_len);
414 414
 	DBG("clen_builder: content-length: %d (%s)\n", value, value_s);
415 415
 		
... ...
@@ -497,7 +499,7 @@ static inline int lump_check_opt(	enum lump_conditions cond,
497 497
 
498 498
 /* computes the "unpacked" len of a lump list,
499 499
    code moved from build_req_from_req */
500
-static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, struct socket_info* send_sock)
500
+static inline int lumps_len(struct sip_msg* msg, struct socket_info* send_sock)
501 501
 {
502 502
 	int s_offset;
503 503
 	int new_len;
... ...
@@ -670,7 +672,7 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, struct sock
670 670
 		send_port_str=&(send_sock->port_no_str);
671 671
 	
672 672
 	
673
-	for(t=lumps;t;t=t->next){
673
+	for(t=msg->add_rm;t;t=t->next){
674 674
 		/* skip if this is an OPT lump and the condition is not satisfied */
675 675
 		if ((t->op==LUMP_ADD_OPT) && !lump_check_opt(t->u.cond, msg, send_sock))
676 676
 			continue;
... ...
@@ -761,8 +763,7 @@ skip_after:
761 761
 /* another helper functions, adds/Removes the lump,
762 762
 	code moved form build_req_from_req  */
763 763
 
764
-static inline void process_lumps(	struct sip_msg* msg,
765
-					                                struct lump* lumps,
764
+static inline void process_lumps(	struct sip_msg* msg,	
766 765
 									char* new_buf, 
767 766
 									unsigned int* new_buf_offs, 
768 767
 									unsigned int* orig_offs,
... ...
@@ -1026,7 +1027,7 @@ static inline void process_lumps(	struct sip_msg* msg,
1026 1026
 	offset=*new_buf_offs;
1027 1027
 	s_offset=*orig_offs;
1028 1028
 	
1029
-	for (t=lumps;t;t=t->next){
1029
+	for (t=msg->add_rm;t;t=t->next){
1030 1030
 		switch(t->op){
1031 1031
 			case LUMP_ADD:
1032 1032
 			case LUMP_ADD_SUBST:
... ...
@@ -1183,109 +1184,12 @@ skip_nop_after:
1183 1183
 }
1184 1184
 
1185 1185
 
1186
-/*
1187
- * Adjust/insert Content-Length if necesarry
1188
- */
1189
-static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1190
-{
1191
-	struct lump* anchor;
1192
-	char* clen_buf;
1193
-	int clen_len;
1194
-
1195
-	/* Calculate message length difference caused by lumps modifying message
1196
-	 * body, from this point on the message body must not be modified. Zero
1197
-	 * value indicates that the body hasn't been modified
1198
-	*/
1199
-
1200
-	clen_buf = 0;
1201
-	anchor=0;
1202
-	
1203
-	/* check to see if we need to add clen */
1204
-#ifdef USE_TCP
1205
-	if (proto == PROTO_TCP
1206
-#ifdef USE_TLS
1207
-	    || proto == PROTO_TLS
1208
-#endif
1209
-	    ) {
1210
-		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
1211
-			LOG(L_ERR, "adjust_clen: error parsing content-length\n");
1212
-			goto error;
1213
-		}
1214
-		if (msg->content_length==0){
1215
-			/* not present, we need to add it */
1216
-			/* msg->unparsed should point just before the final crlf
1217
-			 * - whole message was parsed by the above parse_headers
1218
-			 *   which did not find content-length */
1219
-			anchor=anchor_lump(msg, msg->unparsed-msg->buf, 0,
1220
-												HDR_CONTENTLENGTH);
1221
-			if (anchor==0){
1222
-				LOG(L_ERR, "adjust_clen: cannot set clen anchor\n");
1223
-				goto error;
1224
-			}
1225
-		}
1226
-	}
1227
-#endif
1228
-	
1229
-	
1230
-	if ((anchor==0) && body_delta){
1231
-		if (parse_headers(msg, HDR_CONTENTLENGTH, 0) == -1) {
1232
-			LOG(L_ERR, "adjust_clen: Error parsing Content-Length\n");
1233
-			goto error;
1234
-		}
1235
-		
1236
-		/* The body has been changed, try to find
1237
-		 * existing Content-Length
1238
-		 */
1239
-		/* no need for Content-Length if it's and UDP packet and
1240
-		 * it hasn't Content-Lentgh already */
1241
-		if ((msg->content_length==0)){
1242
-		    /* content-length doesn't exist, append it */
1243
-			/* msg->unparsed should point just before the final crlf
1244
-			 * - whole message was parsed by the above parse_headers
1245
-			 *   which did not find content-length */
1246
-			if (proto!=PROTO_UDP){
1247
-				anchor=anchor_lump(msg, msg->unparsed-msg->buf, 0,
1248
-													HDR_CONTENTLENGTH);
1249
-				if (anchor==0){
1250
-					LOG(L_ERR, "adjust_clen: cannot set clen anchor\n");
1251
-					goto error;
1252
-				}
1253
-			}else{
1254
-				DBG("add_clen: UDP packet with no clen => not adding one \n");
1255
-			}
1256
-		}else{
1257
-			/* Content-Length has been found, remove it */
1258
-			anchor = del_lump(	msg, msg->content_length->name.s - msg->buf,
1259
-								msg->content_length->len, HDR_CONTENTLENGTH);
1260
-			if (anchor==0) {
1261
-				LOG(L_ERR, "adjust_clen: Can't remove original"
1262
-							" Content-Length\n");
1263
-				goto error;
1264
-			}
1265
-		}
1266
-	}
1267
-	
1268
-	if (anchor){
1269
-		clen_buf = clen_builder(msg, &clen_len, body_delta);
1270
-		if (!clen_buf) goto error;
1271
-		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1272
-					HDR_CONTENTLENGTH) == 0)
1273
-			goto error;
1274
-	}
1275
-
1276
-	return 0;
1277
-error:
1278
-	if (clen_buf) pkg_free(clen_buf);
1279
-	return -1;
1280
-}
1281
-
1282
-
1283 1186
 
1284 1187
 char * build_req_buf_from_sip_req( struct sip_msg* msg,
1285 1188
 								unsigned int *returned_len,
1286 1189
 								struct socket_info* send_sock, int proto)
1287 1190
 {
1288
-	unsigned int len, new_len, received_len, rport_len, uri_len, via_len, body_delta;
1191
+	unsigned int len, new_len, received_len, rport_len, uri_len, via_len;
1289 1192
 	char* line_buf;
1290 1193
 	char* received_buf;
1291 1194
 	char* rport_buf;
... ...
@@ -1297,14 +1201,18 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1297 1297
 	str branch;
1298 1298
 	str extra_params;
1299 1299
 	struct hostport hp;
1300
-
1300
+	
1301 1301
 #ifdef USE_TCP
1302 1302
 	char* id_buf;
1303 1303
 	unsigned int id_len;
1304
+	char* clen_buf;
1305
+	unsigned int clen_len;
1304 1306
 	
1305 1307
 	
1306 1308
 	id_buf=0;
1307 1309
 	id_len=0;
1310
+	clen_buf=0;
1311
+	clen_len=0;
1308 1312
 #endif
1309 1313
 	via_insert_param=0;
1310 1314
 	extra_params.len=0;
... ...
@@ -1318,6 +1226,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1318 1318
 	received_buf=0;
1319 1319
 	rport_buf=0;
1320 1320
 	line_buf=0;
1321
+
1321 1322
 	
1322 1323
 #ifdef USE_TCP
1323 1324
 	/* add id if tcp */
... ...
@@ -1337,17 +1246,31 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1337 1337
 		extra_params.s=id_buf;
1338 1338
 		extra_params.len=id_len;
1339 1339
 	}
1340
+	/* if sending proto == tcp, check if Content-Length needs to be added*/
1341
+	if (proto==PROTO_TCP
1342
+#ifdef USE_TLS
1343
+			|| proto==PROTO_TLS
1340 1344
 #endif
1341
-	     /* Calculate message body difference and adjust
1342
-	      * Content-Length
1343
-	      */
1344
-	body_delta = lumps_len(msg, msg->body_lumps, send_sock);
1345
-	if (adjust_clen(msg, body_delta, proto) < 0) {
1346
-		LOG(L_ERR, "ERROR: build_req_buf_from_sip_req: Error while adjusting"
1347
-				" Content-Length\n");
1348
-		goto error00;
1345
+			){
1346
+		DBG("build_req_from_req: checking for clen; proto=%d,"
1347
+			" rcv->proto=%d\n", proto, msg->rcv.proto);
1348
+		/* first of all parse content-length */
1349
+		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
1350
+			LOG(L_ERR, "build_req_buf_from_sip_req:"
1351
+							" error parsing content-length\n");
1352
+			goto skip_clen;
1353
+		}
1354
+		if (msg->content_length==0){
1355
+			/* we need to add it */
1356
+			if ((clen_buf=clen_builder(msg, &clen_len))==0){
1357
+				LOG(L_ERR, "build_req_buf_from_sip_req:" 
1358
+								" clen_builder failed\n");
1359
+				goto skip_clen;
1360
+			}
1361
+		}
1349 1362
 	}
1350
-
1363
+skip_clen:
1364
+#endif
1351 1365
 	branch.s=msg->add_to_branch_s;
1352 1366
 	branch.len=msg->add_to_branch_len;
1353 1367
 	set_hostport(&hp, msg);
... ...
@@ -1383,7 +1306,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1383 1383
 	/* add via header to the list */
1384 1384
 	/* try to add it before msg. 1st via */
1385 1385
 	/* add first via, as an anchor for second via*/
1386
-	anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA);
1386
+	anchor=anchor_lump(&(msg->add_rm), msg->via1->hdr.s-buf, 0, HDR_VIA);
1387 1387
 	if (anchor==0) goto error01;
1388 1388
 	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
1389 1389
 		goto error01;
... ...
@@ -1409,11 +1332,11 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1409 1409
 	 * overwrite the previous one if already present */
1410 1410
 	if (received_len){
1411 1411
 		if (msg->via1->received){ /* received already present => overwrite it*/
1412
-			via_insert_param=del_lump(msg,
1412
+			via_insert_param=del_lump(&(msg->add_rm),
1413 1413
 								msg->via1->received->start-buf-1, /*;*/
1414 1414
 								msg->via1->received->size+1, /*;*/ HDR_VIA);
1415 1415
 		}else if (via_insert_param==0){ /* receive not present, ok */
1416
-			via_insert_param=anchor_lump(msg,
1416
+			via_insert_param=anchor_lump(&(msg->add_rm),
1417 1417
 										msg->via1->hdr.s-buf+size,0, HDR_VIA);
1418 1418
 		}
1419 1419
 		if (via_insert_param==0) goto error02; /* free received_buf */
... ...
@@ -1423,12 +1346,12 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1423 1423
 	/* if rport needs to be updated, delete it if present and add it's value */
1424 1424
 	if (rport_len){
1425 1425
 		if (msg->via1->rport){ /* rport already present */
1426
-			via_insert_param=del_lump(msg,
1426
+			via_insert_param=del_lump(&(msg->add_rm),
1427 1427
 								msg->via1->rport->start-buf-1, /*';'*/
1428 1428
 								msg->via1->rport->size+1 /* ; */, HDR_VIA);
1429 1429
 		}else if (via_insert_param==0){ /*force rport, no rport present */
1430 1430
 			/* no rport, add it */
1431
-			via_insert_param=anchor_lump(msg,
1431
+			via_insert_param=anchor_lump(&(msg->add_rm),
1432 1432
 										msg->via1->hdr.s-buf+size,0, HDR_VIA);
1433 1433
 		}
1434 1434
 		if (via_insert_param==0) goto error03; /* free rport_buf */
... ...
@@ -1437,9 +1360,22 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1437 1437
 			goto error03; /* free rport_buf */
1438 1438
 			
1439 1439
 	}
1440
+#ifdef USE_TCP
1441
+	/* if clen needs to be added, add it */
1442
+	if (clen_len){
1443
+		/* msg->unparsed should point just before the final crlf,
1444
+		 * parse_headers is called from clen_builder */
1445
+		anchor=anchor_lump(&(msg->add_rm), msg->unparsed-buf, 0,
1446
+							 HDR_CONTENTLENGTH);
1447
+		if (anchor==0) goto error04; /* free clen_buf */
1448
+		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1449
+					HDR_CONTENTLENGTH)==0)
1450
+			goto error04; /* free clen_buf*/
1451
+	}
1452
+#endif
1440 1453
 
1441 1454
 	/* compute new msg len and fix overlapping zones*/
1442
-	new_len=len+body_delta+lumps_len(msg, msg->add_rm, send_sock);
1455
+	new_len=len+lumps_len(msg, send_sock);
1443 1456
 #ifdef XL_DEBUG
1444 1457
 	LOG(L_ERR, "DEBUG: new_len(%d)=len(%d)+lumps_len\n", new_len, len);
1445 1458
 #endif
... ...
@@ -1469,8 +1405,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1469 1469
 	}
1470 1470
 	new_buf[new_len]=0;
1471 1471
 	/* copy msg adding/removing lumps */
1472
-	process_lumps(msg, msg->add_rm, new_buf, &offset, &s_offset, send_sock);
1473
-	process_lumps(msg, msg->body_lumps, new_buf, &offset, &s_offset,send_sock);
1472
+	process_lumps(msg, new_buf, &offset, &s_offset, send_sock);
1474 1473
 	/* copy the rest of the message */
1475 1474
 	memcpy(new_buf+offset, buf+s_offset, len-s_offset);
1476 1475
 	new_buf[new_len]=0;
... ...
@@ -1496,6 +1431,10 @@ error02:
1496 1496
 	if (received_buf) pkg_free(received_buf);
1497 1497
 error03:
1498 1498
 	if (rport_buf) pkg_free(rport_buf);
1499
+#ifdef USE_TCP
1500
+error04:
1501
+	if (clen_buf) pkg_free(clen_buf);
1502
+#endif
1499 1503
 error00:
1500 1504
 #ifdef USE_TCP
1501 1505
 	if (id_buf) pkg_free(id_buf);
... ...
@@ -1509,12 +1448,19 @@ error00:
1509 1509
 char * build_res_buf_from_sip_res( struct sip_msg* msg,
1510 1510
 				unsigned int *returned_len)
1511 1511
 {
1512
-	unsigned int new_len, via_len, body_delta;
1512
+	unsigned int new_len, via_len;
1513 1513
 	char* new_buf;
1514 1514
 	unsigned offset, s_offset, via_offset;
1515 1515
 	char* buf;
1516 1516
 	unsigned int len;
1517
-
1517
+#ifdef USE_TCP
1518
+	struct lump* anchor;
1519
+	char* clen_buf;
1520
+	unsigned int clen_len;
1521
+	
1522
+	clen_buf=0;
1523
+	clen_len=0;
1524
+#endif
1518 1525
 	buf=msg->buf;
1519 1526
 	len=msg->len;
1520 1527
 	new_buf=0;
... ...
@@ -1527,26 +1473,57 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
1527 1527
 		via_offset=msg->h_via1->name.s-buf;
1528 1528
 	}
1529 1529
 
1530
-	     /* Calculate message body difference and adjust
1531
-	      * Content-Length
1532
-	      */
1533
-	body_delta = lumps_len(msg, msg->body_lumps, 0);
1534
-	if (adjust_clen(msg, body_delta, (msg->via2? msg->via2->proto:PROTO_UDP))
1535
-			< 0) {
1536
-		LOG(L_ERR, "ERROR: build_req_buf_from_sip_req: Error while adjusting"
1537
-				" Content-Length\n");
1538
-		goto error;
1539
-	}
1530
+#ifdef USE_TCP
1540 1531
 
1532
+	/* if sending proto == tcp, check if Content-Length needs to be added*/
1533
+	if (msg->via2 && ((msg->via2->proto==PROTO_TCP)
1534
+#ifdef USE_TLS
1535
+				|| (msg->via2->proto==PROTO_TLS)
1536
+#endif
1537
+				)){
1538
+		DBG("build_res_from_sip_res: checking content-length for \n%.*s\n",
1539
+				(int)msg->len, msg->buf);
1540
+		/* first of all parse content-length */
1541
+		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
1542
+			LOG(L_ERR, "build_res_buf_from_sip_res:"
1543
+							" error parsing content-length\n");
1544
+			goto skip_clen;
1545
+		}
1546
+		if (msg->content_length==0){
1547
+			DBG("build_res_from_sip_res: no content_length hdr found\n");
1548
+			/* we need to add it */
1549
+			if ((clen_buf=clen_builder(msg, &clen_len))==0){
1550
+				LOG(L_ERR, "build_res_buf_from_sip_res:" 
1551
+								" clen_builder failed\n");
1552
+				goto skip_clen;
1553
+			}
1554
+		}
1555
+	}
1556
+skip_clen:
1557
+#endif
1558
+	
1541 1559
 	/* remove the first via*/
1542
-	if (del_lump( msg, via_offset, via_len, HDR_VIA)==0){
1560
+	if (del_lump( &(msg->add_rm), via_offset, via_len, HDR_VIA)==0){
1543 1561
 		LOG(L_ERR, "build_res_buf_from_sip_res: error trying to remove first"
1544 1562
 					"via\n");
1545 1563
 		goto error;
1546 1564
 	}
1547
-
1548
-	new_len=len+body_delta+lumps_len(msg, msg->add_rm, 0); /*FIXME: we don't
1549
-														know the send sock */
1565
+#ifdef USE_TCP
1566
+	/* if clen needs to be added, add it */
1567
+	if (clen_len){
1568
+		/* msg->unparsed should point just before the final crlf,
1569
+		 * parse_headers is called from clen_builder */
1570
+		anchor=anchor_lump(&(msg->add_rm), msg->unparsed-buf, 0, 
1571
+							HDR_CONTENTLENGTH);
1572
+		DBG("build_res_from_sip_res: adding content-length: %.*s\n",
1573
+				(int)clen_len, clen_buf);
1574
+		if (anchor==0) goto error_clen; /* free clen_buf*/
1575
+		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1576
+					HDR_CONTENTLENGTH)==0)
1577
+			goto error_clen; /* free clen_buf*/
1578
+	}
1579
+#endif
1580
+	new_len=len+lumps_len(msg, 0); /*FIXME: we don't know the send sock */
1550 1581
 	
1551 1582
 	DBG(" old size: %d, new size: %d\n", len, new_len);
1552 1583
 	new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging 
... ...
@@ -1557,9 +1534,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
1557 1557
 	}
1558 1558
 	new_buf[new_len]=0; /* debug: print the message */
1559 1559
 	offset=s_offset=0;
1560
-	/*FIXME: no send sock*/
1561
-	process_lumps(msg, msg->add_rm, new_buf, &offset, &s_offset, 0);/*FIXME:*/
1562
-	process_lumps(msg, msg->body_lumps, new_buf, &offset, &s_offset, 0);
1560
+	process_lumps(msg, new_buf, &offset, &s_offset, 0); /*FIXME: no send sock*/
1563 1561
 	/* copy the rest of the message */
1564 1562
 	memcpy(new_buf+offset,
1565 1563
 		buf+s_offset, 
... ...
@@ -1570,6 +1545,10 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
1570 1570
 
1571 1571
 	*returned_len=new_len;
1572 1572
 	return new_buf;
1573
+#ifdef USE_TCP
1574
+error_clen:
1575
+	if (clen_buf) pkg_free(clen_buf);
1576
+#endif
1573 1577
 error:
1574 1578
 	*returned_len=0;
1575 1579
 	return 0;
... ...
@@ -1585,10 +1564,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1585 1585
 	struct lump_rpl   *lump;
1586 1586
 	struct lump_rpl   *body;
1587 1587
 	int               i;
1588
-	str               received = {0,0};
1589
-	str               rport = {0,0};
1590
-	str               warning = {0,0};
1591
-	str               content_len = {0,0};
1588
+	char*             received_buf;
1589
+	unsigned int      received_len;
1590
+	char*             rport_buf;
1591
+	unsigned int      rport_len;
1592
+	char*             warning_buf;
1593
+	unsigned int      warning_len;
1594
+	char*             content_len_buf;
1595
+	unsigned int      content_len_len;
1592 1596
 	unsigned int      text_len;
1593 1597
 	char *after_body;
1594 1598
 	str  to_tag;
... ...
@@ -1596,9 +1579,11 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1596 1596
 
1597 1597
 	body = 0;
1598 1598
 	buf=0;
1599
-
1599
+	received_buf=rport_buf=warning_buf=content_len_buf=0;
1600
+	received_len=rport_len=warning_len=content_len_len=0;
1601
+	
1600 1602
 	text_len=strlen(text);
1601
-
1603
+	
1602 1604
 	/* force parsing all headers -- we want to return all
1603 1605
 	Via's in the reply and they may be scattered down to the
1604 1606
 	end of header (non-block Vias are a really poor property
... ...
@@ -1614,7 +1599,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1614 1614
 
1615 1615
 	/* check if received needs to be added */
1616 1616
 	if (received_test(msg)) {
1617
-		if ((received.s=received_builder(msg,&received.len))==0) {
1617
+		if ((received_buf=received_builder(msg,&received_len))==0) {
1618 1618
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
1619 1619
 				"alas, received_builder failed\n");
1620 1620
 			goto error00;
... ...
@@ -1623,7 +1608,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1623 1623
 	/* check if rport needs to be updated */
1624 1624
 	if ( (msg->msg_flags&FL_FORCE_RPORT)||
1625 1625
 		(msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
1626
-		if ((rport.s=rport_builder(msg, &rport.len))==0){
1626
+		if ((rport_buf=rport_builder(msg, &rport_len))==0){
1627 1627
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req:"
1628 1628
 							" rport_builder failed\n");
1629 1629
 			goto error01; /* free everything */
... ...
@@ -1651,7 +1636,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1651 1651
 			case HDR_VIA:
1652 1652
 				/* we always add CRLF to via*/
1653 1653
 				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
1654
-				if (hdr==msg->h_via1) len += received.len+rport.len;
1654
+				if (hdr==msg->h_via1) len += received_len+rport_len;
1655 1655
 				break;
1656 1656
 			case HDR_RECORDROUTE:
1657 1657
 				/* RR only for 1xx and 2xx replies */
... ...
@@ -1675,14 +1660,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1675 1675
 		len += SERVER_HDR_LEN + CRLF_LEN;
1676 1676
 	/* warning hdr */
1677 1677
 	if (sip_warning) {
1678
-		warning.s = warning_builder(msg,&warning.len);
1679
-		if (warning.s) len += warning.len + CRLF_LEN;
1678
+		warning_buf = warning_builder(msg,&warning_len);
1679
+		if (warning_buf) len += warning_len + CRLF_LEN;
1680 1680
 		else LOG(L_WARN, "WARNING: warning skipped -- too big\n");
1681 1681
 	}
1682 1682
 	/* content length hdr */
1683 1683
 	if (body) {
1684
-		content_len.s = int2str(body->text.len, &content_len.len);
1685
-		len += CONTENT_LENGTH_LEN + content_len.len + CRLF_LEN;
1684
+		content_len_buf = int2str(body->text.len, (int*)&content_len_len);
1685
+		len += CONTENT_LENGTH_LEN + content_len_len + CRLF_LEN;
1686 1686
 	} else {
1687 1687
 		len += CONTENT_LENGTH_LEN + 1/*0*/ + CRLF_LEN;
1688 1688
 	}
... ...
@@ -1719,13 +1704,13 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1719 1719
 		{
1720 1720
 			case HDR_VIA:
1721 1721
 				if (hdr==msg->h_via1){
1722
-					if (rport.s){
1722
+					if (rport_buf){
1723 1723
 						if (msg->via1->rport){ /* delete the old one */
1724 1724
 							/* copy until rport */
1725 1725
 							append_str_trans( p, hdr->name.s ,
1726 1726
 								msg->via1->rport->start-hdr->name.s-1,msg);
1727 1727
 							/* copy new rport */
1728
-							append_str(p, rport.s, rport.len);
1728
+							append_str(p, rport_buf, rport_len);
1729 1729
 							/* copy the rest of the via */
1730 1730
 							append_str_trans(p, msg->via1->rport->start+
1731 1731
 												msg->via1->rport->size, 
... ...
@@ -1736,15 +1721,15 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1736 1736
 							/* normal whole via copy */
1737 1737
 							append_str_trans( p, hdr->name.s , 
1738 1738
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
1739
-							append_str(p, rport.s, rport.len);
1739
+							append_str(p, rport_buf, rport_len);
1740 1740
 						}
1741 1741
 					}else{
1742 1742
 						/* normal whole via copy */
1743 1743
 						append_str_trans( p, hdr->name.s , 
1744 1744
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
1745 1745
 					}
1746
-					if (received.s)
1747
-						append_str( p, received.s, received.len);
1746
+					if (received_buf)
1747
+						append_str( p, received_buf, received_len);
1748 1748
 				}else{
1749 1749
 					/* normal whole via copy */
1750 1750
 					append_str_trans( p, hdr->name.s,
... ...
@@ -1807,17 +1792,17 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1807 1807
 		p+=CRLF_LEN;
1808 1808
 	}
1809 1809
 	/* content_length hdr */
1810
-	if (content_len.len) {
1810
+	if (content_len_len) {
1811 1811
 		append_str( p, CONTENT_LENGTH, CONTENT_LENGTH_LEN);
1812
-		append_str( p, content_len.s, content_len.len );
1812
+		append_str( p, content_len_buf, content_len_len );
1813 1813
 		append_str( p, CRLF, CRLF_LEN );
1814 1814
 	} else {
1815 1815
 		append_str( p, CONTENT_LENGTH"0"CRLF,CONTENT_LENGTH_LEN+1+CRLF_LEN);
1816 1816
 	}
1817 1817
 	/* warning header */
1818
-	if (warning.s) {
1819
-		memcpy( p, warning.s, warning.len);
1820
-		p+=warning.len;
1818
+	if (warning_buf) {
1819
+		memcpy( p, warning_buf, warning_len);
1820
+		p+=warning_len;
1821 1821
 		memcpy( p, CRLF, CRLF_LEN);
1822 1822
 		p+=CRLF_LEN;
1823 1823
 	}
... ...
@@ -1838,13 +1823,13 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1838 1838
 	/* in req2reply, received_buf is not introduced to lumps and
1839 1839
 	   needs to be deleted here
1840 1840
 	*/
1841
-	if (received.s) pkg_free(received.s);
1842
-	if (rport.s) pkg_free(rport.s);
1841
+	if (received_buf) pkg_free(received_buf);
1842
+	if (rport_buf) pkg_free(rport_buf);
1843 1843
 	return buf;
1844 1844
 
1845 1845
 error01:
1846
-	if (received.s) pkg_free(received.s);
1847
-	if (rport.s) pkg_free(rport.s);
1846
+	if (received_buf) pkg_free(received_buf);
1847
+	if (rport_buf) pkg_free(rport_buf);
1848 1848
 error00:
1849 1849
 	*returned_len=0;
1850 1850
 	return 0;
... ...
@@ -263,7 +263,7 @@ int parse_content_type_hdr( struct sip_msg *msg )
263 263
 {
264 264
 	char *end;
265 265
 	char *ret;
266
-	int  mime;
266
+	unsigned int  mime;
267 267
 
268 268
 	/* is the header already found? */
269 269
 	if ( msg->content_type==0 ) {
... ...
@@ -297,7 +297,7 @@ int parse_content_type_hdr( struct sip_msg *msg )
297 297
 		goto error;
298 298
 	}
299 299
 
300
-	msg->content_type->parsed = (void*)(long)mime;
300
+	msg->content_type->parsed = (void*)(unsigned long)mime;
301 301
 	return mime;
302 302
 
303 303
 error:
... ...
@@ -311,9 +311,9 @@ error:
311 311
  *          = -1 error */
312 312
 int parse_accept_hdr( struct sip_msg *msg )
313 313
 {
314
-	static int mimes[MAX_MIMES_NR];
314
+	static unsigned int mimes[MAX_MIMES_NR];
315 315
 	int nr_mimes;
316
-	int mime;
316
+	unsigned int mime;
317 317
 	char *end;
318 318
 	char *ret;
319 319