Module: sip-router
Branch: master
Commit: ec1dfe890db6bd8ea50edc55e6774908d74a672e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ec1dfe8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Sep 10 18:55:44 2014 +0200
usrloc: new parameter db_raw_fetch_type
- specify what type of query should be used in DB-only mode for
retrieving contacts for specific needs (e.g., sending NAT keepalives)
---
modules/usrloc/README | 19 +++++++++++++++++++
modules/usrloc/dlist.c | 15 ++++++++-------
modules/usrloc/doc/usrloc_admin.xml | 24 ++++++++++++++++++++++++
modules/usrloc/ul_mod.c | 2 ++
4 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/modules/usrloc/README b/modules/usrloc/README
index 68fac27..ed9df55 100644
--- a/modules/usrloc/README
+++ b/modules/usrloc/README
@@ -70,6 +70,7 @@ Bogdan-Andrei Iancu
3.32. db_ops_ruid (int)
3.33. handle_lost_tcp (int)
3.34. expires_type (int)
+ 3.35. db_raw_fetch_type (int)
4. Functions
5. MI Commands
@@ -161,6 +162,7 @@ Bogdan-Andrei Iancu
1.32. Set db_ops_ruid parameter
1.33. Set handle_lost_tcp parameter
1.34. Set expires_type parameter
+ 1.35. Set db_raw_fetch_type parameter
Chapter 1. Admin Guide
@@ -211,6 +213,7 @@ Chapter 1. Admin Guide
3.32. db_ops_ruid (int)
3.33. handle_lost_tcp (int)
3.34. expires_type (int)
+ 3.35. db_raw_fetch_type (int)
4. Functions
5. MI Commands
@@ -333,6 +336,7 @@ Chapter 1. Admin Guide
3.32. db_ops_ruid (int)
3.33. handle_lost_tcp (int)
3.34. expires_type (int)
+ 3.35. db_raw_fetch_type (int)
3.1. nat_bflag (integer)
@@ -799,6 +803,21 @@ modparam("usrloc", "handle_lost_tcp", 1)
modparam("usrloc", "expires_type", 1)
...
+3.35. db_raw_fetch_type (int)
+
+ This affect DB-only mode and controls what kind of raw query is used to
+ fetch the contacts from database for specific needs (e.g., sending NAT
+ keepalives). If it is set to 0, then the common SQL query is used
+ (working for MySQL, PostgreSQL, ...). If it is set to 1, the query
+ required by Oracle is used.
+
+ Default value is "0".
+
+ Example 1.35. Set db_raw_fetch_type parameter
+...
+modparam("usrloc", "db_raw_fetch_type", 1)
+...
+
4. Functions
There are no exported functions that could be used in scripts.
diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c
index 1fbfacf..8ac272a 100644
--- a/modules/usrloc/dlist.c
+++ b/modules/usrloc/dlist.c
@@ -79,6 +79,11 @@ static inline int find_dlist(str* _n, dlist_t** _d)
return 1;
}
+extern int ul_db_raw_fetch_type;
+
+#define UL_DB_RAW_FETCH_COMMON "select %.*s, %.*s, %.*s, %.*s, %.*s, %.*s from %s
where %.*s > %.*s and %.*s & %d = %d and id %% %u = %u"
+
+#define UL_DB_RAW_FETCH_ORACLE "select %.*s, %.*s, %.*s, %.*s, %.*s, %.*s from %s
where %.*s > %.*s and bitand(%.*s, %d) = %d and mod(id, %u) = %u"
/*!
* \brief Get all contacts from the database, in partitions if wanted
@@ -134,13 +139,9 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned
int flags,
for (dom = root; dom!=NULL ; dom=dom->next) {
/* build query */
- i = snprintf( query_buf, sizeof(query_buf), "select %.*s, %.*s, %.*s,"
- " %.*s, %.*s, %.*s from %s where %.*s > %.*s and"
-#ifdef ORACLE_USRLOC
- " bitand(%.*s, %d) = %d and mod(id, %u) = %u",
-#else
- " %.*s & %d = %d and id %% %u = %u",
-#endif
+ i = snprintf( query_buf, sizeof(query_buf),
+ (ul_db_raw_fetch_type==1)?
+ UL_DB_RAW_FETCH_ORACLE:UL_DB_RAW_FETCH_COMMON,
received_col.len, received_col.s,
contact_col.len, contact_col.s,
sock_col.len, sock_col.s,
diff --git a/modules/usrloc/doc/usrloc_admin.xml b/modules/usrloc/doc/usrloc_admin.xml
index b4f68a0..6520b49 100644
--- a/modules/usrloc/doc/usrloc_admin.xml
+++ b/modules/usrloc/doc/usrloc_admin.xml
@@ -921,6 +921,30 @@ modparam("usrloc", "expires_type", 1)
</example>
</section>
+ <section id="usrloc.p.db_raw_fetch_type">
+ <title><varname>db_raw_fetch_type</varname> (int)</title>
+ <para>
+ This affect DB-only mode and controls what kind of
+ raw query is used to fetch the contacts from database for
+ specific needs (e.g., sending NAT keepalives). If it is set to 0,
+ then the common SQL query is used (working for MySQL, PostgreSQL,
+ ...). If it is set to 1, the query required by Oracle is used.
+ </para>
+ <para>
+ <emphasis>
+ Default value is <quote>0</quote>.
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>db_raw_fetch_type</varname>
parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("usrloc", "db_raw_fetch_type", 1)
+...
+</programlisting>
+ </example>
+ </section>
+
</section>
<section>
diff --git a/modules/usrloc/ul_mod.c b/modules/usrloc/ul_mod.c
index b51675e..a8a0b91 100644
--- a/modules/usrloc/ul_mod.c
+++ b/modules/usrloc/ul_mod.c
@@ -120,6 +120,7 @@ int ul_keepalive_timeout = 0;
int ul_db_ops_ruid = 0;
int ul_expires_type = 0;
+int ul_db_raw_fetch_type = 0;
str ul_xavp_contact_name = {0};
@@ -224,6 +225,7 @@ static param_export_t params[] = {
{"xavp_contact", PARAM_STR, &ul_xavp_contact_name},
{"db_ops_ruid", INT_PARAM, &ul_db_ops_ruid},
{"expires_type", PARAM_INT, &ul_expires_type},
+ {"db_raw_fetch_type", PARAM_INT, &ul_db_raw_fetch_type},
{0, 0, 0}
};