[sr-dev] git:master: modules/ims_usrloc_pcscf: added new parameter to contact match using only URI host and port
Richard Good
richard.good at smilecoms.com
Thu Oct 9 15:08:57 CEST 2014
Module: sip-router
Branch: master
Commit: 0161257895fe421a0c9ee413a8b89d038007ba0d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0161257895fe421a0c9ee413a8b89d038007ba0d
Author: Richard Good <richard.good at smilecoms.com>
Committer: Richard Good <richard.good at smilecoms.com>
Date: Thu Oct 9 15:08:22 2014 +0200
modules/ims_usrloc_pcscf: added new parameter to contact match using only URI host and port
---
.../doc/ims_usrloc_pcscf_admin.xml | 28 ++++++++++++++++++++
modules/ims_usrloc_pcscf/udomain.c | 17 +++++++++++-
modules/ims_usrloc_pcscf/ul_mod.c | 2 +
3 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/modules/ims_usrloc_pcscf/doc/ims_usrloc_pcscf_admin.xml b/modules/ims_usrloc_pcscf/doc/ims_usrloc_pcscf_admin.xml
index c904b53..165ba41 100644
--- a/modules/ims_usrloc_pcscf/doc/ims_usrloc_pcscf_admin.xml
+++ b/modules/ims_usrloc_pcscf/doc/ims_usrloc_pcscf_admin.xml
@@ -235,6 +235,34 @@ modparam("ims_usrloc_pcscf", "lookup_check_received", 0)
</programlisting>
</example>
</section>
+ <section>
+ <title>match_contact_host_port (int)</title>
+
+ <para>If set to 1 (default), the contact is matched using only host
+ and port in the contact URI.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>0 - When matching contact do full contact match procedure.</para>
+ </listitem>
+
+ <listitem>
+ <para>1 - When matching contact compare only host and port of the contact URI.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis>Default value is 1.</emphasis></para>
+
+ <example>
+ <title>Set match_contact_host_port parameter</title>
+
+ <programlisting format="linespecific">...
+modparam("ims_usrloc_pcscf", "match_contact_host_port", 0)
+...
+</programlisting>
+ </example>
+ </section>
+
</section>
<section>
diff --git a/modules/ims_usrloc_pcscf/udomain.c b/modules/ims_usrloc_pcscf/udomain.c
index 23e1213..f213c89 100644
--- a/modules/ims_usrloc_pcscf/udomain.c
+++ b/modules/ims_usrloc_pcscf/udomain.c
@@ -64,6 +64,7 @@
extern int db_mode;
extern unsigned int hashing_type;
extern int lookup_check_received;
+extern int match_contact_host_port;
#ifdef STATISTICS
static char *build_stat_name( str* domain, char *var_name)
@@ -477,7 +478,21 @@ int get_pcontact(udomain_t* _d, str* _contact, struct pcontact** _c) {
*_c = c;
return 0;
}
-
+
+ if(match_contact_host_port) {
+ LM_DBG("Comparing needle user at host:port [%.*s@%.*s:%d] and contact_user at contact_host:port [%.*s@%.*s:%d]\n", needle_uri.user.len, needle_uri.user.s,
+ needle_uri.host.len, needle_uri.host.s, needle_uri.port_no,
+ c->contact_user.len, c->contact_user.s, c->contact_host.len, c->contact_host.s, c->contact_port);
+
+ if((needle_uri.user.len == c->contact_user.len && (memcmp(needle_uri.user.s, c->contact_user.s, needle_uri.user.len) ==0)) &&
+ (needle_uri.host.len == c->contact_host.len && (memcmp(needle_uri.host.s, c->contact_host.s, needle_uri.host.len) ==0)) &&
+ (needle_uri.port_no == c->contact_port)) {
+ LM_DBG("Match!!\n");
+ *_c = c;
+ return 0;
+ }
+ }
+
LM_DBG("Searching for [%.*s] and comparing to [%.*s]\n", _contact->len, _contact->s, c->aor.len, c->aor.s);
/* hosts HAVE to match */
diff --git a/modules/ims_usrloc_pcscf/ul_mod.c b/modules/ims_usrloc_pcscf/ul_mod.c
index 3fbab3c..11079da 100644
--- a/modules/ims_usrloc_pcscf/ul_mod.c
+++ b/modules/ims_usrloc_pcscf/ul_mod.c
@@ -86,6 +86,7 @@ int ul_fetch_rows = 2000;
int hashing_type = 0; /*!< has type for storing P-CSCF contacts - 0 - use full contact AOR, 1 - use IP:PORT only */
int lookup_check_received = 1; /*!< Should we check received on lookup? */
+int match_contact_host_port = 1; /*!< Should we match contact just based on rui host and port*/
db1_con_t* ul_dbh = 0;
db_func_t ul_dbf;
@@ -112,6 +113,7 @@ static param_export_t params[] = {
{"db_mode", INT_PARAM, &db_mode },
{"hashing_type", INT_PARAM, &hashing_type },
{"lookup_check_received", INT_PARAM, &lookup_check_received },
+ {"match_contact_host_port", INT_PARAM, &match_contact_host_port },
{0, 0, 0}
};
More information about the sr-dev
mailing list