[sr-dev] git:master:609110d0: dialplan: Added dp_reload function
Luis Martin Gil
martingil.luis at gmail.com
Fri Jun 10 13:14:53 CEST 2016
Module: kamailio
Branch: master
Commit: 609110d05eafbf43cb53353c38020e4c66b60800
URL: https://github.com/kamailio/kamailio/commit/609110d05eafbf43cb53353c38020e4c66b60800
Author: Luis Martin Gil <martingil.luis at gmail.com>
Committer: Luis Martin Gil <martingil.luis at gmail.com>
Date: 2016-06-10T11:39:31+02:00
dialplan: Added dp_reload function
---
Modified: modules/dialplan/dialplan.c
Modified: modules/dialplan/doc/dialplan.xml
Modified: modules/dialplan/doc/dialplan_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/609110d05eafbf43cb53353c38020e4c66b60800.diff
Patch: https://github.com/kamailio/kamailio/commit/609110d05eafbf43cb53353c38020e4c66b60800.patch
---
diff --git a/modules/dialplan/dialplan.c b/modules/dialplan/dialplan.c
index 9a7fe33..a0c679a 100644
--- a/modules/dialplan/dialplan.c
+++ b/modules/dialplan/dialplan.c
@@ -73,6 +73,7 @@ static struct mi_root * mi_reload_rules(struct mi_root *cmd_tree,void *param);
static struct mi_root * mi_translate(struct mi_root *cmd_tree, void *param);
static int dp_translate_f(struct sip_msg* msg, char* str1, char* str2);
static int dp_trans_fixup(void ** param, int param_no);
+static int dp_reload_f(struct sip_msg* msg);
str attr_pvar_s = STR_NULL;
pv_spec_t * attr_pvar = NULL;
@@ -111,6 +112,8 @@ static cmd_export_t cmds[]={
ANY_ROUTE},
{"dp_translate",(cmd_function)dp_translate_f, 1, dp_trans_fixup, 0,
ANY_ROUTE},
+ {"dp_reload",(cmd_function)dp_reload_f, 0, 0, 0,
+ ANY_ROUTE},
{0,0,0,0,0,0}
};
@@ -452,6 +455,27 @@ static int dp_trans_fixup(void ** param, int param_no){
return E_INVALID_PARAMS;
}
+static int dp_reload_f(struct sip_msg* msg)
+{
+ struct mi_root* rpl_tree= NULL;
+
+ if (dp_connect_db() < 0) {
+ LM_ERR("failed to reload rules fron database (db connect)\n");
+ return -1;
+ }
+
+ if(dp_load_db() != 0){
+ LM_ERR("failed to reload rules fron database (db load)\n");
+ dp_disconnect_db();
+ return -1;
+ }
+
+ dp_disconnect_db();
+
+ LM_DBG("reloaded dialplan\n");
+ return 1;
+}
+
static struct mi_root * mi_reload_rules(struct mi_root *cmd_tree, void *param)
{
diff --git a/modules/dialplan/doc/dialplan.xml b/modules/dialplan/doc/dialplan.xml
index 386e7eb..8118cbf 100644
--- a/modules/dialplan/doc/dialplan.xml
+++ b/modules/dialplan/doc/dialplan.xml
@@ -36,6 +36,13 @@
<firstname>Olle E.</firstname>
<surname>Johansson</surname>
</editor>
+ <editor>
+ <firstname>Luis</firstname>
+ <surname>Martin</surname>
+ <address>
+ <email>martingil.luis at gmail.com</email>
+ </address>
+ </editor>
</authorgroup>
<copyright>
<year>2007-2008</year>
diff --git a/modules/dialplan/doc/dialplan_admin.xml b/modules/dialplan/doc/dialplan_admin.xml
index 5bfa870..63fc4ce 100644
--- a/modules/dialplan/doc/dialplan_admin.xml
+++ b/modules/dialplan/doc/dialplan_admin.xml
@@ -496,6 +496,22 @@ xlog("translated to var $var(y) \n");
</section>
+ <section id="dispatcher.f.dp_reload">
+ <title>
+ <function moreinfo="none">dp_reload()</function>
+ </title>
+ <para>
+ Forces an update of the translation rules from the database.
+ </para>
+ <para>
+ Name: <emphasis>dp_reload</emphasis>
+ </para>
+ <para>Parameters: <emphasis>none</emphasis></para>
+ <para>
+ This function can be used from ANY_ROUTE.
+ </para>
+ </section>
+
</section>
More information about the sr-dev
mailing list