Module: sip-router
Branch: master
Commit: 0b10377df11977d7ddd7e6bf30fe060d1fe200aa
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0b10377…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Dec 1 11:48:39 2014 +0100
nathelper: use dedicated function for testing via address against source ip
- reported by Igor Potjevlesch
- previous used functions was checking the presence of rport and
received parameters, ending in a wrong result for nat testing
---
modules/nathelper/nathelper.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c
index 7626ed6..0cda937 100644
--- a/modules/nathelper/nathelper.c
+++ b/modules/nathelper/nathelper.c
@@ -1556,7 +1556,7 @@ nat_uac_test_f(struct sip_msg* msg, char* str1, char* str2)
* test if source address of signaling is different from
* address advertised in Via
*/
- if ((tests & NAT_UAC_TEST_RCVD) && received_test(msg))
+ if ((tests & NAT_UAC_TEST_RCVD) && received_via_test(msg))
return 1;
/*
* test for occurrences of RFC1918 addresses in Contact
Module: sip-router
Branch: master
Commit: 194743bf0de92ae09fdc817e57863f6bdb159539
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=194743b…
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
---
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 6f36492..df1a753 100644
--- a/msg_translator.c
+++ b/msg_translator.c
@@ -252,7 +252,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;
@@ -263,6 +264,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 a87c69b..01b5619 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
*/
Hi!
I just want to remind all developers about the coolness of the core stats/counters.
We have two modules that handle these - stats and counters, but in the core it's the same.
If you use them in a module there's a lot of benefits:
- You have locking
- They can be exposed in "kamctl monitor"
- They can be read over the RPC interface in kamcmd, over HTTP/XMLRPC or JSONRPC and sockets
- They can be exposed in snmpstats
Be cool. Add a counter to a module today! Every day. One per day to Christmas!
And yes, using the modules anyone writing a kamailio routing script can add counters
that behave in the same way! Amazing, isn't it?
/O