Module: sip-router
Branch: master
Commit: 0314f73b8dde0b49f213abe5fea4495c6985bc31
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0314f73…
Author: Tristan Bruns <bruns(a)decoit.de>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Aug 3 12:29:24 2011 +0200
modules_k/siptrace: Add trace_to_database configuration parameter
Adding configuration parameter to disable writing to the database.
We can use this to only duplicate the SIP messages without storing them
in our database.
Signed-off-by: Tristan Bruns <bruns(a)decoit.de>
Signed-off-by: Daniel-Constantin Mierla <miconda(a)gmail.com>
---
modules_k/siptrace/doc/siptrace_admin.xml | 25 +++++++++++++++++++++++++
modules_k/siptrace/siptrace.c | 15 +++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/modules_k/siptrace/doc/siptrace_admin.xml
b/modules_k/siptrace/doc/siptrace_admin.xml
index c02ec57..cbca2e6 100644
--- a/modules_k/siptrace/doc/siptrace_admin.xml
+++ b/modules_k/siptrace/doc/siptrace_admin.xml
@@ -233,6 +233,31 @@ modparam("siptrace", "duplicate_uri",
"sip:10.1.1.1:5888")
</example>
</section>
<section>
+ <title><varname>trace_to_database</varname> (integer)</title>
+ <para>
+ Parameter to enable/disable inserts to the Database from this
+ Kamailio.
+ </para>
+ <para>
+ In case we only want to send the SIP-Messages to the
+ duplicate_uri and not store the information to the local
+ database we can set this to "0".
+ </para>
+ <para>
+ <emphasis>
+ Default value is "1".
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>trace_to_database</varname>
parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("siptrace", "trace_to_database", 0)
+...
+</programlisting>
+ </example>
+ </section>
+ <section>
<title><varname>trace_local_ip</varname> (str)</title>
<para>
The address to be used in fromip field for local generated
diff --git a/modules_k/siptrace/siptrace.c b/modules_k/siptrace/siptrace.c
index 68fd44c..c970002 100644
--- a/modules_k/siptrace/siptrace.c
+++ b/modules_k/siptrace/siptrace.c
@@ -117,10 +117,13 @@ int trace_flag = -1;
int trace_on = 0;
int trace_sl_acks = 1;
+int trace_to_database = 1;
+
str dup_uri_str = {0, 0};
struct sip_uri *dup_uri = 0;
int *trace_on_flag = NULL;
+int *trace_to_database_flag = NULL;
static unsigned short traced_user_avp_type = 0;
static int_str traced_user_avp;
@@ -166,6 +169,7 @@ static param_export_t params[] = {
{"traced_user_avp", STR_PARAM, &traced_user_avp_str.s},
{"trace_table_avp", STR_PARAM, &trace_table_avp_str.s},
{"duplicate_uri", STR_PARAM, &dup_uri_str.s },
+ {"trace_to_database", INT_PARAM, &trace_to_database },
{"trace_local_ip", STR_PARAM, &trace_local_ip.s },
{"trace_sl_acks", INT_PARAM, &trace_sl_acks },
{0, 0, 0}
@@ -282,6 +286,14 @@ static int mod_init(void)
*trace_on_flag = trace_on;
+ trace_to_database_flag = (int*)shm_malloc(sizeof(int));
+ if(trace_to_database_flag==NULL) {
+ LM_ERR("no more shm memory left\n");
+ return -1;
+ }
+
+ *trace_to_database_flag = trace_to_database;
+
/* register callbacks to TM */
if (load_tm_api(&tmb)!=0)
{
@@ -476,6 +488,9 @@ static int sip_trace_store(struct _siptrace_data *sto)
static int sip_trace_store_db(struct _siptrace_data *sto)
{
+ if(trace_to_database_flag==NULL || *trace_to_database_flag==0)
+ goto done;
+
db_key_t db_keys[NR_KEYS];
db_val_t db_vals[NR_KEYS];