浏览代码

Modules_k/siputils : config framework implementation start

Started for ring_timeout
Marius Zbihlei 15 年之前
父节点
当前提交
4607f39ad0
共有 4 个文件被更改,包括 16 次插入5 次删除
  1. 1 1
      modules_k/siputils/README
  2. 1 1
      modules_k/siputils/doc/siputils_admin.xml
  3. 5 0
      modules_k/siputils/ring.c
  4. 9 3
      modules_k/siputils/siputils.c

+ 1 - 1
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
    Inserting the call-id in the internal list, which is checked when
    further replies arrive. Any 183 reply that is received during the
    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.
    need to set a positive timeout value in order to use this function.
 
 
    The function returns TRUE on success, and FALSE during processing
    The function returns TRUE on success, and FALSE during processing

+ 1 - 1
modules_k/siputils/doc/siputils_admin.xml

@@ -225,7 +225,7 @@ modparam("siputils", "options_support", "100rel")
 			<para>
 			<para>
 			Inserting the call-id in the internal list, which is checked when
 			Inserting the call-id in the internal list, which is checked when
 			further replies arrive. Any 183 reply that is received during the
 			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.
 			need to set a positive timeout value in order to use this function.
 			</para>
 			</para>
 			<para>
 			<para>

+ 5 - 0
modules_k/siputils/ring.c

@@ -50,6 +50,7 @@
 #include "../../locking.h"
 #include "../../locking.h"
 #include "../../md5.h"
 #include "../../md5.h"
 
 
+#include "config.h"
 #include "ring.h"
 #include "ring.h"
 
 
 
 
@@ -174,6 +175,10 @@ static unsigned int hash(char *buf, int len)
  */
  */
 static void remove_timeout(unsigned int index)
 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()) {
 	while ((*hashtable)[index].head && ((*hashtable)[index].head)->time + ring_timeout < get_ticks()) {
 		struct ring_record_t* rr = (*hashtable)[index].head;
 		struct ring_record_t* rr = (*hashtable)[index].head;
 		(*hashtable)[index].head = rr->next;
 		(*hashtable)[index].head = rr->next;

+ 9 - 3
modules_k/siputils/siputils.c

@@ -74,6 +74,7 @@
 #include "utils.h"
 #include "utils.h"
 #include "contact_ops.h"
 #include "contact_ops.h"
 #include "sipops.h"
 #include "sipops.h"
+#include "config.h"
 
 
 MODULE_VERSION
 MODULE_VERSION
 
 
@@ -115,7 +116,7 @@ static cmd_export_t cmds[]={
 };
 };
 
 
 static param_export_t params[] = {
 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",          STR_PARAM, &opt_accept.s},
 	{"options_accept_encoding", STR_PARAM, &opt_accept_enc.s},
 	{"options_accept_encoding", STR_PARAM, &opt_accept_enc.s},
 	{"options_accept_language", STR_PARAM, &opt_accept_lang.s},
 	{"options_accept_language", STR_PARAM, &opt_accept_lang.s},
@@ -143,7 +144,7 @@ struct module_exports exports= {
 
 
 static int mod_init(void)
 static int mod_init(void)
 {
 {
-	if(ring_timeout > 0) {
+	if(default_siputils_cfg.ring_timeout > 0) {
 		ring_init_hashtable();
 		ring_init_hashtable();
 
 
 		ring_lock = lock_alloc();
 		ring_lock = lock_alloc();
@@ -163,7 +164,12 @@ static int mod_init(void)
 		LM_ERR("can't load SL API\n");
 		LM_ERR("can't load SL API\n");
 		return -1;
 		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.len = strlen(opt_accept.s);
 	opt_accept_enc.len = strlen(opt_accept_enc.s);
 	opt_accept_enc.len = strlen(opt_accept_enc.s);
 	opt_accept_lang.len = strlen(opt_accept_lang.s);
 	opt_accept_lang.len = strlen(opt_accept_lang.s);