Module: sip-router
Branch: 4.1
Commit: 518b3e9c9b9fd7cd03903f69c31b95ababc31856
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=518b3e9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Dec 1 11:47:19 2014 +0100
core: dedicated function to check Via address with source ip
- received_via_test() as alternative to received_test() which looks also
for rport and received parameters, confusing nat detection tests
(cherry picked from commit 194743bf0de92ae09fdc817e57863f6bdb159539)
(cherry picked from commit 7ebf861b27ae7e90092bc875d75772e5a1c941d5)
---
msg_translator.c | 12 +++++++++++-
msg_translator.h | 6 +++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/msg_translator.c b/msg_translator.c
index 91fa021..52aa660 100644
--- a/msg_translator.c
+++ b/msg_translator.c
@@ -251,7 +251,8 @@ static int check_via_address(struct ip_addr* ip, str *name,
}
-/* check if IP address in Via != source IP address of signaling */
+/* check if IP address in Via != source IP address of signaling,
+ * or the sender requires adding rport or received values */
int received_test( struct sip_msg *msg )
{
int rcvd;
@@ -262,6 +263,15 @@ int received_test( struct sip_msg *msg )
return rcvd;
}
+/* check if IP address in Via != source IP address of signaling */
+int received_via_test( struct sip_msg *msg )
+{
+ int rcvd;
+
+ rcvd = (check_via_address(&msg->rcv.src_ip, &msg->via1->host,
+ msg->via1->port, received_dns)!=0);
+ return rcvd;
+}
static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
{
diff --git a/msg_translator.h b/msg_translator.h
index 4848291..54b514a 100644
--- a/msg_translator.h
+++ b/msg_translator.h
@@ -129,9 +129,13 @@ int branch_builder( unsigned int hash_index,
char* id_builder(struct sip_msg* msg, unsigned int *id_len);
-/* check if IP address in Via != source IP address of signaling */
+/* check if IP address in Via != source IP address of signaling,
+ * or the sender is asking to set the values for rport or received */
int received_test( struct sip_msg *msg );
+/* check if IP address in Via != source IP address of signaling */
+int received_via_test( struct sip_msg *msg );
+
/* builds a char* buffer from message headers without body
* first line is excluded in case of skip_first_line=1
*/