Skip to content

Commit

Permalink
Merge pull request #632 from shripchenko/alias_db
Browse files Browse the repository at this point in the history
alias_db module changed to allow alias_db_find() to be called from startup route
  • Loading branch information
bogdan-iancu committed Jan 25, 2016
2 parents e210f45 + 39e34d4 commit a61a88d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
16 changes: 8 additions & 8 deletions modules/alias_db/README
Expand Up @@ -180,8 +180,8 @@ modparam("alias_db", "append_branches", 1)
by user's SIP uri.

Meaning of the parameters is as follows:
* table_name - the name of the table where to search for
alias. It can include pseudo-variables.
* table_name - any PV (string or PV or mix) the name of the
table where to search for alias.
* flags (optional) - set of flags (char based flags) to
control the alias lookup process:
+ d - do not use domain URI part in the alias lookup
Expand Down Expand Up @@ -216,11 +216,11 @@ alias_db_lookup("dba_$(rU{s.substr,0,1})");
returned.

Meaning of the parameters is as follows:
* table_name - the name of the table where to search for
alias. It can include pseudo-variables.
* input - any PV (pseudo-variable) carrying the SIP URI that
needs to be looked up.
* ouput - PV (AVP or script VAR) where to place the SIP URI
* table_name - any PV (string or PV or mix) the name of the
table where to search for alias.
* input - any PV (string or PV or mix) carrying the SIP URI
that needs to be looked up.
* output - PV (AVP or script VAR) where to place the SIP URI
resulting from the alias lookup.
* flags (optional) - set of flags (char based flags) to
control the alias lookup process:
Expand All @@ -233,7 +233,7 @@ alias_db_lookup("dba_$(rU{s.substr,0,1})");
the alias (alias 2 URI translation).

This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
LOCAL_ROUTE, FAILURE_ROUTE and ONREPLY_ROUTE.
LOCAL_ROUTE, STARTUP_ROUTE, FAILURE_ROUTE and ONREPLY_ROUTE.

Example 1.9. alias_db_find() usage
...
Expand Down
12 changes: 6 additions & 6 deletions modules/alias_db/alias_db.c
Expand Up @@ -75,9 +75,9 @@ static cmd_export_t cmds[] = {
{"alias_db_lookup", (cmd_function)alias_db_lookup, 2, lookup_fixup, 0,
REQUEST_ROUTE|FAILURE_ROUTE},
{"alias_db_find", (cmd_function)alias_db_find, 3, find_fixup, 0,
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE|STARTUP_ROUTE},
{"alias_db_find", (cmd_function)alias_db_find, 4, find_fixup, 0,
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE|STARTUP_ROUTE},
{0, 0, 0, 0, 0, 0}
};

Expand Down Expand Up @@ -158,7 +158,7 @@ static int lookup_fixup(void** param, int param_no)
{
if (param_no==1) {
/* string or pseudo-var - table name */
return fixup_spve_null(param, 1);
return fixup_spve(param);
} else if (param_no==2) {
/* string - flags ? */
return alias_flags_fixup(param);
Expand All @@ -175,10 +175,10 @@ static int find_fixup(void** param, int param_no)

if (param_no==1) {
/* string or pseudo-var - table name */
return fixup_spve_null(param, 1);
return fixup_spve(param);
} else if(param_no==2) {
/* pseudo-var - source URI */
return fixup_pvar(param);
/* string or pseudo-var - source URI */
return fixup_spve(param);
} else if(param_no==3) {
/* pvar (AVP or VAR) - destination URI */
if (fixup_pvar(param))
Expand Down
14 changes: 5 additions & 9 deletions modules/alias_db/alookup.c
Expand Up @@ -272,20 +272,16 @@ static inline int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, vo
int alias_db_find(struct sip_msg* _msg, char* _table, char* _in, char* _out,
char* flags)
{
pv_value_t val;
str _in_s;
struct sip_uri puri;

/* get the input value */
if (pv_get_spec_value(_msg, (pv_spec_t*)_in, &val)!=0) {
LM_ERR("failed to get PV value\n");
return -1;
}
if ( (val.flags&PV_VAL_STR)==0 ) {
LM_ERR("PV vals is not string\n");
if(_in==NULL || fixup_get_svalue(_msg, (gparam_p)_in, &_in_s)!=0) {
LM_ERR("invalid input parameter\n");
return -1;
}
if (parse_uri(val.rs.s, val.rs.len, &puri)<0) {
LM_ERR("failed to parse uri %.*s\n",val.rs.len,val.rs.s);
if (parse_uri(_in_s.s, _in_s.len, &puri)<0) {
LM_ERR("failed to parse uri %.*s\n",_in_s.len,_in_s.s);
return -1;
}

Expand Down
14 changes: 7 additions & 7 deletions modules/alias_db/doc/alias_db_admin.xml
Expand Up @@ -213,8 +213,8 @@ modparam("alias_db", "append_branches", 1)
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>table_name</emphasis> - the name of the table
where to search for alias. It can include pseudo-variables.
<para><emphasis>table_name</emphasis> - any PV (string or PV or mix)
the name of the table where to search for alias.
</para>
</listitem>
<listitem>
Expand Down Expand Up @@ -275,17 +275,17 @@ alias_db_lookup("dba_$(rU{s.substr,0,1})");
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>table_name</emphasis> - the name of the table
where to search for alias. It can include pseudo-variables.
<para><emphasis>table_name</emphasis> - any PV (string or PV or mix)
the name of the table where to search for alias.
</para>
</listitem>
<listitem>
<para><emphasis>input</emphasis> - any PV (pseudo-variable)
<para><emphasis>input</emphasis> - any PV (string or PV or mix)
carrying the SIP URI that needs to be looked up.
</para>
</listitem>
<listitem>
<para><emphasis>ouput</emphasis> - PV (AVP or script VAR)
<para><emphasis>output</emphasis> - PV (AVP or script VAR)
where to place the SIP URI resulting from the alias lookup.
</para>
</listitem>
Expand All @@ -312,7 +312,7 @@ alias_db_lookup("dba_$(rU{s.substr,0,1})");
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
LOCAL_ROUTE, FAILURE_ROUTE and ONREPLY_ROUTE.
LOCAL_ROUTE, STARTUP_ROUTE, FAILURE_ROUTE and ONREPLY_ROUTE.
</para>
<example>
<title><function>alias_db_find()</function> usage</title>
Expand Down

0 comments on commit a61a88d

Please sign in to comment.