瀏覽代碼

* modules/enum: enum_query() params may now contain pseudo variables.

Juha Heinanen 15 年之前
父節點
當前提交
e8a3c6dd30
共有 5 個文件被更改,包括 60 次插入31 次删除
  1. 17 15
      modules/enum/README
  2. 6 4
      modules/enum/doc/enum_admin.xml
  3. 32 8
      modules/enum/enum.c
  4. 1 0
      modules/enum/enum.h
  5. 4 4
      modules/enum/enum_mod.c

+ 17 - 15
modules/enum/README

@@ -8,7 +8,7 @@ Otmar Lendl
 
 
    <[email protected]>
    <[email protected]>
 
 
-   Copyright © 2002, 2003 Juha Heinanen
+   Copyright © 2002, 2003 Juha Heinanen
    Revision History
    Revision History
    Revision $Revision$ $Date$
    Revision $Revision$ $Date$
      __________________________________________________________________
      __________________________________________________________________
@@ -76,9 +76,9 @@ Chapter 1. Admin Guide
    phone number of the form +decimal-digits, where the number of digits is
    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
    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
    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
    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
    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
    branch off from the default, user-ENUM tree to an infrastructure ENUM
    tree.
    tree.
@@ -146,7 +146,7 @@ Chapter 1. Admin Guide
    digits of an E164 number. Can be overridden by a parameter to
    digits of an E164 number. Can be overridden by a parameter to
    enum_query.
    enum_query.
 
 
-   Default value is "e164.arpa."
+   Default value is “e164.arpa.�
 
 
    Example 1.1. Setting domain_suffix module parameter
    Example 1.1. Setting domain_suffix module parameter
 modparam("enum", "domain_suffix", "e1234.arpa.")
 modparam("enum", "domain_suffix", "e1234.arpa.")
@@ -161,7 +161,7 @@ Note
    Currently Kamailio does not support tel URIs. This means that at
    Currently Kamailio does not support tel URIs. This means that at
    present tel_uri_params is appended as URI parameters to every URI.
    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
    Example 1.2. Setting tel_uri_params module parameter
 modparam("enum", "tel_uri_params", ";npdi")
 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
    The domain suffix to be used for i_enum_query() lookups. Can be
    overridden by a parameter to i_enum_query.
    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
    Example 1.3. Setting i_enum_suffix module parameter
 modparam("enum", "i_enum_suffix", "e1234.arpa.")
 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
    This parameter determines which label i_enum_query() will use to branch
    off to the infrastructure ENUM tree.
    off to the infrastructure ENUM tree.
 
 
-   Default value is ""i""
+   Default value is “"i"�
 
 
    Example 1.4. Setting brachlabel module parameter
    Example 1.4. Setting brachlabel module parameter
 modparam("enum", "branchlabel", "i")
 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"
 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
    Example 1.7. Setting the bl_algorithm module parameter
 modparam("enum", "bl_algorithm", "txt")
 modparam("enum", "bl_algorithm", "txt")
@@ -232,15 +232,17 @@ modparam("enum", "bl_algorithm", "txt")
    4.3. i_enum_query(["suffix"[,"service"]])
    4.3. i_enum_query(["suffix"[,"service"]])
    4.4. is_from_user_enum()
    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 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.
    information.
 
 
    Meaning of the parameters is as follows:
    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.
    This function can be used from REQUEST_ROUTE.
 
 
@@ -266,11 +268,11 @@ enum_query("e164.arpa.","voice");
 enum_query("e164.arpa.","+sip+voice:sip");
 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
    The function performs an enum query on E.164 number stored in its
    pseudo variable argument and rewrites the Request-URI with the result
    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:
    Meaning of the parameters is as follows:
      * pvar - Pseudo variable that holds an E.164 number on which enum
      * 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");
 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 function performs an enum query and rewrites the Request-URI with
    the result of the query. This the Infrastructure-ENUM version of
    the result of the query. This the Infrastructure-ENUM version of

+ 6 - 4
modules/enum/doc/enum_admin.xml

@@ -247,13 +247,15 @@ modparam("enum", "bl_algorithm", "txt")
 		<para>Meaning of the parameters is as follows:</para>
 		<para>Meaning of the parameters is as follows:</para>
 		<itemizedlist>
 		<itemizedlist>
 		<listitem>
 		<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>
 			</para>
 		</listitem>
 		</listitem>
 		<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>
 			</para>
 		</listitem>
 		</listitem>
 		</itemizedlist>
 		</itemizedlist>

+ 32 - 8
modules/enum/enum.c

@@ -51,6 +51,7 @@
 #include <stdlib.h>
 #include <stdlib.h>
 
 
 #include "enum.h"
 #include "enum.h"
+#include "../../sr_module.h"
 #include "../../parser/parse_uri.h"
 #include "../../parser/parse_uri.h"
 #include "../../parser/parse_from.h"
 #include "../../parser/parse_from.h"
 #include "../../ut.h"
 #include "../../ut.h"
@@ -704,7 +705,7 @@ done:
  */
  */
 int enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2)
 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)
 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)
 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;
 	char *user_s;
 	int user_len, i, j;
 	int user_len, i, j;
 	char name[MAX_DOMAIN_SIZE];
 	char name[MAX_DOMAIN_SIZE];
 	char string[17];
 	char string[17];
 
 
-	str *suffix, *service;
-
-	suffix = (str*)_suffix;
-	service = (str*)_service;
-
 	if (parse_sip_msg_uri(_msg) < 0) {
 	if (parse_sip_msg_uri(_msg) < 0) {
 		LM_ERR("Parsing of R-URI failed\n");
 		LM_ERR("Parsing of R-URI failed\n");
 		return -1;
 		return -1;

+ 1 - 0
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
  * Make enum query and if query succeeds, replace current uri with the
  * result of the query
  * 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_0(struct sip_msg* _msg, char* _str1, char* _str2);
 int enum_query_1(struct sip_msg* _msg, char* _suffix, 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);
 int enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service);

+ 4 - 4
modules/enum/enum_mod.c

@@ -80,10 +80,10 @@ str i_bl_alg;
  */
  */
 static cmd_export_t cmds[] = {
 static cmd_export_t cmds[] = {
 	{"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE},
 	{"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,
 	{"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null,
 	 fixup_free_pvar_null, REQUEST_ROUTE},
 	 fixup_free_pvar_null, REQUEST_ROUTE},
 	{"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,
 	{"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,