Skip to content

Commit

Permalink
cplc: use route names to set proxy_route modparam
Browse files Browse the repository at this point in the history
- Changed proxy_route modparam type to string. The route to be executed
  needs to be defined by name as the current id definition led to some
  unpredictable behavior.

(cherry picked from commit 027871f)
  • Loading branch information
ocapsada authored and miconda committed Aug 30, 2017
1 parent adfc7f6 commit 4ce1210
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/modules/cplc/cplc.c
Expand Up @@ -62,6 +62,7 @@ static str db_table = str_init("cpl"); /* database table */
static char *dtd_file = 0; /* name of the DTD file for CPL parser */
static char *lookup_domain = 0;
static str timer_avp = STR_NULL; /* name of variable timer AVP */
static str proxy_route = STR_NULL;


struct cpl_enviroment cpl_env = {
Expand Down Expand Up @@ -132,7 +133,7 @@ static param_export_t params[] = {
{"db_table", PARAM_STR, &db_table },
{"cpl_dtd_file", PARAM_STRING, &dtd_file },
{"proxy_recurse", INT_PARAM, &cpl_env.proxy_recurse },
{"proxy_route", INT_PARAM, &cpl_env.proxy_route },
{"proxy_route", PARAM_STR, &proxy_route },
{"log_dir", PARAM_STRING, &cpl_env.log_dir },
{"case_sensitive", INT_PARAM, &cpl_env.case_sensitive },
{"realm_prefix", PARAM_STR, &cpl_env.realm_prefix },
Expand Down Expand Up @@ -232,6 +233,14 @@ static int cpl_init(void)
goto error;
}

if (proxy_route.len>0) {
cpl_env.proxy_route=route_lookup(&main_rt, proxy_route.s);
if (cpl_env.proxy_route==-1) {
LM_CRIT("route <%s> defined in proxy_route does not exist\n",proxy_route.s);
goto error;
}
}

/* fix the timer_avp name */
if (timer_avp.s && timer_avp.len > 0) {
if (pv_parse_spec(&timer_avp, &avp_spec)==0
Expand Down
6 changes: 3 additions & 3 deletions src/modules/cplc/doc/cplc_admin.xml
Expand Up @@ -280,22 +280,22 @@ modparam("cpl-c","proxy_recurse",2)
</example>
</section>
<section>
<title><varname>proxy_route</varname> (int)</title>
<title><varname>proxy_route</varname> (string)</title>
<para>
Before doing proxy (forward), a script route can be executed.
All modifications made by that route will be reflected only for
the current branch.
</para>
<para>
<emphasis>
Default value of this parameter is 0 (none).
Default value of this parameter is NULL (none).
</emphasis>
</para>
<example>
<title>Set <varname>proxy_route</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("cpl-c","proxy_route",1)
modparam("cpl-c","proxy_route","1")
...
</programlisting>
</example>
Expand Down

0 comments on commit 4ce1210

Please sign in to comment.