Browse code

received test functionalized for sanity and exporting to nathelper uac_nat_test

Jiri Kuthan authored on 08/10/2003 20:02:14
Showing 2 changed files
... ...
@@ -53,6 +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)
56 57
  *
57 58
  */
58 59
 /* Via special params:
... ...
@@ -212,6 +213,22 @@ static int check_via_address(struct ip_addr* ip, str *name,
212 212
 }
213 213
 
214 214
 
215
+/* check if IP address in Via != source IP address of signaling */
216
+int received_test( struct sip_msg *msg )
217
+{
218
+	char backup;
219
+	int rcvd;
220
+
221
+	/* zero-terminate hostname temporarily in case DNS resolver is used */
222
+	backup = msg->via1->host.s[msg->via1->host.len];
223
+	rcvd=msg->via1->received
224
+			|| check_via_address(&msg->rcv.src_ip, &msg->via1->host,
225
+							msg->via1->port, received_dns);
226
+	msg->via1->host.s[msg->via1->host.len] = backup;
227
+	return rcvd;
228
+}
229
+
230
+
215 231
 static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
216 232
 {
217 233
 	static char buf[MAX_WARNING_LEN];
... ...
@@ -1264,9 +1281,7 @@ skip_clen:
1264 1264
 		goto error00;
1265 1265
 	}
1266 1266
 	/* check if received needs to be added */
1267
-	if ( msg->via1->received || 
1268
-			check_via_address(&msg->rcv.src_ip, &msg->via1->host, 
1269
-									msg->via1->port, received_dns) ){
1267
+	if ( received_test(msg) ) { 
1270 1268
 		if ((received_buf=received_builder(msg,&received_len))==0){
1271 1269
 			LOG(L_ERR, "ERROR: build_req_buf_from_sip_req:"
1272 1270
 							" received_builder failed\n");
... ...
@@ -1540,7 +1555,6 @@ error:
1540 1540
 }
1541 1541
 
1542 1542
 
1543
-
1544 1543
 char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1545 1544
 		struct sip_msg* msg, unsigned int *returned_len, struct bookmark *bmark)
1546 1545
 {
... ...
@@ -1559,7 +1573,6 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1559 1559
 	char *after_body;
1560 1560
 	str  to_tag;
1561 1561
 	char *totags;
1562
-	int rcvd;
1563 1562
 
1564 1563
 	body = 0;
1565 1564
 	buf=0;
... ...
@@ -1580,14 +1593,8 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1580 1580
 	len = 0;
1581 1581
 
1582 1582
 	/* check if received needs to be added */
1583
-	backup = msg->via1->host.s[msg->via1->host.len];
1584
-	msg->via1->host.s[msg->via1->host.len] = 0;
1585
-	rcvd=msg->via1->received 
1586
-			|| check_via_address(&msg->rcv.src_ip, &msg->via1->host, 
1587
-						msg->via1->port, received_dns);
1588
-	msg->via1->host.s[msg->via1->host.len] = backup;
1589
-	if (rcvd) {
1590
-		if ((received.s=received_builder(msg,&received.len))==0) {
1583
+	if (received_test(msg)) {
1584
+		if ((received_buf=received_builder(msg,&received_len))==0) {
1591 1585
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
1592 1586
 				"alas, received_builder failed\n");
1593 1587
 			goto error00;
... ...
@@ -30,6 +30,7 @@
30 30
  *             ACK/200 tag matching
31 31
  *
32 32
  * 2003-03-01 VOICE_MAIL defs removed (jiri)
33
+ * 2003-10-08 receive_test function-alized (jiri)
33 34
  */
34 35
 
35 36
 
... ...
@@ -113,5 +114,7 @@ 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
+/* check if IP address in Via != source IP address of signaling */
117
+int received_test( struct sip_msg *msg );
116 118
 
117 119
 #endif