Module: sip-router
Branch: master
Commit: 4607f39ad00c0d1133618ad54a1c9c788f3ac01c
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4607f39…
Author: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Date: Mon Feb 1 12:26:21 2010 +0200
Modules_k/siputils : config framework implementation start
Started for ring_timeout
---
modules_k/siputils/README | 2 +-
modules_k/siputils/doc/siputils_admin.xml | 2 +-
modules_k/siputils/ring.c | 5 +++++
modules_k/siputils/siputils.c | 12 +++++++++---
4 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/modules_k/siputils/README b/modules_k/siputils/README
index 9078784..fab43aa 100644
--- a/modules_k/siputils/README
+++ b/modules_k/siputils/README
@@ -293,7 +293,7 @@ modparam("siputils", "options_support",
"100rel")
Inserting the call-id in the internal list, which is checked when
further replies arrive. Any 183 reply that is received during the
- timeout value will be converted to a 180 message. Please not that you
+ timeout value will be converted to a 180 message. Please note that you
need to set a positive timeout value in order to use this function.
The function returns TRUE on success, and FALSE during processing
diff --git a/modules_k/siputils/doc/siputils_admin.xml
b/modules_k/siputils/doc/siputils_admin.xml
index 84f546e..c9e169d 100644
--- a/modules_k/siputils/doc/siputils_admin.xml
+++ b/modules_k/siputils/doc/siputils_admin.xml
@@ -225,7 +225,7 @@ modparam("siputils", "options_support",
"100rel")
<para>
Inserting the call-id in the internal list, which is checked when
further replies arrive. Any 183 reply that is received during the
- timeout value will be converted to a 180 message. Please not that you
+ timeout value will be converted to a 180 message. Please note that you
need to set a positive timeout value in order to use this function.
</para>
<para>
diff --git a/modules_k/siputils/ring.c b/modules_k/siputils/ring.c
index f895572..ed0d478 100644
--- a/modules_k/siputils/ring.c
+++ b/modules_k/siputils/ring.c
@@ -50,6 +50,7 @@
#include "../../locking.h"
#include "../../md5.h"
+#include "config.h"
#include "ring.h"
@@ -174,6 +175,10 @@ static unsigned int hash(char *buf, int len)
*/
static void remove_timeout(unsigned int index)
{
+ int ring_timeout = cfg_get(siputils, siputils_cfg, ring_timeout);
+ if(ring_timeout == 0){
+ LM_ERR("Could not get timeout from cfg. This will expire all entries");
+ }
while ((*hashtable)[index].head && ((*hashtable)[index].head)->time +
ring_timeout < get_ticks()) {
struct ring_record_t* rr = (*hashtable)[index].head;
(*hashtable)[index].head = rr->next;
diff --git a/modules_k/siputils/siputils.c b/modules_k/siputils/siputils.c
index 461dd30..2b3aec8 100644
--- a/modules_k/siputils/siputils.c
+++ b/modules_k/siputils/siputils.c
@@ -74,6 +74,7 @@
#include "utils.h"
#include "contact_ops.h"
#include "sipops.h"
+#include "config.h"
MODULE_VERSION
@@ -115,7 +116,7 @@ static cmd_export_t cmds[]={
};
static param_export_t params[] = {
- {"ring_timeout", INT_PARAM, &ring_timeout},
+ {"ring_timeout", INT_PARAM,
&default_siputils_cfg.ring_timeout},
{"options_accept", STR_PARAM, &opt_accept.s},
{"options_accept_encoding", STR_PARAM, &opt_accept_enc.s},
{"options_accept_language", STR_PARAM, &opt_accept_lang.s},
@@ -143,7 +144,7 @@ struct module_exports exports= {
static int mod_init(void)
{
- if(ring_timeout > 0) {
+ if(default_siputils_cfg.ring_timeout > 0) {
ring_init_hashtable();
ring_lock = lock_alloc();
@@ -163,7 +164,12 @@ static int mod_init(void)
LM_ERR("can't load SL API\n");
return -1;
}
-
+
+ if(cfg_declare("siptutils", siputils_cfg_def, &default_siputils_cfg,
cfg_sizeof(siputils), &siputils_cfg)){
+ LM_ERR("Fail to declare the configuration\n");
+ return -1;
+ }
+
opt_accept.len = strlen(opt_accept.s);
opt_accept_enc.len = strlen(opt_accept_enc.s);
opt_accept_lang.len = strlen(opt_accept_lang.s);