... | ... |
@@ -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 | 213 |
} |
213 | 214 |
|
214 | 215 |
|
216 |
+/* check if IP address in Via != source IP address of signaling */ |
|
217 |
+int received_test( struct sip_msg *msg ) |
|
218 |
+{ |
|
219 |
+ char backup; |
|
220 |
+ int rcvd; |
|
221 |
+ |
|
222 |
+ /* zero-terminate hostname temporarily in case DNS resolver is used */ |
|
223 |
+ backup = msg->via1->host.s[msg->via1->host.len]; |
|
224 |
+ rcvd=msg->via1->received |
|
225 |
+ || check_via_address(&msg->rcv.src_ip, &msg->via1->host, |
|
226 |
+ msg->via1->port, received_dns); |
|
227 |
+ msg->via1->host.s[msg->via1->host.len] = backup; |
|
228 |
+ return rcvd; |
|
229 |
+} |
|
230 |
+ |
|
231 |
+ |
|
215 | 232 |
static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len) |
216 | 233 |
{ |
217 | 234 |
static char buf[MAX_WARNING_LEN]; |
... | ... |
@@ -1264,9 +1281,7 @@ skip_clen: |
1264 | 1281 |
goto error00; |
1265 | 1282 |
} |
1266 | 1283 |
/* 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) ){ |
|
1284 |
+ if ( received_test(msg) ) { |
|
1270 | 1285 |
if ((received_buf=received_builder(msg,&received_len))==0){ |
1271 | 1286 |
LOG(L_ERR, "ERROR: build_req_buf_from_sip_req:" |
1272 | 1287 |
" received_builder failed\n"); |
... | ... |
@@ -1540,7 +1555,6 @@ error: |
1540 | 1555 |
} |
1541 | 1556 |
|
1542 | 1557 |
|
1543 |
- |
|
1544 | 1558 |
char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag, |
1545 | 1559 |
struct sip_msg* msg, unsigned int *returned_len, struct bookmark *bmark) |
1546 | 1560 |
{ |
... | ... |
@@ -1559,7 +1573,6 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag, |
1559 | 1573 |
char *after_body; |
1560 | 1574 |
str to_tag; |
1561 | 1575 |
char *totags; |
1562 |
- int rcvd; |
|
1563 | 1576 |
|
1564 | 1577 |
body = 0; |
1565 | 1578 |
buf=0; |
... | ... |
@@ -1580,14 +1593,8 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag, |
1580 | 1593 |
len = 0; |
1581 | 1594 |
|
1582 | 1595 |
/* 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) { |
|
1596 |
+ if (received_test(msg)) { |
|
1597 |
+ if ((received_buf=received_builder(msg,&received_len))==0) { |
|
1591 | 1598 |
LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: " |
1592 | 1599 |
"alas, received_builder failed\n"); |
1593 | 1600 |
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 | 114 |
/* output value: string and actual length */ |
114 | 115 |
char *branch_str, int *len ); |
115 | 116 |
|
117 |
+/* check if IP address in Via != source IP address of signaling */ |
|
118 |
+int received_test( struct sip_msg *msg ); |
|
116 | 119 |
|
117 | 120 |
#endif |