Module: sip-router
Branch: master
Commit: e8a3c6dd30b2123a385380b44e9975697f628f01
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e8a3c6d…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Juha Heinanen <jh(a)tutpro.com>
Date: Wed Mar 24 23:03:48 2010 +0200
* modules/enum: enum_query() params may now contain pseudo variables.
---
modules/enum/README | 32 ++++++++++++++++--------------
modules/enum/doc/enum_admin.xml | 10 +++++---
modules/enum/enum.c | 40 +++++++++++++++++++++++++++++++-------
modules/enum/enum.h | 1 +
modules/enum/enum_mod.c | 8 +++---
5 files changed, 60 insertions(+), 31 deletions(-)
diff --git a/modules/enum/README b/modules/enum/README
index c7ce8ea..24f727c 100644
--- a/modules/enum/README
+++ b/modules/enum/README
@@ -8,7 +8,7 @@ Otmar Lendl
<lendl(a)nic.at>
- Copyright � 2002, 2003 Juha Heinanen
+ Copyright © 2002, 2003 Juha Heinanen
Revision History
Revision $Revision$ $Date$
__________________________________________________________________
@@ -76,9 +76,9 @@ Chapter 1. Admin Guide
phone number of the form +decimal-digits, where the number of digits is
at least 2 and at most 15. Out of this number enum_query forms a domain
name, where the digits are in reverse order and separated by dots
- followed by domain suffix that by default is "e164.arpa.". For example,
+ followed by domain suffix that by default is “e164.arpa.”. For example,
if the user part is +35831234567, the domain name will be
- "7.6.5.4.3.2.1.3.8.5.3.e164.arpa.". i_enum_query operates in a similar
+ “7.6.5.4.3.2.1.3.8.5.3.e164.arpa.”. i_enum_query operates in a similar
fashion. The only difference is that it adds a label (default "i") to
branch off from the default, user-ENUM tree to an infrastructure ENUM
tree.
@@ -146,7 +146,7 @@ Chapter 1. Admin Guide
digits of an E164 number. Can be overridden by a parameter to
enum_query.
- Default value is "e164.arpa."
+ Default value is “e164.arpa.”
Example 1.1. Setting domain_suffix module parameter
modparam("enum", "domain_suffix", "e1234.arpa.")
@@ -161,7 +161,7 @@ Note
Currently Kamailio does not support tel URIs. This means that at
present tel_uri_params is appended as URI parameters to every URI.
- Default value is ""
+ Default value is “”
Example 1.2. Setting tel_uri_params module parameter
modparam("enum", "tel_uri_params", ";npdi")
@@ -171,7 +171,7 @@ modparam("enum", "tel_uri_params",
";npdi")
The domain suffix to be used for i_enum_query() lookups. Can be
overridden by a parameter to i_enum_query.
- Default value is "e164.arpa."
+ Default value is “e164.arpa.”
Example 1.3. Setting i_enum_suffix module parameter
modparam("enum", "i_enum_suffix", "e1234.arpa.")
@@ -181,7 +181,7 @@ modparam("enum", "i_enum_suffix",
"e1234.arpa.")
This parameter determines which label i_enum_query() will use to branch
off to the infrastructure ENUM tree.
- Default value is ""i""
+ Default value is “"i"”
Example 1.4. Setting brachlabel module parameter
modparam("enum", "branchlabel", "i")
@@ -220,7 +220,7 @@ i.1.e164.arpa. TYPE65300 \# 14 (
; )
9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678
999"
- Default value is "cc"
+ Default value is “cc”
Example 1.7. Setting the bl_algorithm module parameter
modparam("enum", "bl_algorithm", "txt")
@@ -232,15 +232,17 @@ modparam("enum", "bl_algorithm",
"txt")
4.3. i_enum_query(["suffix"[,"service"]])
4.4. is_from_user_enum()
-4.1. enum_query(["suffix"[,"service"]])
+4.1. enum_query(["suffix"[,"service"]])
The function performs an enum query and rewrites the Request-URI with
- the result of the query. See Section 1, "Overview" for more
+ the result of the query. See Section 1, “Overview” for more
information.
Meaning of the parameters is as follows:
- * suffix - Suffix to be appended to the domain name.
- * service - Service string to be used in the service field.
+ * suffix - Suffix string to be appended to the domain name. String
+ may contain pseudo variables.
+ * service - Service string to be used in the service field. String
+ may contain pseudo variables.
This function can be used from REQUEST_ROUTE.
@@ -266,11 +268,11 @@ enum_query("e164.arpa.","voice");
enum_query("e164.arpa.","+sip+voice:sip");
...
-4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
+4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
The function performs an enum query on E.164 number stored in its
pseudo variable argument and rewrites the Request-URI with the result
- of the query. See Section 1, "Overview" for more information.
+ of the query. See Section 1, “Overview” for more information.
Meaning of the parameters is as follows:
* pvar - Pseudo variable that holds an E.164 number on which enum
@@ -302,7 +304,7 @@
enum_pv_query("$avp(i:100)","e164.arpa.","voice");
enum_pv_query("$avp(i:100)","e164.arpa.","+sip+voice:sip");
...
-4.3. i_enum_query(["suffix"[,"service"]])
+4.3. i_enum_query(["suffix"[,"service"]])
The function performs an enum query and rewrites the Request-URI with
the result of the query. This the Infrastructure-ENUM version of
diff --git a/modules/enum/doc/enum_admin.xml b/modules/enum/doc/enum_admin.xml
index ede74c4..8560049 100644
--- a/modules/enum/doc/enum_admin.xml
+++ b/modules/enum/doc/enum_admin.xml
@@ -247,13 +247,15 @@ modparam("enum", "bl_algorithm",
"txt")
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
- <para><emphasis>suffix</emphasis> - Suffix to be appended to the
- domain name.
+ <para><emphasis>suffix</emphasis> - Suffix
+ string to be appended to the domain name. String may contain
+ pseudo variables.
</para>
</listitem>
<listitem>
- <para><emphasis>service</emphasis> - Service string to be used in
- the service field.
+ <para><emphasis>service</emphasis> - Service
+ string to be used in the service field. String may contain
+ pseudo variables.
</para>
</listitem>
</itemizedlist>
diff --git a/modules/enum/enum.c b/modules/enum/enum.c
index 80793f7..ba4fc48 100644
--- a/modules/enum/enum.c
+++ b/modules/enum/enum.c
@@ -51,6 +51,7 @@
#include <stdlib.h>
#include "enum.h"
+#include "../../sr_module.h"
#include "../../parser/parse_uri.h"
#include "../../parser/parse_from.h"
#include "../../ut.h"
@@ -704,7 +705,7 @@ done:
*/
int enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2)
{
- return enum_query_2(_msg, (char *)(&suffix), (char *)(&service));
+ return enum_query(_msg, &suffix, &service);
}
@@ -713,25 +714,48 @@ int enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2)
*/
int enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2)
{
- return enum_query_2(_msg, _suffix, (char *)(&service));
+ str suffix;
+
+ if (get_str_fparam(&suffix, _msg, (fparam_t*)_suffix) != 0) {
+ LM_ERR("unable to get suffix\n");
+ return -1;
+ }
+
+ return enum_query(_msg, &suffix, &service);
}
/*
- * See documentation in README file.
+ * Call enum_query_2 with given suffix and service.
*/
int enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service)
{
+ str suffix, service;
+
+ if (get_str_fparam(&suffix, _msg, (fparam_t*)_suffix) != 0) {
+ LM_ERR("unable to get suffix\n");
+ return -1;
+ }
+
+ if (get_str_fparam(&service, _msg, (fparam_t*)_service) != 0) {
+ LM_ERR("unable to get service\n");
+ return -1;
+ }
+
+ return enum_query(_msg, &suffix, &service);
+}
+
+
+/*
+ * See documentation in README file.
+ */
+int enum_query(struct sip_msg* _msg, str* suffix, str* service)
+{
char *user_s;
int user_len, i, j;
char name[MAX_DOMAIN_SIZE];
char string[17];
- str *suffix, *service;
-
- suffix = (str*)_suffix;
- service = (str*)_service;
-
if (parse_sip_msg_uri(_msg) < 0) {
LM_ERR("Parsing of R-URI failed\n");
return -1;
diff --git a/modules/enum/enum.h b/modules/enum/enum.h
index bcd9fea..2dffce0 100644
--- a/modules/enum/enum.h
+++ b/modules/enum/enum.h
@@ -61,6 +61,7 @@ int enum_pv_query_3(struct sip_msg* _msg, char* _sp, char* _suffix,
* Make enum query and if query succeeds, replace current uri with the
* result of the query
*/
+int enum_query(struct sip_msg* _msg, str* suffix, str* service);
int enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2);
int enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2);
int enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service);
diff --git a/modules/enum/enum_mod.c b/modules/enum/enum_mod.c
index 1215178..0ec1bb9 100644
--- a/modules/enum/enum_mod.c
+++ b/modules/enum/enum_mod.c
@@ -80,10 +80,10 @@ str i_bl_alg;
*/
static cmd_export_t cmds[] = {
{"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE},
- {"enum_query", (cmd_function)enum_query_1, 1, fixup_str_null,
- fixup_free_str_null, REQUEST_ROUTE},
- {"enum_query", (cmd_function)enum_query_2, 2, fixup_str_str,
- fixup_free_str_str, REQUEST_ROUTE},
+ {"enum_query", (cmd_function)enum_query_1, 1, fixup_spve_null, 0,
+ REQUEST_ROUTE},
+ {"enum_query", (cmd_function)enum_query_2, 2, fixup_spve_str, 0,
+ REQUEST_ROUTE},
{"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null,
fixup_free_pvar_null, REQUEST_ROUTE},
{"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,