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 459
 			goto restore;
461 460
 		}
462 461
 	}
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 462
 	/* success */
473 463
 	return 1;
474 464
 
475 465
 restore:
476 466
 	/* restore original environment and destroy faked message */
477 467
 	free_duped_lump_list(fake->add_rm);
478
-	free_duped_lump_list(fake->body_lumps);
479 468
 	if (fake->new_uri.s) pkg_free(fake->new_uri.s);
480 469
 	set_t(backup_t);
481 470
 	global_msg_id=backup_msgid;
... ...
@@ -1211,7 +1200,7 @@ int t_reply_with_body( struct cell *trans, unsigned int code,
1211 1200
 
1212 1201
 	rpl.s = build_res_buf_from_sip_req(
1213 1202
 			code, text, &s_to_tag,
1214
-			trans->uas.request, &rpl.len, &bm);
1203
+			trans->uas.request, (unsigned int*)&rpl.len, &bm);
1215 1204
 
1216 1205
 	/* since the msg (trans->uas.request) is a clone into shm memory, to avoid
1217 1206
 	 * 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 121
 #include "dprint.h"
123 122
 #include "config.h"
124 123
 #include "md5utils.h"
125
-#include "data_lump.h"
126 124
 #include "data_lump_rpl.h"
127 125
 #include "ip_addr.h"
128 126
 #include "resolve.h"
... ...
@@ -218,11 +216,15 @@ static int check_via_address(struct ip_addr* ip, str *name,
218 216
 /* check if IP address in Via != source IP address of signaling */
219 217
 int received_test( struct sip_msg *msg )
220 218
 {
219
+	char backup;
221 220
 	int rcvd;
222 221
 
222
+	/* zero-terminate hostname temporarily in case DNS resolver is used */
223
+	backup = msg->via1->host.s[msg->via1->host.len];
223 224
 	rcvd=msg->via1->received
224 225
 			|| check_via_address(&msg->rcv.src_ip, &msg->via1->host,
225 226
 							msg->via1->port, received_dns);
227
+	msg->via1->host.s[msg->via1->host.len] = backup;
226 228
 	return rcvd;
227 229
 }
228 230
 
... ...
@@ -392,7 +394,7 @@ char* id_builder(struct sip_msg* msg, unsigned int *id_len)
392 394
 
393 395
 
394 396
 
395
-char* clen_builder(struct sip_msg* msg, unsigned int *clen_len, int diff)
397
+char* clen_builder(struct sip_msg* msg, unsigned int *clen_len)
396 398
 {
397 399
 	char* buf;
398 400
 	int len;
... ...
@@ -409,7 +411,7 @@ char* clen_builder(struct sip_msg* msg, unsigned int *clen_len, int diff)
409 411
 					" (missing crlf?)");
410 412
 		return 0;
411 413
 	}
412
-	value=msg->len-(int)(body-msg->buf)+diff;
414
+	value=msg->len-(int)(body-msg->buf);
413 415
 	value_s=int2str(value, &value_len);
414 416
 	DBG("clen_builder: content-length: %d (%s)\n", value, value_s);
415 417
 		
