Skip to content

Commit

Permalink
enum: Move the "number" optional parameter last
Browse files Browse the repository at this point in the history
This preserves the backwards-compatibility of enum_query().
Additionally, "number" is the least used of the optional paramters, so
it makes more sense for it to go last.

Suggested by Dan Pascu
  • Loading branch information
liviuchircu committed Apr 22, 2019
1 parent 687b3e4 commit a1da98c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
25 changes: 13 additions & 12 deletions modules/enum/doc/enum_admin.xml
Expand Up @@ -261,7 +261,7 @@ modparam("enum", "bl_algorithm", "txt")
<title>Exported Functions</title>
<section id="func_enum_query" xreflabel="enum_query()">
<title>
<function moreinfo="none">enum_query([number], [suffix], [service])</function>
<function moreinfo="none">enum_query([suffix], [service], [number])</function>
</title>
<para>
The function performs an ENUM query on a given E.164 "number" (or R-URI
Expand All @@ -271,11 +271,6 @@ modparam("enum", "bl_algorithm", "txt")
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>number (string, optional)</emphasis> - an E.164 number
packed as a string on which the ENUM query is performed
</para>
</listitem>
<listitem>
<para><emphasis>suffix (string, optional)</emphasis> - suffix to be appended to the
domain name, <xref linkend="param_domain_suffix"/> if missing</para>
Expand All @@ -285,6 +280,12 @@ modparam("enum", "bl_algorithm", "txt")
the service field
</para>
</listitem>
<listitem>
<para><emphasis>number (string, optional)</emphasis> - an specific
E.164 number packed as a string on which the ENUM query is
performed, other the R-URI username ($rU) will be used
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE.
Expand All @@ -294,23 +295,23 @@ modparam("enum", "bl_algorithm", "txt")
<programlisting format="linespecific">
...
# search for "e2u+sip" in freenum.org
enum_query($avp(number), "freenum.org.");
enum_query("freenum.org.", , $avp(number));
...
# search for "e2u+sip" in default tree (configured as parameter)
enum_query();
...
# search for "e2u+voice:sip" in e164.arpa
enum_query(, "e164.arpa.", "voice");
enum_query("e164.arpa.", "voice");
...
# search for service type "sip" or "voice:sip" or "video:sip"
# note the '+' sign in front of the second parameter
enum_query($avp(number), "e164.arpa.", "+sip+voice:sip+video:sip");
enum_query("e164.arpa.", "+sip+voice:sip+video:sip", $avp(number));
...
# querying for service sip and voice:sip
enum_query(, "e164.arpa.");
enum_query(, "e164.arpa.", "voice");
enum_query("e164.arpa.");
enum_query("e164.arpa.", "voice");
# or use instead
enum_query(, "e164.arpa.", "+sip+voice:sip");
enum_query("e164.arpa.", "+sip+voice:sip");
...
</programlisting>
</example>
Expand Down
2 changes: 1 addition & 1 deletion modules/enum/enum.c
Expand Up @@ -660,7 +660,7 @@ int do_query(struct sip_msg* _msg, char *user, char *name, str *service) {
/*
* See documentation in README file.
*/
int enum_query(struct sip_msg* _msg, str* _num, str* _suffix, str* _service)
int enum_query(struct sip_msg* _msg, str* _suffix, str* _service, str* _num)
{
char *user_s;
int user_len, i, j;
Expand Down
2 changes: 1 addition & 1 deletion modules/enum/enum.h
Expand Up @@ -41,7 +41,7 @@ int is_from_user_enum(struct sip_msg* _msg, str* _suffix, str* _service);
* Make enum query and if query succeeds, replace current uri with the
* result of the query
*/
int enum_query(struct sip_msg* _msg, str* _num, str* _suffix, str* _service);
int enum_query(struct sip_msg* _msg, str* _suffix, str* _service, str* _num);

/*
* Infrastructure ENUM versions.
Expand Down
4 changes: 2 additions & 2 deletions modules/enum/enum_mod.c
Expand Up @@ -79,11 +79,11 @@ str isnsuffix;

static cmd_export_t cmds[] = {
{"enum_query", (cmd_function)enum_query, {
{CMD_PARAM_STR | CMD_PARAM_OPT, 0, 0},
{CMD_PARAM_STR | CMD_PARAM_OPT | CMD_PARAM_FIX_NULL,
fixup_enum_suffix, 0},
{CMD_PARAM_STR | CMD_PARAM_OPT | CMD_PARAM_FIX_NULL,
fixup_enum_service, 0}, {0,0,0}},
fixup_enum_service, 0},
{CMD_PARAM_STR | CMD_PARAM_OPT, 0, 0}, {0, 0, 0}},
REQUEST_ROUTE},
{"i_enum_query", (cmd_function)i_enum_query, {
{CMD_PARAM_STR | CMD_PARAM_OPT | CMD_PARAM_FIX_NULL,
Expand Down

0 comments on commit a1da98c

Please sign in to comment.