... ...
@@ -497,7 +499,7 @@ static inline int lump_check_opt(	enum lump_conditions cond,
497 499
 
498 500
 /* computes the "unpacked" len of a lump list,
499 501
    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)
502
+static inline int lumps_len(struct sip_msg* msg, struct socket_info* send_sock)
501 503
 {
502 504
 	int s_offset;
503 505
 	int new_len;
... ...
@@ -670,7 +672,7 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, struct sock
670 672
 		send_port_str=&(send_sock->port_no_str);
671 673
 	
672 674
 	
673
-	for(t=lumps;t;t=t->next){
675
+	for(t=msg->add_rm;t;t=t->next){
674 676
 		/* skip if this is an OPT lump and the condition is not satisfied */
675 677
 		if ((t->op==LUMP_ADD_OPT) && !lump_check_opt(t->u.cond, msg, send_sock))
676 678
 			continue;
... ...
@@ -761,8 +763,7 @@ skip_after:
761 763
 /* another helper functions, adds/Removes the lump,
762 764
 	code moved form build_req_from_req  */
763 765
 
764
-static inline void process_lumps(	struct sip_msg* msg,
765
-					                                struct lump* lumps,
766
+static inline void process_lumps(	struct sip_msg* msg,	
766 767
 									char* new_buf, 
767 768
 									unsigned int* new_buf_offs, 
768 769
 									unsigned int* orig_offs,
... ...
@@ -1026,7 +1027,7 @@ static inline void process_lumps(	struct sip_msg* msg,
1026 1027
 	offset=*new_buf_offs;
1027 1028
 	s_offset=*orig_offs;
1028 1029
 	
1029
-	for (t=lumps;t;t=t->next){
1030
+	for (t=msg->add_rm;t;t=t->next){
1030 1031
 		switch(t->op){
1031 1032
 			case LUMP_ADD:
1032 1033
 			case LUMP_ADD_SUBST:
... ...
@@ -1183,109 +1184,12 @@ skip_nop_after:
1183 1184
 }
1184 1185
 
1185 1186
 
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 1187
 
1284 1188
 char * build_req_buf_from_sip_req( struct sip_msg* msg,
1285 1189
 								unsigned int *returned_len,
1286 1190
 								struct socket_info* send_sock, int proto)
1287 1191
 {
1288
-	unsigned int len, new_len, received_len, rport_len, uri_len, via_len, body_delta;
1192
+	unsigned int len, new_len, received_len, rport_len, uri_len, via_len;
1289 1193
 	char* line_buf;
1290 1194
 	char* received_buf;
1291 1195
 	char* rport_buf;
... ...
@@ -1297,14 +1201,18 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1297 1201
 	str branch;
1298 1202
 	str extra_params;
1299 1203
 	struct hostport hp;
1300
-
1204
+	
1301 1205
 #ifdef USE_TCP
1302 1206
 	char* id_buf;
1303 1207
 	unsigned int id_len;
1208
+	char* clen_buf;
1209
+	unsigned int clen_len;
1304 1210
 	
1305 1211
 	
1306 1212
 	id_buf=0;
1307 1213
 	id_len=0;
1214
+	clen_buf=0;
1215
+	clen_len=0;
1308 1216
 #endif
1309 1217
 	via_insert_param=0;
1310 1218
 	extra_params.len=0;
... ...
@@ -1318,6 +1226,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1318 1226
 	received_buf=0;
1319 1227
 	rport_buf=0;
1320 1228
 	line_buf=0;
1229
+
1321 1230
 	
1322 1231
 #ifdef USE_TCP
1323 1232
 	/* add id if tcp */
... ...
@@ -1337,17 +1246,31 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1337 1246
 		extra_params.s=id_buf;
1338 1247
 		extra_params.len=id_len;
1339 1248
 	}
1249
+	/* if sending proto == tcp, check if Content-Length needs to be added*/
1250
+	if (proto==PROTO_TCP
1251
+#ifdef USE_TLS
1252
+			|| proto==PROTO_TLS
1340 1253
 #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;
1254
+			){
1255
+		DBG("build_req_from_req: checking for clen; proto=%d,"
1256
+			" rcv->proto=%d\n", proto, msg->rcv.proto);
1257
+		/* first of all parse content-length */
1258
+		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
1259
+			LOG(L_ERR, "build_req_buf_from_sip_req:"
1260
+							" error parsing content-length\n");
1261
+			goto skip_clen;
1262
+		}
1263
+		if (msg->content_length==0){
1264
+			/* we need to add it */
1265
+			if ((clen_buf=clen_builder(msg, &clen_len))==0){
1266
+				LOG(L_ERR, "build_req_buf_from_sip_req:" 
1267
+								" clen_builder failed\n");
1268
+				goto skip_clen;
1269
+			}
1270
+		}
1349 1271
 	}
1350
-
1272
+skip_clen:
1273
+#endif
1351 1274
 	branch.s=msg->add_to_branch_s;
1352 1275
 	branch.len=msg->add_to_branch_len;
1353 1276
 	set_hostport(&hp, msg);
... ...
@@ -1383,7 +1306,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1383 1306
 	/* add via header to the list */
1384 1307
 	/* try to add it before msg. 1st via */
1385 1308
 	/* add first via, as an anchor for second via*/
1386
-	anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA);
1309
+	anchor=anchor_lump(&(msg->add_rm), msg->via1->hdr.s-buf, 0, HDR_VIA);
1387 1310
 	if (anchor==0) goto error01;
1388 1311
 	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
1389 1312
 		goto error01;
... ...
@@ -1409,11 +1332,11 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1409 1332
 	 * overwrite the previous one if already present */
1410 1333
 	if (received_len){
1411 1334
 		if (msg->via1->received){ /* received already present => overwrite it*/
1412
-			via_insert_param=del_lump(msg,
1335
+			via_insert_param=del_lump(&(msg->add_rm),
1413 1336
 								msg->via1->received->start-buf-1, /*;*/
1414 1337
 								msg->via1->received->size+1, /*;*/ HDR_VIA);
1415 1338
 		}else if (via_insert_param==0){ /* receive not present, ok */
1416
-			via_insert_param=anchor_lump(msg,
1339
+			via_insert_param=anchor_lump(&(msg->add_rm),
1417 1340
 										msg->via1->hdr.s-buf+size,0, HDR_VIA);
1418 1341
 		}
1419 1342
 		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 1346
 	/* if rport needs to be updated, delete it if present and add it's value */
1424 1347
 	if (rport_len){
1425 1348
 		if (msg->via1->rport){ /* rport already present */
1426
-			via_insert_param=del_lump(msg,
1349
+			via_insert_param=del_lump(&(msg->add_rm),
1427 1350
 								msg->via1->rport->start-buf-1, /*';'*/
1428 1351
 								msg->via1->rport->size+1 /* ; */, HDR_VIA);
1429 1352
 		}else if (via_insert_param==0){ /*force rport, no rport present */
1430 1353
 			/* no rport, add it */
1431
-			via_insert_param=anchor_lump(msg,
1354
+			via_insert_param=anchor_lump(&(msg->add_rm),
1432 1355
 										msg->via1->hdr.s-buf+size,0, HDR_VIA);
1433 1356
 		}
1434 1357
 		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 1360
 			goto error03; /* free rport_buf */
1438 1361
 			
1439 1362
 	}
1363
+#ifdef USE_TCP
1364
+	/* if clen needs to be added, add it */
1365
+	if (clen_len){
1366
+		/* msg->unparsed should point just before the final crlf,
1367
+		 * parse_headers is called from clen_builder */
1368
+		anchor=anchor_lump(&(msg->add_rm), msg->unparsed-buf, 0,
1369
+							 HDR_CONTENTLENGTH);
1370
+		if (anchor==0) goto error04; /* free clen_buf */
1371
+		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1372
+					HDR_CONTENTLENGTH)==0)
1373
+			goto error04; /* free clen_buf*/
1374
+	}
1375
+#endif
1440 1376
 
1441 1377
 	/* compute new msg len and fix overlapping zones*/
1442
-	new_len=len+body_delta+lumps_len(msg, msg->add_rm, send_sock);
1378
+	new_len=len+lumps_len(msg, send_sock);
1443 1379
 #ifdef XL_DEBUG
1444 1380
 	LOG(L_ERR, "DEBUG: new_len(%d)=len(%d)+lumps_len\n", new_len, len);
1445 1381
 #endif
... ...
@@ -1469,8 +1405,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1469 1405
 	}
1470 1406
 	new_buf[new_len]=0;
1471 1407
 	/* 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);
1408
+	process_lumps(msg, new_buf, &offset, &s_offset, send_sock);
1474 1409
 	/* copy the rest of the message */
1475 1410
 	memcpy(new_buf+offset, buf+s_offset, len-s_offset);
1476 1411
 	new_buf[new_len]=0;
... ...
@@ -1496,6 +1431,10 @@ error02:
1496 1431
 	if (received_buf) pkg_free(received_buf);
1497 1432
 error03:
1498 1433
 	if (rport_buf) pkg_free(rport_buf);
1434
+#ifdef USE_TCP
1435
+error04:
1436
+	if (clen_buf) pkg_free(clen_buf);
1437
+#endif
1499 1438
 error00:
1500 1439
 #ifdef USE_TCP
1501 1440
 	if (id_buf) pkg_free(id_buf);
... ...
@@ -1509,12 +1448,19 @@ error00:
1509 1448
 char * build_res_buf_from_sip_res( struct sip_msg* msg,
1510 1449
 				unsigned int *returned_len)
1511 1450
 {
1512
-	unsigned int new_len, via_len, body_delta;
1451
+	unsigned int new_len, via_len;
1513 1452
 	char* new_buf;
1514 1453
 	unsigned offset, s_offset, via_offset;
1515 1454
 	char* buf;
1516 1455
 	unsigned int len;
1517
-
1456
+#ifdef USE_TCP
1457
+	struct lump* anchor;
1458
+	char* clen_buf;
1459
+	unsigned int clen_len;
1460
+	
1461
+	clen_buf=0;
1462
+	clen_len=0;
1463
+#endif
1518 1464
 	buf=msg->buf;
1519 1465
 	len=msg->len;
1520 1466
 	new_buf=0;
... ...
@@ -1527,26 +1473,57 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
1527 1473
 		via_offset=msg->h_via1->name.s-buf;
1528 1474
 	}
1529 1475
 
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
-	}
1476
+#ifdef USE_TCP
1540 1477
 
1478
+	/* if sending proto == tcp, check if Content-Length needs to be added*/
1479
+	if (msg->via2 && ((msg->via2->proto==PROTO_TCP)
1480
+#ifdef USE_TLS
1481
+				|| (msg->via2->proto==PROTO_TLS)
1482
+#endif
1483
+				)){
1484
+		DBG("build_res_from_sip_res: checking content-length for \n%.*s\n",
1485
+				(int)msg->len, msg->buf);
1486
+		/* first of all parse content-length */
1487
+		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
1488
+			LOG(L_ERR, "build_res_buf_from_sip_res:"
1489
+							" error parsing content-length\n");
1490
+			goto skip_clen;
1491
+		}
1492
+		if (msg->content_length==0){
1493
+			DBG("build_res_from_sip_res: no content_length hdr found\n");
1494
+			/* we need to add it */
1495
+			if ((clen_buf=clen_builder(msg, &clen_len))==0){
1496
+				LOG(L_ERR, "build_res_buf_from_sip_res:" 
1497
+								" clen_builder failed\n");
1498
+				goto skip_clen;
1499
+			}
1500
+		}
1501
+	}
1502
+skip_clen:
1503
+#endif
1504
+	
1541 1505
 	/* remove the first via*/
1542
-	if (del_lump( msg, via_offset, via_len, HDR_VIA)==0){
1506
+	if (del_lump( &(msg->add_rm), via_offset, via_len, HDR_VIA)==0){
1543 1507
 		LOG(L_ERR, "build_res_buf_from_sip_res: error trying to remove first"
1544 1508
 					"via\n");
1545 1509
 		goto error;
1546 1510
 	}
1547
-
1548
-	new_len=len+body_delta+lumps_len(msg, msg->add_rm, 0); /*FIXME: we don't
1549
-														know the send sock */
1511
+#ifdef USE_TCP
1512
+	/* if clen needs to be added, add it */
1513
+	if (clen_len){
1514
+		/* msg->unparsed should point just before the final crlf,
1515
+		 * parse_headers is called from clen_builder */
1516
+		anchor=anchor_lump(&(msg->add_rm), msg->unparsed-buf, 0, 
1517
+							HDR_CONTENTLENGTH);
1518
+		DBG("build_res_from_sip_res: adding content-length: %.*s\n",
1519
+				(int)clen_len, clen_buf);
1520
+		if (anchor==0) goto error_clen; /* free clen_buf*/
1521
+		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1522
+					HDR_CONTENTLENGTH)==0)
1523
+			goto error_clen; /* free clen_buf*/
1524
+	}
1525
+#endif
1526
+	new_len=len+lumps_len(msg, 0); /*FIXME: we don't know the send sock */
1550 1527
 	
1551 1528
 	DBG(" old size: %d, new size: %d\n", len, new_len);
1552 1529
 	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 1534
 	}
1558 1535
 	new_buf[new_len]=0; /* debug: print the message */
1559 1536
 	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);
1537
+	process_lumps(msg, new_buf, &offset, &s_offset, 0); /*FIXME: no send sock*/
1563 1538
 	/* copy the rest of the message */
1564 1539
 	memcpy(new_buf+offset,
1565 1540
 		buf+s_offset, 
... ...
@@ -1570,6 +1545,10 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
1570 1545
 
1571 1546
 	*returned_len=new_len;
1572 1547
 	return new_buf;
1548
+#ifdef USE_TCP
1549
+error_clen:
1550
+	if (clen_buf) pkg_free(clen_buf);
1551
+#endif
1573 1552
 error:
1574 1553
 	*returned_len=0;
1575 1554
 	return 0;
... ...
@@ -1585,10 +1564,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1585 1564
 	struct lump_rpl   *lump;
1586 1565
 	struct lump_rpl   *body;
1587 1566
 	int               i;
1588
-	str               received = {0,0};
1589
-	str               rport = {0,0};
1590
-	str               warning = {0,0};
1591
-	str               content_len = {0,0};
1567
+	char*             received_buf;
1568
+	unsigned int      received_len;
1569
+	char*             rport_buf;
1570
+	unsigned int      rport_len;
1571
+	char*             warning_buf;
1572
+	unsigned int      warning_len;
1573
+	char*             content_len_buf;
1574
+	unsigned int      content_len_len;
1592 1575
 	unsigned int      text_len;
1593 1576
 	char *after_body;
1594 1577
 	str  to_tag;
... ...
@@ -1596,9 +1579,11 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1596 1579
 
1597 1580
 	body = 0;
1598 1581
 	buf=0;
1599
-
1582
+	received_buf=rport_buf=warning_buf=content_len_buf=0;
1583
+	received_len=rport_len=warning_len=content_len_len=0;
1584
+	
1600 1585
 	text_len=strlen(text);
1601
-
1586
+	
1602 1587
 	/* force parsing all headers -- we want to return all
1603 1588
 	Via's in the reply and they may be scattered down to the
1604 1589
 	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 1599
 
1615 1600
 	/* check if received needs to be added */
1616 1601
 	if (received_test(msg)) {
1617
-		if ((received.s=received_builder(msg,&received.len))==0) {
1602
+		if ((received_buf=received_builder(msg,&received_len))==0) {
1618 1603
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
1619 1604
 				"alas, received_builder failed\n");
1620 1605
 			goto error00;
... ...
@@ -1623,7 +1608,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1623 1608
 	/* check if rport needs to be updated */
1624 1609
 	if ( (msg->msg_flags&FL_FORCE_RPORT)||
1625 1610
 		(msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
1626
-		if ((rport.s=rport_builder(msg, &rport.len))==0){
1611
+		if ((rport_buf=rport_builder(msg, &rport_len))==0){
1627 1612
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req:"
1628 1613
 							" rport_builder failed\n");
1629 1614
 			goto error01; /* free everything */
... ...
@@ -1651,7 +1636,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1651 1636
 			case HDR_VIA:
1652 1637
 				/* we always add CRLF to via*/
1653 1638
 				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
1654
-				if (hdr==msg->h_via1) len += received.len+rport.len;
1639
+				if (hdr==msg->h_via1) len += received_len+rport_len;
1655 1640
 				break;
1656 1641
 			case HDR_RECORDROUTE:
1657 1642
 				/* 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 1660
 		len += SERVER_HDR_LEN + CRLF_LEN;
1676 1661
 	/* warning hdr */
1677 1662
 	if (sip_warning) {
1678
-		warning.s = warning_builder(msg,&warning.len);
1679
-		if (warning.s) len += warning.len + CRLF_LEN;
1663
+		warning_buf = warning_builder(msg,&warning_len);
1664
+		if (warning_buf) len += warning_len + CRLF_LEN;
1680 1665
 		else LOG(L_WARN, "WARNING: warning skipped -- too big\n");
1681 1666
 	}
1682 1667
 	/* content length hdr */
1683 1668
 	if (body) {
1684
-		content_len.s = int2str(body->text.len, &content_len.len);
1685
-		len += CONTENT_LENGTH_LEN + content_len.len + CRLF_LEN;
1669
+		content_len_buf = int2str(body->text.len, (int*)&content_len_len);
1670
+		len += CONTENT_LENGTH_LEN + content_len_len + CRLF_LEN;
1686 1671
 	} else {
1687 1672
 		len += CONTENT_LENGTH_LEN + 1/*0*/ + CRLF_LEN;
1688 1673
 	}
... ...
@@ -1719,13 +1704,13 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1719 1704
 		{
1720 1705
 			case HDR_VIA:
1721 1706
 				if (hdr==msg->h_via1){
1722
-					if (rport.s){
1707
+					if (rport_buf){
1723 1708
 						if (msg->via1->rport){ /* delete the old one */
1724 1709
 							/* copy until rport */
1725 1710
 							append_str_trans( p, hdr->name.s ,
1726 1711
 								msg->via1->rport->start-hdr->name.s-1,msg);
1727 1712
 							/* copy new rport */
1728
-							append_str(p, rport.s, rport.len);
1713
+							append_str(p, rport_buf, rport_len);
1729 1714
 							/* copy the rest of the via */
1730 1715
 							append_str_trans(p, msg->via1->rport->start+
1731 1716
 												msg->via1->rport->size, 
... ...
@@ -1736,15 +1721,15 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1736 1721
 							/* normal whole via copy */
1737 1722
 							append_str_trans( p, hdr->name.s , 
1738 1723
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
1739
-							append_str(p, rport.s, rport.len);
1724
+							append_str(p, rport_buf, rport_len);
1740 1725
 						}
1741 1726
 					}else{
1742 1727
 						/* normal whole via copy */
1743 1728
 						append_str_trans( p, hdr->name.s , 
1744 1729
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
1745 1730
 					}
1746
-					if (received.s)
1747
-						append_str( p, received.s, received.len);
1731
+					if (received_buf)
1732
+						append_str( p, received_buf, received_len);
1748 1733
 				}else{
1749 1734
 					/* normal whole via copy */
1750 1735
 					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 1792
 		p+=CRLF_LEN;
1808 1793
 	}
1809 1794
 	/* content_length hdr */
1810
-	if (content_len.len) {
1795
+	if (content_len_len) {
1811 1796
 		append_str( p, CONTENT_LENGTH, CONTENT_LENGTH_LEN);
1812
-		append_str( p, content_len.s, content_len.len );
1797
+		append_str( p, content_len_buf, content_len_len );
1813 1798
 		append_str( p, CRLF, CRLF_LEN );
1814 1799
 	} else {
1815 1800
 		append_str( p, CONTENT_LENGTH"0"CRLF,CONTENT_LENGTH_LEN+1+CRLF_LEN);
1816 1801
 	}
1817 1802
 	/* warning header */
1818
-	if (warning.s) {
1819
-		memcpy( p, warning.s, warning.len);
1820
-		p+=warning.len;
1803
+	if (warning_buf) {
1804
+		memcpy( p, warning_buf, warning_len);
1805
+		p+=warning_len;
1821 1806
 		memcpy( p, CRLF, CRLF_LEN);
1822 1807
 		p+=CRLF_LEN;
1823 1808
 	}
... ...
@@ -1838,13 +1823,13 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1838 1823
 	/* in req2reply, received_buf is not introduced to lumps and
1839 1824
 	   needs to be deleted here
1840 1825
 	*/
1841
-	if (received.s) pkg_free(received.s);
1842
-	if (rport.s) pkg_free(rport.s);
1826
+	if (received_buf) pkg_free(received_buf);
1827
+	if (rport_buf) pkg_free(rport_buf);
1843 1828
 	return buf;
1844 1829
 
1845 1830
 error01:
1846
-	if (received.s) pkg_free(received.s);
1847
-	if (rport.s) pkg_free(rport.s);
1831
+	if (received_buf) pkg_free(received_buf);
1832
+	if (rport_buf) pkg_free(rport_buf);
1848 1833
 error00:
1849 1834
 	*returned_len=0;
1850 1835
 	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