Wed, 10 Feb 2010 21:40:10 +0100
Changes accepted by upstream vendor and merged into trunk revision 6590.
http://opensips.svn.sourceforge.net/viewvc/opensips?view=rev&revision=6590
svn co -r 6590 https://opensips.svn.sourceforge.net/svnroot/opensips/trunk
opensips/enum-isn.diff | file | annotate | diff | comparison | revisions | |
opensips/enum-isn.txt | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/README | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/doc/enum.xml | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/doc/enum_admin.xml | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/enum.c | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/enum.h | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/enum_mod.c | file | annotate | diff | comparison | revisions | |
opensips/modules/enum/enum_mod.h | file | annotate | diff | comparison | revisions |
1.1 --- a/opensips/enum-isn.diff Wed Feb 10 21:25:01 2010 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,502 +0,0 @@ 1.4 -Index: modules/enum/enum_mod.h 1.5 -diff -Nau modules/enum/enum_mod.h.orig modules/enum/enum_mod.h 1.6 ---- modules/enum/enum_mod.h.orig 2010-01-18 15:54:52.842465412 +0100 1.7 -+++ modules/enum/enum_mod.h 2010-01-18 15:55:20.812190874 +0100 1.8 -@@ -41,5 +41,7 @@ 1.9 - extern str i_branchlabel; /* the label branching off the infrastructure tree */ 1.10 - extern str i_bl_alg; /* how to know where to branch off */ 1.11 - 1.12 -+extern str isnsuffix; /* str version of isn_suffix */ 1.13 -+ 1.14 - 1.15 - #endif /* ENUM_MOD_H */ 1.16 -Index: modules/enum/enum_mod.c 1.17 -diff -Nau modules/enum/enum_mod.c.orig modules/enum/enum_mod.c 1.18 ---- modules/enum/enum_mod.c.orig 2010-01-18 15:52:57.316263519 +0100 1.19 -+++ modules/enum/enum_mod.c 2010-01-18 15:52:42.844229824 +0100 1.20 -@@ -55,6 +55,8 @@ 1.21 - char* i_enum_suffix = "e164.arpa."; 1.22 - char* bl_algorithm = "cc"; 1.23 - 1.24 -+char* isn_suffix = "freenum.org."; 1.25 -+ 1.26 - 1.27 - /* 1.28 - * Internal module variables 1.29 -@@ -67,6 +69,8 @@ 1.30 - str i_branchlabel; 1.31 - str i_bl_alg; 1.32 - 1.33 -+str isnsuffix; 1.34 -+ 1.35 - 1.36 - /* 1.37 - * Exported functions 1.38 -@@ -94,6 +98,11 @@ 1.39 - REQUEST_ROUTE}, 1.40 - {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0, 1.41 - REQUEST_ROUTE}, 1.42 -+ {"isn_query", (cmd_function)isn_query_0, 0, 0, 0, REQUEST_ROUTE}, 1.43 -+ {"isn_query", (cmd_function)isn_query_1, 1, fixup_str_null, 1.44 -+ fixup_free_str_null, REQUEST_ROUTE}, 1.45 -+ {"isn_query", (cmd_function)isn_query_2, 2, fixup_str_str, 1.46 -+ fixup_free_str_str, REQUEST_ROUTE}, 1.47 - {0, 0, 0, 0, 0, 0} 1.48 - }; 1.49 - 1.50 -@@ -107,6 +116,7 @@ 1.51 - {"branchlabel", STR_PARAM, &branchlabel}, 1.52 - {"i_enum_suffix", STR_PARAM, &i_enum_suffix}, 1.53 - {"bl_algorithm", STR_PARAM, &bl_algorithm}, 1.54 -+ {"isn_suffix", STR_PARAM, &isn_suffix}, 1.55 - {0, 0, 0} 1.56 - }; 1.57 - 1.58 -@@ -152,6 +162,9 @@ 1.59 - i_bl_alg.s = bl_algorithm; 1.60 - i_bl_alg.len = strlen(bl_algorithm); 1.61 - 1.62 -+ isnsuffix.s = isn_suffix; 1.63 -+ isnsuffix.len = strlen(isn_suffix.s); 1.64 -+ 1.65 - return 0; 1.66 - } 1.67 - 1.68 -Index: modules/enum/enum.h 1.69 -diff -Nau modules/enum/enum.h.orig modules/enum/enum.h 1.70 ---- modules/enum/enum.h.orig 2010-01-18 15:54:40.361624448 +0100 1.71 -+++ modules/enum/enum.h 2010-01-18 15:54:43.090330399 +0100 1.72 -@@ -66,5 +66,13 @@ 1.73 - int i_enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); 1.74 - int i_enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service); 1.75 - 1.76 -+/* 1.77 -+ * Make ISN query and if query succeeds, replace current uri with the 1.78 -+ * result of the query 1.79 -+ */ 1.80 -+int isn_query_0(struct sip_msg* _msg, char* _str1, char* _str2); 1.81 -+int isn_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); 1.82 -+int isn_query_2(struct sip_msg* _msg, char* _suffix, char* _service); 1.83 -+ 1.84 - 1.85 - #endif /* ENUM_H */ 1.86 -Index: modules/enum/enum.c 1.87 -diff -Nau modules/enum/enum.c.orig modules/enum/enum.c 1.88 ---- modules/enum/enum.c.orig 2010-01-18 15:57:10.995902181 +0100 1.89 -+++ modules/enum/enum.c 2010-01-18 15:46:19.642209178 +0100 1.90 -@@ -736,6 +736,84 @@ 1.91 - } 1.92 - 1.93 - 1.94 -+/* 1.95 -+ * Call isn_query_2 with module parameter suffix and default service. 1.96 -+ */ 1.97 -+int isn_query_0(struct sip_msg* _msg, char* _str1, char* _str2) 1.98 -+{ 1.99 -+ return isn_query_2(_msg, (char *)(&isnsuffix), (char *)(&service)); 1.100 -+} 1.101 -+ 1.102 -+ 1.103 -+/* 1.104 -+ * Call isn_query_2 with given suffix and default service. 1.105 -+ */ 1.106 -+int isn_query_1(struct sip_msg* _msg, char* _suffix, char* _str2) 1.107 -+{ 1.108 -+ return isn_query_2(_msg, _suffix, (char *)(&service)); 1.109 -+} 1.110 -+ 1.111 -+ 1.112 -+/* 1.113 -+ * See documentation in README file. 1.114 -+ */ 1.115 -+int isn_query_2(struct sip_msg* _msg, char* _suffix, char* _service) 1.116 -+{ 1.117 -+ char *user_s = NULL; 1.118 -+ int user_len, i, j; 1.119 -+ char name[MAX_DOMAIN_SIZE] = {0}; 1.120 -+ char string[17] = {0}; 1.121 -+ char szItad[17] = {0}; 1.122 -+ size_t nItlen = 0; 1.123 -+ 1.124 -+ str *suffix, *service; 1.125 -+ 1.126 -+ suffix = (str*)_suffix; 1.127 -+ service = (str*)_service; 1.128 -+ 1.129 -+ if (parse_sip_msg_uri(_msg) < 0) { 1.130 -+ LM_ERR("Parsing of R-URI failed\n"); 1.131 -+ return -1; 1.132 -+ } 1.133 -+ 1.134 -+ user_s = _msg->parsed_uri.user.s; 1.135 -+ user_len = _msg->parsed_uri.user.len; 1.136 -+ 1.137 -+ memcpy(&(string[0]), user_s, user_len); 1.138 -+ string[user_len] = (char)0; 1.139 -+ 1.140 -+ /* Do primitive test for correct ISN format, */ 1.141 -+ /* and set szItad to the ISN ITAD (RFC 3872/2871). */ 1.142 -+ /* Correct ISN format guessed from freenum.org and IANA */ 1.143 -+ /* doc http://www.iana.org/assignments/trip-parameters/ */ 1.144 -+ { 1.145 -+ char *pAster = strchr(string, '*'); 1.146 -+ if (pAster && (nItlen = strspn(pAster + sizeof(char), "0123456789"))) 1.147 -+ strncpy(szItad, pAster + sizeof(char), nItlen); 1.148 -+ else { 1.149 -+ LM_ERR("R-URI user does not contain a valid ISN\n"); 1.150 -+ return -1; 1.151 -+ } 1.152 -+ } 1.153 -+ 1.154 -+ /* Ammend the original ENUM E.164 string logic to process */ 1.155 -+ /* ISN numbers instead, which include a nonreversed ITAD. */ 1.156 -+ i = user_len - nItlen - sizeof(char); /* Ex: *1212 */ 1.157 -+ j = 0; 1.158 -+ while (i--) { 1.159 -+ name[j] = user_s[i]; 1.160 -+ name[j + 1] = '.'; 1.161 -+ j = j + 2; 1.162 -+ } 1.163 -+ 1.164 -+ strcat(name + j, szItad); /* Copy the unreversed ITAD, */ 1.165 -+ name[j + nItlen] = '.'; /* and append a trailing dot. */ 1.166 -+ memcpy(name + j + nItlen + sizeof(char), suffix->s, suffix->len + 1); 1.167 -+ 1.168 -+ return do_query(_msg, string, name, service); 1.169 -+} 1.170 -+ 1.171 -+ 1.172 - /*********** INFRASTRUCTURE ENUM ***************/ 1.173 - 1.174 - /* 1.175 -Index: modules/enum/README 1.176 -diff -Nau modules/enum/README.orig modules/enum/README 1.177 ---- modules/enum/README.orig 2010-01-18 17:59:52.034172367 +0100 1.178 -+++ modules/enum/README 2010-01-18 18:01:30.730633377 +0100 1.179 -@@ -10,8 +10,8 @@ 1.180 - 1.181 - Copyright © 2002, 2003 Juha Heinanen 1.182 - Revision History 1.183 -- Revision $Revision: 5906 $ $Date: 2009-07-21 10:45:05 +0300 1.184 -- (Tue, 21 Jul 2009) $ 1.185 -+ Revision $Revision: 5907 $ $Date: 2010-01-18 10:45:05 +0100 1.186 -+ (Mon, 18 Jan 2010) $ 1.187 - __________________________________________________________ 1.188 - 1.189 - Table of Contents 1.190 -@@ -25,28 +25,32 @@ 1.191 - 1.3.1. domain_suffix (string) 1.192 - 1.3.2. tel_uri_params (string) 1.193 - 1.3.3. i_enum_suffix (string) 1.194 -- 1.3.4. branchlabel (string) 1.195 -- 1.3.5. bl_algorithm (string) 1.196 -+ 1.3.4. isn_suffix (string) 1.197 -+ 1.3.5. branchlabel (string) 1.198 -+ 1.3.6. bl_algorithm (string) 1.199 - 1.200 - 1.4. Exported Functions 1.201 - 1.202 - 1.4.1. enum_query(["suffix"[,"service"]]) 1.203 - 1.4.2. enum_pv_query("pvar"[,"suffix"[,"service"]]) 1.204 - 1.4.3. i_enum_query(["suffix"[,"service"]]) 1.205 -- 1.4.4. is_from_user_enum() 1.206 -+ 1.4.4. isn_query(["suffix"[,"service"]]) 1.207 -+ 1.4.5. is_from_user_enum() 1.208 - 1.209 - List of Examples 1.210 - 1.211 - 1.1. Setting domain_suffix module parameter 1.212 - 1.2. Setting tel_uri_params module parameter 1.213 - 1.3. Setting i_enum_suffix module parameter 1.214 -- 1.4. Setting brachlabel module parameter 1.215 -- 1.5. Zone file example 1.216 -+ 1.4. Setting isn_query usage module parameter 1.217 -+ 1.5. Setting branchlabel module parameter 1.218 - 1.6. Zone file example 1.219 -- 1.7. Setting the bl_algorithm module parameter 1.220 -- 1.8. enum_query usage 1.221 -- 1.9. enum_pv_query usage 1.222 -- 1.10. is_from_user_enum usage 1.223 -+ 1.7. Zone file example 1.224 -+ 1.8. Setting the bl_algorithm module parameter 1.225 -+ 1.9. enum_query usage 1.226 -+ 1.10. enum_pv_query usage 1.227 -+ 1.11. isn_query usage 1.228 -+ 1.12. is_from_user_enum usage 1.229 - 1.230 - Chapter 1. Admin Guide 1.231 - 1.232 -@@ -113,6 +117,22 @@ 1.233 - function does an enum lookup on the from user and returns true 1.234 - if found, false otherwise. 1.235 - 1.236 -+ In addition to standard ENUM, support for ISN (ITAD Subscriber 1.237 -+ Numbers) is provided as well. To allow ISN lookups to resolve, 1.238 -+ a different formatting algorithm is expected by the DNS server. 1.239 -+ Whereas a ENUM NAPTR record expects a DNS query of the form 1.240 -+ 9.8.7.6.5.4.3.2.1.<suffix>, ISN method expects a DNS query of 1.241 -+ the form 6.5.1212.<suffix>. That is, a valid ISN number includes 1.242 -+ a prefix of '56' in the example. The rest of the number is a 1.243 -+ ITAD (Internet Telephony Administrative Domain) as defined 1.244 -+ in RFCs 3872 and 2871, and as allocated by the IANA in 1.245 -+ http://www.iana.org/assignments/trip-parameters. The ITAD is 1.246 -+ left intact and not refersed as ENUM requires. To learn more 1.247 -+ about ISN please refer to documents at www.freenum.org. 1.248 -+ 1.249 -+ To complete a ISN lookup on the user part of the Request-URI, 1.250 -+ isn_query() is used instead of enum_query(). 1.251 -+ 1.252 - 1.2. Dependencies 1.253 - 1.254 - The module depends on the following modules (in the other words 1.255 -@@ -158,17 +178,27 @@ 1.256 - Example 1.3. Setting i_enum_suffix module parameter 1.257 - modparam("enum", "i_enum_suffix", "e1234.arpa.") 1.258 - 1.259 --1.3.4. branchlabel (string) 1.260 -+1.3.4. isn_suffix (string) 1.261 -+ 1.262 -+ The domain suffix to be used for isn_query() lookups. Can be 1.263 -+ overridden by a parameter to isn_query. 1.264 -+ 1.265 -+ Default value is "freenum.org." 1.266 -+ 1.267 -+ Example 1.4. Setting isn_suffix module parameter 1.268 -+modparam("enum", "isn_suffix", "freenum.org.") 1.269 -+ 1.270 -+1.3.5. branchlabel (string) 1.271 - 1.272 - This parameter determines which label i_enum_query() will use 1.273 - to branch off to the infrastructure ENUM tree. 1.274 - 1.275 - Default value is ""i"" 1.276 - 1.277 -- Example 1.4. Setting brachlabel module parameter 1.278 -+ Example 1.5. Setting branchlabel module parameter 1.279 - modparam("enum", "branchlabel", "i") 1.280 - 1.281 --1.3.5. bl_algorithm (string) 1.282 -+1.3.6. bl_algorithm (string) 1.283 - 1.284 - This parameter determines which algorithm i_enum_query() will 1.285 - use to select the position in the DNS tree where the 1.286 -@@ -182,7 +212,7 @@ 1.287 - [branchlabel].[reverse-country-code].[i_enum_suffix] to 1.288 - indicate after how many digits the label should in inserted. 1.289 - 1.290 -- Example 1.5. Zone file example 1.291 -+ Example 1.6. Zone file example 1.292 - i.1.e164.arpa. IN TXT "4" 1.293 - 9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5 1.294 - 678 999" 1.295 -@@ -196,7 +226,7 @@ 1.296 - allocated yet. This version of the code uses 65300. See 1.297 - resolve.h. 1.298 - 1.299 -- Example 1.6. Zone file example 1.300 -+ Example 1.7. Zone file example 1.301 - i.1.e164.arpa. TYPE65300 \# 14 ( 1.302 - 04 ; position 1.303 - 01 69 ; separator 1.304 -@@ -208,7 +238,7 @@ 1.305 - 1.306 - Default value is "cc" 1.307 - 1.308 -- Example 1.7. Setting the bl_algorithm module parameter 1.309 -+ Example 1.8. Setting the bl_algorithm module parameter 1.310 - modparam("enum", "bl_algorithm", "txt") 1.311 - 1.312 - 1.4. Exported Functions 1.313 -@@ -225,7 +255,7 @@ 1.314 - 1.315 - This function can be used from REQUEST_ROUTE. 1.316 - 1.317 -- Example 1.8. enum_query usage 1.318 -+ Example 1.9. enum_query usage 1.319 - ... 1.320 - # search for "e2u+sip" in freenum.org 1.321 - enum_query("freenum.org."); 1.322 -@@ -262,7 +292,7 @@ 1.323 - 1.324 - This function can be used from REQUEST_ROUTE. 1.325 - 1.326 -- Example 1.9. enum_pv_query usage 1.327 -+ Example 1.10. enum_pv_query usage 1.328 - ... 1.329 - # search for "e2u+sip" in freenum.org 1.330 - enum_pv_query("$avp(i:100)", "freenum.org."); 1.331 -@@ -296,14 +326,42 @@ 1.332 - ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberle 1.333 - r-carrier-enum-01.txt for the rationale behind this function. 1.334 - 1.335 --1.4.4. is_from_user_enum() 1.336 -+1.4.4. isn_query(["suffix"[,"service"]]) 1.337 -+ 1.338 -+ The function performs a ISN query and rewrites the 1.339 -+ Request-URI with the result of the query. See Section 1.1, 1.340 -+ "Overview" for more information. 1.341 -+ 1.342 -+ Meaning of the parameters is as follows: 1.343 -+ * suffix - Suffix to be appended to the domain name. 1.344 -+ * service - Service string to be used in the service field. 1.345 -+ 1.346 -+ This function can be used from REQUEST_ROUTE. 1.347 -+ 1.348 -+ See ftp://www.ietf.org/rfc/rfc3872.txt and 1.349 -+ ftp://www.ietf.org/rfc/rfc2871.txt for information 1.350 -+ regarding the ITAD part of the ISN string. 1.351 -+ 1.352 -+ Example 1.11. isn_query usage 1.353 -+... 1.354 -+# search for "e2u+sip" in freenum.org 1.355 -+isn_query("freenum.org."); 1.356 -+... 1.357 -+# search for "e2u+sip" in default tree (configured as parameter) 1.358 -+enum_query(); 1.359 -+... 1.360 -+# search for "e2u+voice:sip" in freenum.org 1.361 -+enum_query("freenum.org.","voice"); 1.362 -+... 1.363 -+ 1.364 -+1.4.5. is_from_user_enum() 1.365 - 1.366 - Checks if the user part of from URI is found in an enum lookup. 1.367 - Returns 1 if yes and -1 if not. 1.368 - 1.369 - This function can be used from REQUEST_ROUTE. 1.370 - 1.371 -- Example 1.10. is_from_user_enum usage 1.372 -+ Example 1.12. is_from_user_enum usage 1.373 - ... 1.374 - if (is_from_user_enum()) { 1.375 - .... 1.376 -Index: modules/enum/doc/enum.xml 1.377 -diff -Nau modules/enum/doc/enum.xml.orig modules/enum/doc/enum.xml 1.378 ---- modules/enum/doc/enum.xml.orig 2009-10-16 02:31:52.000000000 +0200 1.379 -+++ modules/enum/doc/enum.xml 2010-01-18 18:01:15.954172402 +0100 1.380 -@@ -33,8 +33,8 @@ 1.381 - </copyright> 1.382 - <revhistory> 1.383 - <revision> 1.384 -- <revnumber>$Revision: 5901 $</revnumber> 1.385 -- <date>$Date: 2009-07-21 10:45:05 +0300 (Tue, 21 Jul 2009) $</date> 1.386 -+ <revnumber>$Revision: 5907 $</revnumber> 1.387 -+ <date>$Date: 2010-01-18 10:45:05 +0100 (Mon, 18 Jan 2010) $</date> 1.388 - </revision> 1.389 - </revhistory> 1.390 - </bookinfo> 1.391 -Index: modules/enum/doc/enum_admin.xml 1.392 -diff -Nau modules/enum/doc/enum_admin.xml.orig modules/enum/doc/enum_admin.xml 1.393 ---- modules/enum/doc/enum_admin.xml.orig 2010-01-18 12:33:30.053644000 +0100 1.394 -+++ modules/enum/doc/enum_admin.xml 2010-01-18 18:14:59.583157910 +0100 1.395 -@@ -75,6 +75,24 @@ 1.396 - and -1 if not. 1.397 - </para> 1.398 - <para> 1.399 -+ In addition to standard ENUM, support for ISN (ITAD Subscriber 1.400 -+ Numbers) is provided as well. To allow ISN lookups to resolve, 1.401 -+ a different formatting algorithm is expected by the DNS server. 1.402 -+ Whereas a ENUM NAPTR record expects a DNS query of the form 1.403 -+ 9.8.7.6.5.4.3.2.1.<suffix>, ISN method expects a DNS query of 1.404 -+ the form 6.5.1212.<suffix>. That is, a valid ISN number includes 1.405 -+ a prefix of '56' in the example. The rest of the number is a 1.406 -+ ITAD (Internet Telephony Administrative Domain) as defined 1.407 -+ in RFCs 3872 and 2871, and as allocated by the IANA in 1.408 -+ http://www.iana.org/assignments/trip-parameters. The ITAD is 1.409 -+ left intact and not refersed as ENUM requires. To learn more 1.410 -+ about ISN please refer to documents at www.freenum.org. 1.411 -+ </para> 1.412 -+ <para> 1.413 -+ To complete a ISN lookup on the user part of the Request-URI, 1.414 -+ isn_query() is used instead of enum_query(). 1.415 -+ </para> 1.416 -+ <para> 1.417 - Enum module also implements is_from_user_enum function. 1.418 - This function does an enum lookup on the from user and 1.419 - returns true if found, false otherwise. 1.420 -@@ -153,6 +171,22 @@ 1.421 - </example> 1.422 - </section> 1.423 - <section> 1.424 -+ <title><varname>isn_suffix</varname> (string)</title> 1.425 -+ <para> 1.426 -+ The domain suffix to be used for isn_query() lookups. Can 1.427 -+ be overridden by a parameter to isn_query. 1.428 -+ </para> 1.429 -+ <para> 1.430 -+ Default value is <quote>freenum.org.</quote> 1.431 -+ </para> 1.432 -+ <example> 1.433 -+ <title>Setting isn_suffix module parameter</title> 1.434 -+ <programlisting format="linespecific"> 1.435 -+modparam("enum", "isn_suffix", "freenum.org.") 1.436 -+</programlisting> 1.437 -+ </example> 1.438 -+ </section> 1.439 -+ <section> 1.440 - <title><varname>branchlabel</varname> (string)</title> 1.441 - <para> 1.442 - This parameter determines which label i_enum_query() will use 1.443 -@@ -162,7 +196,7 @@ 1.444 - Default value is <quote>"i"</quote> 1.445 - </para> 1.446 - <example> 1.447 -- <title>Setting brachlabel module parameter</title> 1.448 -+ <title>Setting branchlabel module parameter</title> 1.449 - <programlisting format="linespecific"> 1.450 - modparam("enum", "branchlabel", "i") 1.451 - </programlisting> 1.452 -@@ -353,6 +387,53 @@ 1.453 - </section> 1.454 - 1.455 - <section> 1.456 -+ <title> 1.457 -+ <function moreinfo="none">isn_query(["suffix"[,"service"]])</function> 1.458 -+ </title> 1.459 -+ <para> 1.460 -+ The function performs a ISN query and rewrites the Request-URI with 1.461 -+ the result of the query. See <xref linkend="sec-overview"/> for more 1.462 -+ information. 1.463 -+ </para> 1.464 -+ <para>Meaning of the parameters is as follows:</para> 1.465 -+ <itemizedlist> 1.466 -+ <listitem> 1.467 -+ <para><emphasis>suffix</emphasis> - Suffix to be appended to the 1.468 -+ domain name. 1.469 -+ </para> 1.470 -+ </listitem> 1.471 -+ <listitem> 1.472 -+ <para><emphasis>service</emphasis> - Service string to be used in 1.473 -+ the service field. 1.474 -+ </para> 1.475 -+ </listitem> 1.476 -+ </itemizedlist> 1.477 -+ <para> 1.478 -+ This function can be used from REQUEST_ROUTE. 1.479 -+ </para> 1.480 -+ <para> 1.481 -+ See ftp://www.ietf.org/rfc/rfc3872.txt and 1.482 -+ ftp://www.ietf.org/rfc/rfc2871.txt for information 1.483 -+ regarding the ITAD part of the ISN string. 1.484 -+ </para> 1.485 -+ <example> 1.486 -+ <title><function moreinfo="none">isn_query</function> usage</title> 1.487 -+ <programlisting format="linespecific"> 1.488 -+... 1.489 -+# search for "e2u+sip" in freenum.org 1.490 -+isn_query("freenum.org."); 1.491 -+... 1.492 -+# search for "e2u+sip" in default tree (configured as parameter) 1.493 -+isn_query(); 1.494 -+... 1.495 -+# search for "e2u+voice:sip" in freenum.org 1.496 -+isn_query("freenum.org.","voice"); 1.497 -+... 1.498 -+</programlisting> 1.499 -+ </example> 1.500 -+ </section> 1.501 -+ 1.502 -+ <section> 1.503 - <title><function moreinfo="none">is_from_user_enum()</function></title> 1.504 - <para> 1.505 - Checks if the user part of from <abbrev>URI</abbrev>
2.1 --- a/opensips/enum-isn.txt Wed Feb 10 21:25:01 2010 +0100 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,61 +0,0 @@ 2.4 -ISN (ITAD Subscriber Number) lookup integration contribution code 2.5 - 2.6 -Contribution 2.7 - 2.8 -This contribution introduces ISN formatting logic into the OpenSIPS 2.9 -ENUM module, allowing it to perform NAPTR based ISN lookups on the 2.10 -user part of the Request-URI in addition to the existing ENUM lookups. 2.11 - 2.12 -Rationale 2.13 - 2.14 -This extends the utility of the existing E.164 formatting logic which 2.15 -previously caused valid ISN lookups to fail (although the OpenSIPS 2.16 -documentation did suggest that lookups to freenum.org would succeed.) 2.17 - 2.18 -Compliance 2.19 - 2.20 -The author believes that the introduced logic complies with the 2.21 -relevant ITAD standards as defined by RFC 3872 and RFC 2871, however 2.22 -it seems that at this time ISN is rather loosely defined according to 2.23 -nonstandard documentation provided by freenum.org. 2.24 - 2.25 -Location 2.26 - 2.27 -http://scm.europalab.com/contrib/opensips/ 2.28 -http://scm.europalab.com/contrib/file/tip/opensips/ 2.29 - 2.30 -Instructions 2.31 - 2.32 -To integrate this contributed logic into the source code tree of 2.33 -a OpenSIPS distribution, download the unified diff and use the 2.34 -patch(1) command: 2.35 - 2.36 - $ cd /tmp && mkdir enum-patch && cd enum-patch 2.37 - $ wget http://scm.europalab.com/contrib/raw-file/tip/opensips/enum-isn.diff 2.38 - $ tar zxf /tmp/opensips-<version>-tls.tar.gz 2.39 - $ cd opensips-<version>-tls 2.40 - $ patch -p0 <../enum-isn.diff 2.41 - 2.42 -Testing 2.43 - 2.44 -A basic test of this contribution 2.45 -Once compiled and installed, a basic test of this contributed software 2.46 -involves calling the new exported function in the routing script of the 2.47 -OpenSIPS configuration file: 2.48 - 2.49 - # dial '1234*256' from a UAC first 2.50 - isn_query(); 2.51 - t_relay(); 2.52 - 2.53 -According to the freenum.org cookbook, the ISN '1234*256' is being 2.54 -provided for testing. After dialing the caller hears monkeys screaming. 2.55 - 2.56 -Disclaimer 2.57 - 2.58 -This software contribution is based on source code from OpenSIPS SVN 2.59 -revision 6511. The author makes no guarantees as to this contribution. 2.60 -A user who downloads and executes it does so at his own risk. 2.61 - 2.62 -Michael Schloh von Bennewitz 2.63 -http://michael.schloh.com/ 2.64 -Monday, 18. January 2010
3.1 --- a/opensips/modules/enum/README Wed Feb 10 21:25:01 2010 +0100 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,369 +0,0 @@ 3.4 -Enum Module 3.5 - 3.6 -Juha Heinanen 3.7 - 3.8 - <jh@song.fi> 3.9 - 3.10 -Otmar Lendl 3.11 - 3.12 - <lendl@nic.at> 3.13 - 3.14 - Copyright © 2002, 2003 Juha Heinanen 3.15 - Revision History 3.16 - Revision $Revision: 5907 $ $Date: 2010-01-18 10:45:05 +0100 3.17 - (Mon, 18 Jan 2010) $ 3.18 - __________________________________________________________ 3.19 - 3.20 - Table of Contents 3.21 - 3.22 - 1. Admin Guide 3.23 - 3.24 - 1.1. Overview 3.25 - 1.2. Dependencies 3.26 - 1.3. Exported Parameters 3.27 - 3.28 - 1.3.1. domain_suffix (string) 3.29 - 1.3.2. tel_uri_params (string) 3.30 - 1.3.3. i_enum_suffix (string) 3.31 - 1.3.4. isn_suffix (string) 3.32 - 1.3.5. branchlabel (string) 3.33 - 1.3.6. bl_algorithm (string) 3.34 - 3.35 - 1.4. Exported Functions 3.36 - 3.37 - 1.4.1. enum_query(["suffix"[,"service"]]) 3.38 - 1.4.2. enum_pv_query("pvar"[,"suffix"[,"service"]]) 3.39 - 1.4.3. i_enum_query(["suffix"[,"service"]]) 3.40 - 1.4.4. isn_query(["suffix"[,"service"]]) 3.41 - 1.4.5. is_from_user_enum() 3.42 - 3.43 - List of Examples 3.44 - 3.45 - 1.1. Setting domain_suffix module parameter 3.46 - 1.2. Setting tel_uri_params module parameter 3.47 - 1.3. Setting i_enum_suffix module parameter 3.48 - 1.4. Setting isn_query usage module parameter 3.49 - 1.5. Setting branchlabel module parameter 3.50 - 1.6. Zone file example 3.51 - 1.7. Zone file example 3.52 - 1.8. Setting the bl_algorithm module parameter 3.53 - 1.9. enum_query usage 3.54 - 1.10. enum_pv_query usage 3.55 - 1.11. isn_query usage 3.56 - 1.12. is_from_user_enum usage 3.57 - 3.58 -Chapter 1. Admin Guide 3.59 - 3.60 -1.1. Overview 3.61 - 3.62 - Enum module implements [i_]enum_query functions that make an 3.63 - enum query based on the user part of the current Request-URI. 3.64 - These functions assume that the user part consists of an 3.65 - international phone number of the form +decimal-digits, where 3.66 - the number of digits is at least 2 and at most 15. Out of this 3.67 - number enum_query forms a domain name, where the digits are in 3.68 - reverse order and separated by dots followed by domain suffix 3.69 - that by default is "e164.arpa.". For example, if the user part 3.70 - is +35831234567, the domain name will be 3.71 - "7.6.5.4.3.2.1.3.8.5.3.e164.arpa.". i_enum_query operates in a 3.72 - similar fashion. The only difference is that it adds a label 3.73 - (default "i") to branch off from the default, user-ENUM tree to 3.74 - an infrastructure ENUM tree. 3.75 - 3.76 - After forming the domain name, enum_query queries DNS for its 3.77 - NAPTR records. From the possible response enum_query chooses 3.78 - those records, whose flags field has string value "u", and 3.79 - whose services field has string value "e2u+[service:]sip" or 3.80 - "e2u+type[:subtype][+type[:subtype]...]" (case is ignored in 3.81 - both cases), and whose regexp field is of the form 3.82 - !pattern!replacement!. 3.83 - 3.84 - Then enum_query sorts the chosen NAPTR records based on their 3.85 - <order, preference>. After sorting, enum_query replaces the 3.86 - current Request URI by applying regexp of the most preferred 3.87 - NAPTR record its user part and appends to the request new 3.88 - branches by applying regexp of each remaining NAPTR record to 3.89 - the user part of the current Request URI. If a new URI is a tel 3.90 - URI, enum_query appends to it as tel URI parameters the value 3.91 - of tel_uri_params module parameter. Finally, enum_query 3.92 - associates a q value with each new URI based on the <order, 3.93 - preference> of the corresponding NAPTR record. 3.94 - 3.95 - When using enum_query without any parameters, it searches for 3.96 - NAPTRs with service type "e2u+sip" in the default enum tree. 3.97 - When using enum_query with a single parameter, this parameter 3.98 - will be used as enum tree. When using enum_query with two 3.99 - parameters, the functionality depends on the first letter in 3.100 - the second parameter. When the first letter is not a '+' sign, 3.101 - the second parameter will be used to search for NAPTRs with 3.102 - service type "e2u+parameter:sip". When the second parameter 3.103 - starts with a '+' sign, the ENUM lookup also supports compound 3.104 - NAPTRs (e.g. "e2u+voice:sip+video:sip") and searching for 3.105 - multiple service types within one lookup. Multiple service 3.106 - types must be separeted by a '+' sign. 3.107 - 3.108 - Most of the time you want to route based on the RURI. On rare 3.109 - occasions you may wish to route based on something else. The 3.110 - function enum_pv_query mimics the behavior of the enum_query 3.111 - function except the E.164 number in its pseudo variable 3.112 - argument is used for the enum lookup instead of the user part 3.113 - of the RURI. Obviously the user part of the RURI is still used 3.114 - in the NAPTR regexp. 3.115 - 3.116 - Enum query returns 1 if the current Request URI was replaced 3.117 - and -1 if not. 3.118 - 3.119 - Enum module also implements is_from_user_enum function. This 3.120 - function does an enum lookup on the from user and returns true 3.121 - if found, false otherwise. 3.122 - 3.123 - In addition to standard ENUM, support for ISN (ITAD Subscriber 3.124 - Numbers) is provided as well. To allow ISN lookups to resolve, 3.125 - a different formatting algorithm is expected by the DNS server. 3.126 - Whereas a ENUM NAPTR record expects a DNS query of the form 3.127 - 9.8.7.6.5.4.3.2.1.<suffix>, ISN method expects a DNS query of 3.128 - the form 6.5.1212.<suffix>. That is, a valid ISN number includes 3.129 - a prefix of '56' in the example. The rest of the number is a 3.130 - ITAD (Internet Telephony Administrative Domain) as defined 3.131 - in RFCs 3872 and 2871, and as allocated by the IANA in 3.132 - http://www.iana.org/assignments/trip-parameters. The ITAD is 3.133 - left intact and not refersed as ENUM requires. To learn more 3.134 - about ISN please refer to documents at www.freenum.org. 3.135 - 3.136 - To complete a ISN lookup on the user part of the Request-URI, 3.137 - isn_query() is used instead of enum_query(). 3.138 - 3.139 -1.2. Dependencies 3.140 - 3.141 - The module depends on the following modules (in the other words 3.142 - the listed modules must be loaded before this module): 3.143 - * No dependencies. 3.144 - 3.145 -1.3. Exported Parameters 3.146 - 3.147 -1.3.1. domain_suffix (string) 3.148 - 3.149 - The domain suffix to be added to the domain name obtained from 3.150 - the digits of an E164 number. Can be overridden by a parameter 3.151 - to enum_query. 3.152 - 3.153 - Default value is "e164.arpa." 3.154 - 3.155 - Example 1.1. Setting domain_suffix module parameter 3.156 -modparam("enum", "domain_suffix", "e1234.arpa.") 3.157 - 3.158 -1.3.2. tel_uri_params (string) 3.159 - 3.160 - A string whose contents is appended to each new tel URI in the 3.161 - request as tel URI parameters. 3.162 - 3.163 -Note 3.164 - 3.165 - Currently OpenSIPS does not support tel URIs. This means that 3.166 - at present tel_uri_params is appended as URI parameters to 3.167 - every URI. 3.168 - 3.169 - Default value is "" 3.170 - 3.171 - Example 1.2. Setting tel_uri_params module parameter 3.172 -modparam("enum", "tel_uri_params", ";npdi") 3.173 - 3.174 -1.3.3. i_enum_suffix (string) 3.175 - 3.176 - The domain suffix to be used for i_enum_query() lookups. Can be 3.177 - overridden by a parameter to i_enum_query. 3.178 - 3.179 - Default value is "e164.arpa." 3.180 - 3.181 - Example 1.3. Setting i_enum_suffix module parameter 3.182 -modparam("enum", "i_enum_suffix", "e1234.arpa.") 3.183 - 3.184 -1.3.4. isn_suffix (string) 3.185 - 3.186 - The domain suffix to be used for isn_query() lookups. Can be 3.187 - overridden by a parameter to isn_query. 3.188 - 3.189 - Default value is "freenum.org." 3.190 - 3.191 - Example 1.4. Setting isn_suffix module parameter 3.192 -modparam("enum", "isn_suffix", "freenum.org.") 3.193 - 3.194 -1.3.5. branchlabel (string) 3.195 - 3.196 - This parameter determines which label i_enum_query() will use 3.197 - to branch off to the infrastructure ENUM tree. 3.198 - 3.199 - Default value is ""i"" 3.200 - 3.201 - Example 1.5. Setting branchlabel module parameter 3.202 -modparam("enum", "branchlabel", "i") 3.203 - 3.204 -1.3.6. bl_algorithm (string) 3.205 - 3.206 - This parameter determines which algorithm i_enum_query() will 3.207 - use to select the position in the DNS tree where the 3.208 - infrastructure tree branches off the user ENUM tree. 3.209 - 3.210 - If set to "cc", i_enum_query() will always inserts the label at 3.211 - the country-code level. Examples: i.1.e164.arpa, 3.212 - i.3.4.e164.arpa, i.2.5.3.e164.arpa 3.213 - 3.214 - If set to "txt", i_enum_query() will look for a TXT record at 3.215 - [branchlabel].[reverse-country-code].[i_enum_suffix] to 3.216 - indicate after how many digits the label should in inserted. 3.217 - 3.218 - Example 1.6. Zone file example 3.219 -i.1.e164.arpa. IN TXT "4" 3.220 -9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5 3.221 -678 999" 3.222 - 3.223 - If set to "ebl", i_enum_query() will look for an EBL (ENUM 3.224 - Branch Label) record at 3.225 - [branchlabel].[reverse-country-code].[i_enum_suffix]. See 3.226 - http://www.ietf.org/internet-drafts/draft-lendl-enum-branch-loc 3.227 - ation-record-00.txt for a description of that record and the 3.228 - meaning of the fields. The RR type for the EBL has not been 3.229 - allocated yet. This version of the code uses 65300. See 3.230 - resolve.h. 3.231 - 3.232 - Example 1.7. Zone file example 3.233 -i.1.e164.arpa. TYPE65300 \# 14 ( 3.234 - 04 ; position 3.235 - 01 69 ; separator 3.236 - 04 65 31 36 34 04 61 72 70 61 00 ; e164.ar 3.237 -pa 3.238 -; ) 3.239 -9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5 3.240 -678 999" 3.241 - 3.242 - Default value is "cc" 3.243 - 3.244 - Example 1.8. Setting the bl_algorithm module parameter 3.245 -modparam("enum", "bl_algorithm", "txt") 3.246 - 3.247 -1.4. Exported Functions 3.248 - 3.249 -1.4.1. enum_query(["suffix"[,"service"]]) 3.250 - 3.251 - The function performs an enum query and rewrites the 3.252 - Request-URI with the result of the query. See Section 1.1, 3.253 - "Overview" for more information. 3.254 - 3.255 - Meaning of the parameters is as follows: 3.256 - * suffix - Suffix to be appended to the domain name. 3.257 - * service - Service string to be used in the service field. 3.258 - 3.259 - This function can be used from REQUEST_ROUTE. 3.260 - 3.261 - Example 1.9. enum_query usage 3.262 -... 3.263 -# search for "e2u+sip" in freenum.org 3.264 -enum_query("freenum.org."); 3.265 -... 3.266 -# search for "e2u+sip" in default tree (configured as parameter) 3.267 -enum_query(); 3.268 -... 3.269 -# search for "e2u+voice:sip" in e164.arpa 3.270 -enum_query("e164.arpa.","voice"); 3.271 -... 3.272 -# search for service type "sip" or "voice:sip" or "video:sip" 3.273 -# note the '+' sign in front of the second parameter 3.274 -enum_query("e164.arpa.","+sip+voice:sip+video:sip"); 3.275 -... 3.276 -# quering for service sip and voice:sip 3.277 -enum_query("e164.arpa."); 3.278 -enum_query("e164.arpa.","voice"); 3.279 -# or use instead 3.280 -enum_query("e164.arpa.","+sip+voice:sip"); 3.281 -... 3.282 - 3.283 -1.4.2. enum_pv_query("pvar"[,"suffix"[,"service"]]) 3.284 - 3.285 - The function performs an enum query on E.164 number stored in 3.286 - its pseudo variable argument and rewrites the Request-URI with 3.287 - the result of the query. See Section 1.1, "Overview" for more 3.288 - information. 3.289 - 3.290 - Meaning of the parameters is as follows: 3.291 - * pvar - Pseudo variable that holds an E.164 number on which 3.292 - enum query is performed. 3.293 - * suffix - Suffix to be appended to the domain name. 3.294 - * service - Service string to be used in the service field. 3.295 - 3.296 - This function can be used from REQUEST_ROUTE. 3.297 - 3.298 - Example 1.10. enum_pv_query usage 3.299 -... 3.300 -# search for "e2u+sip" in freenum.org 3.301 -enum_pv_query("$avp(i:100)", "freenum.org."); 3.302 -... 3.303 -# search for "e2u+sip" in default tree (configured as parameter) 3.304 -enum_pv_query("$fU"); 3.305 -... 3.306 -# search for "e2u+voice:sip" in e164.arpa 3.307 -enum_pv_query("$avp(i:100)","e164.arpa.","voice"); 3.308 -... 3.309 -# search for service type "sip" or "voice:sip" or "video:sip" 3.310 -# note the '+' sign in front of the second parameter 3.311 -enum_pv_query("$fU","e164.arpa.","+sip+voice:sip+video:sip"); 3.312 -... 3.313 -# quering for service sip and voice:sip 3.314 -enum_pv_query("$avp(i:100)","e164.arpa."); 3.315 -enum_pv_query("$avp(i:100)","e164.arpa.","voice"); 3.316 -# or use instead 3.317 -enum_pv_query("$avp(i:100)","e164.arpa.","+sip+voice:sip"); 3.318 -... 3.319 - 3.320 -1.4.3. i_enum_query(["suffix"[,"service"]]) 3.321 - 3.322 - The function performs an enum query and rewrites the 3.323 - Request-URI with the result of the query. This the 3.324 - Infrastructure-ENUM version of enum_query(). The only 3.325 - difference to enum_query() is in the calculation of the FQDN 3.326 - where NAPTR records are looked for. 3.327 - 3.328 - See 3.329 - ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberle 3.330 - r-carrier-enum-01.txt for the rationale behind this function. 3.331 - 3.332 -1.4.4. isn_query(["suffix"[,"service"]]) 3.333 - 3.334 - The function performs a ISN query and rewrites the 3.335 - Request-URI with the result of the query. See Section 1.1, 3.336 - "Overview" for more information. 3.337 - 3.338 - Meaning of the parameters is as follows: 3.339 - * suffix - Suffix to be appended to the domain name. 3.340 - * service - Service string to be used in the service field. 3.341 - 3.342 - This function can be used from REQUEST_ROUTE. 3.343 - 3.344 - See ftp://ftp.ietf.org/rfc/rfc3872.txt and 3.345 - ftp://ftp.ietf.org/rfc/rfc2871.txt for information 3.346 - regarding the ITAD part of the ISN string. 3.347 - 3.348 - Example 1.11. isn_query usage 3.349 -... 3.350 -# search for "e2u+sip" in freenum.org 3.351 -isn_query("freenum.org."); 3.352 -... 3.353 -# search for "e2u+sip" in default tree (configured as parameter) 3.354 -enum_query(); 3.355 -... 3.356 -# search for "e2u+voice:sip" in freenum.org 3.357 -enum_query("freenum.org.","voice"); 3.358 -... 3.359 - 3.360 -1.4.5. is_from_user_enum() 3.361 - 3.362 - Checks if the user part of from URI is found in an enum lookup. 3.363 - Returns 1 if yes and -1 if not. 3.364 - 3.365 - This function can be used from REQUEST_ROUTE. 3.366 - 3.367 - Example 1.12. is_from_user_enum usage 3.368 -... 3.369 -if (is_from_user_enum()) { 3.370 - .... 3.371 -}; 3.372 -...
4.1 --- a/opensips/modules/enum/doc/enum.xml Wed Feb 10 21:25:01 2010 +0100 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,46 +0,0 @@ 4.4 -<?xml version="1.0" encoding='ISO-8859-1'?> 4.5 -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" 4.6 -"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ 4.7 - 4.8 -<!ENTITY admin SYSTEM "enum_admin.xml"> 4.9 -<!ENTITY faq SYSTEM "../../../doc/module_faq.xml"> 4.10 - 4.11 -<!-- Include general documentation entities --> 4.12 -<!ENTITY % docentities SYSTEM "../../../doc/entities.xml"> 4.13 -%docentities; 4.14 - 4.15 -]> 4.16 - 4.17 -<book> 4.18 - <bookinfo> 4.19 - <title>Enum Module</title> 4.20 - <authorgroup> 4.21 - <author> 4.22 - <firstname>Juha</firstname> 4.23 - <surname>Heinanen</surname> 4.24 - <email>jh@song.fi</email> 4.25 - </author> 4.26 - <author> 4.27 - <firstname>Otmar</firstname> 4.28 - <surname>Lendl</surname> 4.29 - <email>lendl@nic.at</email> 4.30 - </author> 4.31 - </authorgroup> 4.32 - <copyright> 4.33 - <year>2002</year> 4.34 - <year>2003</year> 4.35 - <holder>Juha Heinanen</holder> 4.36 - </copyright> 4.37 - <revhistory> 4.38 - <revision> 4.39 - <revnumber>$Revision: 5907 $</revnumber> 4.40 - <date>$Date: 2010-01-18 10:45:05 +0100 (Mon, 18 Jan 2010) $</date> 4.41 - </revision> 4.42 - </revhistory> 4.43 - </bookinfo> 4.44 - <toc></toc> 4.45 - 4.46 - &admin; 4.47 - &faq; 4.48 - 4.49 -</book>
5.1 --- a/opensips/modules/enum/doc/enum_admin.xml Wed Feb 10 21:25:01 2010 +0100 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,459 +0,0 @@ 5.4 -<!-- Enum Module User's Guide --> 5.5 - 5.6 -<chapter> 5.7 - 5.8 - <title>&adminguide;</title> 5.9 - 5.10 - <section id="sec-overview"> 5.11 - <title>Overview</title> 5.12 - <para> 5.13 - Enum module implements [i_]enum_query functions that make an enum query 5.14 - based on the user part of the current Request-URI. These functions 5.15 - assume that the user part consists of an international phone number 5.16 - of the form +decimal-digits, where the number of digits is at 5.17 - least 2 and at most 15. Out of this number 5.18 - <function moreinfo="none">enum_query</function> forms a domain name, 5.19 - where the digits are in reverse order and separated by dots followed by 5.20 - domain suffix that by default is <quote>e164.arpa.</quote>. For example, 5.21 - if the user part is +35831234567, the domain 5.22 - name will be <quote>7.6.5.4.3.2.1.3.8.5.3.e164.arpa.</quote>. 5.23 - <function moreinfo="none">i_enum_query</function> operates in a similar 5.24 - fashion. The only difference is that it adds a label (default "i") 5.25 - to branch off from the default, user-ENUM tree to an infrastructure ENUM tree. 5.26 - </para> 5.27 - <para> 5.28 - After forming the domain name, 5.29 - <function moreinfo="none">enum_query</function> queries 5.30 - DNS for its NAPTR records. From the possible response 5.31 - <function moreinfo="none">enum_query</function> chooses those records, 5.32 - whose flags field has string value "u", and whose services field has 5.33 - string value "e2u+[service:]sip" or 5.34 - "e2u+type[:subtype][+type[:subtype]...]" (case is ignored in both 5.35 - cases), and whose regexp field is of the form !pattern!replacement!. 5.36 - </para> 5.37 - <para> 5.38 - Then <function moreinfo="none">enum_query</function> sorts the chosen 5.39 - NAPTR records based on their <order, preference>. After sorting, 5.40 - <function moreinfo="none">enum_query</function> replaces the current 5.41 - Request URI by applying regexp of the most preferred NAPTR record its 5.42 - user part and appends to the request new branches by applying regexp of 5.43 - each remaining NAPTR record to the user part of the 5.44 - current Request URI. If a new URI is a tel URI, 5.45 - <function moreinfo="none">enum_query</function> appends to it as tel 5.46 - URI parameters the value of tel_uri_params module parameter. Finally, 5.47 - <function moreinfo="none">enum_query</function> associates a q value 5.48 - with each new URI based on the <order, preference> of the 5.49 - corresponding NAPTR record. 5.50 - </para> 5.51 - <para> 5.52 - When using <function moreinfo="none">enum_query</function> without any 5.53 - parameters, it searches for NAPTRs with service type "e2u+sip" in the 5.54 - default enum tree. When using 5.55 - <function moreinfo="none">enum_query</function> with a single parameter, 5.56 - this parameter will be used as enum tree. When using 5.57 - <function moreinfo="none">enum_query</function> 5.58 - with two parameters, the functionality depends on the first letter in 5.59 - the second parameter. When the first letter is not a '+' sign, the 5.60 - second parameter will be used to search for NAPTRs with service type 5.61 - "e2u+parameter:sip". When the second parameter starts with a '+' sign, 5.62 - the ENUM lookup also supports compound NAPTRs 5.63 - (e.g. "e2u+voice:sip+video:sip") and searching for multiple service 5.64 - types within one lookup. Multiple service types must be separeted 5.65 - by a '+' sign. 5.66 - </para> 5.67 - <para> 5.68 - Most of the time you want to route based on the RURI. On rare occasions 5.69 - you may wish to route based on something else. The function 5.70 - <function moreinfo="none">enum_pv_query</function> mimics the behavior 5.71 - of the <function moreinfo="none">enum_query</function> function except the 5.72 - E.164 number in its pseudo variable argument is used for the enum lookup instead of the user 5.73 - part of the RURI. Obviously the user part of the RURI is still used in the 5.74 - NAPTR regexp. 5.75 - </para> 5.76 - <para> 5.77 - Enum query returns 1 if the current Request URI was replaced 5.78 - and -1 if not. 5.79 - </para> 5.80 - <para> 5.81 - In addition to standard ENUM, support for ISN (ITAD Subscriber 5.82 - Numbers) is provided as well. To allow ISN lookups to resolve, 5.83 - a different formatting algorithm is expected by the DNS server. 5.84 - Whereas a ENUM NAPTR record expects a DNS query of the form 5.85 - 9.8.7.6.5.4.3.2.1.<suffix>, ISN method expects a DNS query of 5.86 - the form 6.5.1212.<suffix>. That is, a valid ISN number includes 5.87 - a prefix of '56' in the example. The rest of the number is a 5.88 - ITAD (Internet Telephony Administrative Domain) as defined 5.89 - in RFCs 3872 and 2871, and as allocated by the IANA in 5.90 - http://www.iana.org/assignments/trip-parameters. The ITAD is 5.91 - left intact and not refersed as ENUM requires. To learn more 5.92 - about ISN please refer to documents at www.freenum.org. 5.93 - </para> 5.94 - <para> 5.95 - To complete a ISN lookup on the user part of the Request-URI, 5.96 - isn_query() is used instead of enum_query(). 5.97 - </para> 5.98 - <para> 5.99 - Enum module also implements is_from_user_enum function. 5.100 - This function does an enum lookup on the from user and 5.101 - returns true if found, false otherwise. 5.102 - </para> 5.103 - </section> 5.104 - 5.105 - <section> 5.106 - <title>Dependencies</title> 5.107 - <para> 5.108 - The module depends on the following modules (in the other words the 5.109 - listed modules must be loaded before this module): 5.110 - <itemizedlist> 5.111 - <listitem> 5.112 - <para>No dependencies.</para> 5.113 - </listitem> 5.114 - </itemizedlist> 5.115 - </para> 5.116 - </section> 5.117 - 5.118 - <section> 5.119 - <title>Exported Parameters</title> 5.120 - <section> 5.121 - <title><varname>domain_suffix</varname> (string)</title> 5.122 - <para> 5.123 - The domain suffix to be added to the domain name obtained from 5.124 - the digits of an <acronym>E164</acronym> number. Can be overridden 5.125 - by a parameter to enum_query. 5.126 - </para> 5.127 - <para> 5.128 - Default value is <quote>e164.arpa.</quote> 5.129 - </para> 5.130 - <example> 5.131 - <title>Setting domain_suffix module parameter</title> 5.132 - <programlisting format="linespecific"> 5.133 -modparam("enum", "domain_suffix", "e1234.arpa.") 5.134 -</programlisting> 5.135 - </example> 5.136 - </section> 5.137 - 5.138 - <section> 5.139 - <title><varname>tel_uri_params</varname> (string)</title> 5.140 - <para> 5.141 - A string whose contents is appended to each new tel URI in the 5.142 - request as tel URI parameters. 5.143 - </para> 5.144 - <note> 5.145 - <para> 5.146 - Currently &osips; does not support tel URIs. This means that at present 5.147 - tel_uri_params is appended as URI parameters to every URI. 5.148 - </para> 5.149 - </note> 5.150 - <para> 5.151 - Default value is <quote></quote> 5.152 - </para> 5.153 - <example> 5.154 - <title>Setting tel_uri_params module parameter</title> 5.155 - <programlisting format="linespecific"> 5.156 -modparam("enum", "tel_uri_params", ";npdi") 5.157 -</programlisting> 5.158 - </example> 5.159 - </section> 5.160 - <section> 5.161 - <title><varname>i_enum_suffix</varname> (string)</title> 5.162 - <para> 5.163 - The domain suffix to be used for i_enum_query() lookups. 5.164 - Can be overridden by a parameter to i_enum_query. 5.165 - </para> 5.166 - <para> 5.167 - Default value is <quote>e164.arpa.</quote> 5.168 - </para> 5.169 - <example> 5.170 - <title>Setting i_enum_suffix module parameter</title> 5.171 - <programlisting format="linespecific"> 5.172 -modparam("enum", "i_enum_suffix", "e1234.arpa.") 5.173 -</programlisting> 5.174 - </example> 5.175 - </section> 5.176 - <section> 5.177 - <title><varname>isn_suffix</varname> (string)</title> 5.178 - <para> 5.179 - The domain suffix to be used for isn_query() lookups. Can 5.180 - be overridden by a parameter to isn_query. 5.181 - </para> 5.182 - <para> 5.183 - Default value is <quote>freenum.org.</quote> 5.184 - </para> 5.185 - <example> 5.186 - <title>Setting isn_suffix module parameter</title> 5.187 - <programlisting format="linespecific"> 5.188 -modparam("enum", "isn_suffix", "freenum.org.") 5.189 -</programlisting> 5.190 - </example> 5.191 - </section> 5.192 - <section> 5.193 - <title><varname>branchlabel</varname> (string)</title> 5.194 - <para> 5.195 - This parameter determines which label i_enum_query() will use 5.196 - to branch off to the infrastructure ENUM tree. 5.197 - </para> 5.198 - <para> 5.199 - Default value is <quote>"i"</quote> 5.200 - </para> 5.201 - <example> 5.202 - <title>Setting branchlabel module parameter</title> 5.203 - <programlisting format="linespecific"> 5.204 -modparam("enum", "branchlabel", "i") 5.205 -</programlisting> 5.206 - </example> 5.207 - </section> 5.208 - <section> 5.209 - <title><varname>bl_algorithm</varname> (string)</title> 5.210 - <para> 5.211 - This parameter determines which algorithm i_enum_query() will use 5.212 - to select the position in the DNS tree where the infrastructure tree 5.213 - branches off the user ENUM tree. 5.214 - </para> 5.215 - <para> 5.216 - If set to "cc", i_enum_query() will always inserts the 5.217 - label at the country-code level. 5.218 - Examples: i.1.e164.arpa, i.3.4.e164.arpa, i.2.5.3.e164.arpa 5.219 - </para> 5.220 - <para> 5.221 - If set to "txt", i_enum_query() will look for a TXT record at 5.222 - [branchlabel].[reverse-country-code].[i_enum_suffix] to indicate after how many digits the 5.223 - label should in inserted. 5.224 - <example> 5.225 - <title>Zone file example</title> 5.226 - <programlisting format="linespecific"> 5.227 -i.1.e164.arpa. IN TXT "4" 5.228 -9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678 999" 5.229 -</programlisting> 5.230 - </example> 5.231 - </para> 5.232 - <para> 5.233 - If set to "ebl", i_enum_query() will look for an EBL (ENUM Branch Label) record at 5.234 - [branchlabel].[reverse-country-code].[i_enum_suffix]. See http://www.ietf.org/internet-drafts/draft-lendl-enum-branch-location-record-00.txt for a description of that record and the 5.235 - meaning of the fields. The RR type for the EBL has not been allocated yet. 5.236 - This version of the code uses 65300. See resolve.h. 5.237 - <example> 5.238 - <title>Zone file example</title> 5.239 - <programlisting format="linespecific"> 5.240 -i.1.e164.arpa. TYPE65300 \# 14 ( 5.241 - 04 ; position 5.242 - 01 69 ; separator 5.243 - 04 65 31 36 34 04 61 72 70 61 00 ; e164.arpa 5.244 -; ) 5.245 -9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678 999" 5.246 -</programlisting> 5.247 - </example> 5.248 - </para> 5.249 - 5.250 - <para> 5.251 - Default value is <quote>cc</quote> 5.252 - </para> 5.253 - <example> 5.254 - <title>Setting the bl_algorithm module parameter</title> 5.255 - <programlisting format="linespecific"> 5.256 -modparam("enum", "bl_algorithm", "txt") 5.257 -</programlisting> 5.258 - </example> 5.259 - </section> 5.260 - 5.261 - </section> 5.262 - 5.263 - <section> 5.264 - <title>Exported Functions</title> 5.265 - <section> 5.266 - <title> 5.267 - <function moreinfo="none">enum_query(["suffix"[,"service"]])</function> 5.268 - </title> 5.269 - <para> 5.270 - The function performs an enum query and rewrites the Request-URI with 5.271 - the result of the query. See <xref linkend="sec-overview"/> for more 5.272 - information. 5.273 - </para> 5.274 - <para>Meaning of the parameters is as follows:</para> 5.275 - <itemizedlist> 5.276 - <listitem> 5.277 - <para><emphasis>suffix</emphasis> - Suffix to be appended to the 5.278 - domain name. 5.279 - </para> 5.280 - </listitem> 5.281 - <listitem> 5.282 - <para><emphasis>service</emphasis> - Service string to be used in 5.283 - the service field. 5.284 - </para> 5.285 - </listitem> 5.286 - </itemizedlist> 5.287 - <para> 5.288 - This function can be used from REQUEST_ROUTE. 5.289 - </para> 5.290 - <example> 5.291 - <title><function moreinfo="none">enum_query</function> usage</title> 5.292 - <programlisting format="linespecific"> 5.293 -... 5.294 -# search for "e2u+sip" in freenum.org 5.295 -enum_query("freenum.org."); 5.296 -... 5.297 -# search for "e2u+sip" in default tree (configured as parameter) 5.298 -enum_query(); 5.299 -... 5.300 -# search for "e2u+voice:sip" in e164.arpa 5.301 -enum_query("e164.arpa.","voice"); 5.302 -... 5.303 -# search for service type "sip" or "voice:sip" or "video:sip" 5.304 -# note the '+' sign in front of the second parameter 5.305 -enum_query("e164.arpa.","+sip+voice:sip+video:sip"); 5.306 -... 5.307 -# quering for service sip and voice:sip 5.308 -enum_query("e164.arpa."); 5.309 -enum_query("e164.arpa.","voice"); 5.310 -# or use instead 5.311 -enum_query("e164.arpa.","+sip+voice:sip"); 5.312 -... 5.313 -</programlisting> 5.314 - </example> 5.315 - </section> 5.316 - 5.317 - <section> 5.318 - <title> 5.319 - <function moreinfo="none">enum_pv_query("pvar"[,"suffix"[,"service"]])</function> 5.320 - </title> 5.321 - <para> 5.322 - The function performs an enum query on E.164 number stored 5.323 - in its pseudo variable argument and rewrites the Request-URI with 5.324 - the result of the query. See <xref linkend="sec-overview"/> for more 5.325 - information. 5.326 - </para> 5.327 - <para>Meaning of the parameters is as follows:</para> 5.328 - <itemizedlist> 5.329 - <listitem> 5.330 - <para><emphasis>pvar</emphasis> - Pseudo 5.331 - variable that holds an E.164 number on which enum 5.332 - query is performed. 5.333 - </para> 5.334 - </listitem> 5.335 - <listitem> 5.336 - <para><emphasis>suffix</emphasis> - Suffix to be appended to the 5.337 - domain name. 5.338 - </para> 5.339 - </listitem> 5.340 - <listitem> 5.341 - <para><emphasis>service</emphasis> - Service string to be used in 5.342 - the service field. 5.343 - </para> 5.344 - </listitem> 5.345 - </itemizedlist> 5.346 - <para> 5.347 - This function can be used from REQUEST_ROUTE. 5.348 - </para> 5.349 - <example> 5.350 - <title><function moreinfo="none">enum_pv_query</function> usage</title> 5.351 - <programlisting format="linespecific"> 5.352 -... 5.353 -# search for "e2u+sip" in freenum.org 5.354 -enum_pv_query("$avp(i:100)", "freenum.org."); 5.355 -... 5.356 -# search for "e2u+sip" in default tree (configured as parameter) 5.357 -enum_pv_query("$fU"); 5.358 -... 5.359 -# search for "e2u+voice:sip" in e164.arpa 5.360 -enum_pv_query("$avp(i:100)","e164.arpa.","voice"); 5.361 -... 5.362 -# search for service type "sip" or "voice:sip" or "video:sip" 5.363 -# note the '+' sign in front of the second parameter 5.364 -enum_pv_query("$fU","e164.arpa.","+sip+voice:sip+video:sip"); 5.365 -... 5.366 -# quering for service sip and voice:sip 5.367 -enum_pv_query("$avp(i:100)","e164.arpa."); 5.368 -enum_pv_query("$avp(i:100)","e164.arpa.","voice"); 5.369 -# or use instead 5.370 -enum_pv_query("$avp(i:100)","e164.arpa.","+sip+voice:sip"); 5.371 -... 5.372 -</programlisting> 5.373 - </example> 5.374 - </section> 5.375 - 5.376 - <section> 5.377 - <title> 5.378 - <function moreinfo="none">i_enum_query(["suffix"[,"service"]])</function> 5.379 - </title> 5.380 - <para> 5.381 - The function performs an enum query and rewrites the Request-URI with 5.382 - the result of the query. This the Infrastructure-ENUM version of enum_query(). 5.383 - The only difference to enum_query() is in the calculation of the 5.384 - FQDN where NAPTR records are looked for. 5.385 - </para> 5.386 - <para> 5.387 - See ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberler-carrier-enum-01.txt 5.388 - for the rationale behind this function. 5.389 - </para> 5.390 - </section> 5.391 - 5.392 - <section> 5.393 - <title> 5.394 - <function moreinfo="none">isn_query(["suffix"[,"service"]])</function> 5.395 - </title> 5.396 - <para> 5.397 - The function performs a ISN query and rewrites the Request-URI with 5.398 - the result of the query. See <xref linkend="sec-overview"/> for more 5.399 - information. 5.400 - </para> 5.401 - <para>Meaning of the parameters is as follows:</para> 5.402 - <itemizedlist> 5.403 - <listitem> 5.404 - <para><emphasis>suffix</emphasis> - Suffix to be appended to the 5.405 - domain name. 5.406 - </para> 5.407 - </listitem> 5.408 - <listitem> 5.409 - <para><emphasis>service</emphasis> - Service string to be used in 5.410 - the service field. 5.411 - </para> 5.412 - </listitem> 5.413 - </itemizedlist> 5.414 - <para> 5.415 - This function can be used from REQUEST_ROUTE. 5.416 - </para> 5.417 - <para> 5.418 - See ftp://ftp.ietf.org/rfc/rfc3872.txt and 5.419 - ftp://ftp.ietf.org/rfc/rfc2871.txt for information 5.420 - regarding the ITAD part of the ISN string. 5.421 - </para> 5.422 - <example> 5.423 - <title><function moreinfo="none">isn_query</function> usage</title> 5.424 - <programlisting format="linespecific"> 5.425 -... 5.426 -# search for "e2u+sip" in freenum.org 5.427 -isn_query("freenum.org."); 5.428 -... 5.429 -# search for "e2u+sip" in default tree (configured as parameter) 5.430 -isn_query(); 5.431 -... 5.432 -# search for "e2u+voice:sip" in freenum.org 5.433 -isn_query("freenum.org.","voice"); 5.434 -... 5.435 -</programlisting> 5.436 - </example> 5.437 - </section> 5.438 - 5.439 - <section> 5.440 - <title><function moreinfo="none">is_from_user_enum()</function></title> 5.441 - <para> 5.442 - Checks if the user part of from <abbrev>URI</abbrev> 5.443 - is found in an enum lookup. 5.444 - Returns 1 if yes and -1 if not. 5.445 - </para> 5.446 - <para> 5.447 - This function can be used from REQUEST_ROUTE. 5.448 - </para> 5.449 - <example> 5.450 - <title><function moreinfo="none">is_from_user_enum</function> usage</title> 5.451 - <programlisting format="linespecific"> 5.452 -... 5.453 -if (is_from_user_enum()) { 5.454 - .... 5.455 -}; 5.456 -... 5.457 -</programlisting> 5.458 - </example> 5.459 - </section> 5.460 - </section> 5.461 -</chapter> 5.462 -
6.1 --- a/opensips/modules/enum/enum.c Wed Feb 10 21:25:01 2010 +0100 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,1196 +0,0 @@ 6.4 -/* 6.5 - * $Id: enum.c 5901 2009-07-21 07:45:05Z bogdan_iancu $ 6.6 - * 6.7 - * Enum and E164 related functions 6.8 - * 6.9 - * Copyright (C) 2002-2008 Juha Heinanen 6.10 - * 6.11 - * This file is part of opensips, a free SIP server. 6.12 - * 6.13 - * opensips is free software; you can redistribute it and/or modify 6.14 - * it under the terms of the GNU General Public License as published by 6.15 - * the Free Software Foundation; either version 2 of the License, or 6.16 - * (at your option) any later version 6.17 - * 6.18 - * opensips is distributed in the hope that it will be useful, 6.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 6.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 6.21 - * GNU General Public License for more details. 6.22 - * 6.23 - * You should have received a copy of the GNU General Public License 6.24 - * along with this program; if not, write to the Free Software 6.25 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6.26 - * 6.27 - */ 6.28 - 6.29 -#include <stdlib.h> 6.30 - 6.31 -#include "enum.h" 6.32 -#include "../../parser/parse_uri.h" 6.33 -#include "../../parser/parse_from.h" 6.34 -#include "../../ut.h" 6.35 -#include "../../resolve.h" 6.36 -#include "../../mem/mem.h" 6.37 -#include "../../dset.h" 6.38 -#include "../../qvalue.h" 6.39 -#include "enum_mod.h" 6.40 -#include "../../regexp.h" 6.41 -#include "../../pvar.h" 6.42 - 6.43 -/* 6.44 - * Input: E.164 number w/o leading + 6.45 - * 6.46 - * Output: number of digits in the country code 6.47 - * 0 on invalid number 6.48 - * 6.49 - * convention: 6.50 - * 3 digits is the default length of a country code. 6.51 - * country codes 1 and 7 are a single digit. 6.52 - * the following country codes are two digits: 20, 27, 30-34, 36, 39, 6.53 - * 40, 41, 43-49, 51-58, 60-66, 81, 82, 84, 86, 90-95, 98. 6.54 - */ 6.55 -static int cclen(const char *number) 6.56 -{ 6.57 - char d1,d2; 6.58 - 6.59 - if (!number || (strlen(number) < 3)) 6.60 - return(0); 6.61 - 6.62 - d1 = number[0]; 6.63 - d2 = number[1]; 6.64 - 6.65 - if (!isdigit((int)d2)) 6.66 - return(0); 6.67 - 6.68 - switch(d1) { 6.69 - case '1': 6.70 - case '7': 6.71 - return(1); 6.72 - case '2': 6.73 - if ((d2 == '0') || (d1 == '7')) 6.74 - return(2); 6.75 - break; 6.76 - case '3': 6.77 - if ((d2 >= '0') && (d1 <= '4')) 6.78 - return(2); 6.79 - if ((d2 == '6') || (d1 == '9')) 6.80 - return(2); 6.81 - break; 6.82 - case '4': 6.83 - if (d2 != '2') 6.84 - return(2); 6.85 - break; 6.86 - case '5': 6.87 - if ((d2 >= '1') && (d1 <= '8')) 6.88 - return(2); 6.89 - break; 6.90 - case '6': 6.91 - if (d1 <= '6') 6.92 - return(2); 6.93 - break; 6.94 - case '8': 6.95 - if ((d2 == '1') || (d1 == '2') || (d1 == '4') || (d1 == '6')) 6.96 - return(2); 6.97 - break; 6.98 - case '9': 6.99 - if (d1 <= '5') 6.100 - return(2); 6.101 - if (d2 == '8') 6.102 - return(2); 6.103 - break; 6.104 - default: 6.105 - return(0); 6.106 - } 6.107 - 6.108 - return(3); 6.109 -} 6.110 - 6.111 - 6.112 - 6.113 -/* return the length of the string until c, if not found returns n */ 6.114 -static inline int findchr(char* p, int c, unsigned int size) 6.115 -{ 6.116 - int len=0; 6.117 - 6.118 - for(;len<size;p++){ 6.119 - if (*p==(unsigned char)c) { 6.120 - return len; 6.121 - } 6.122 - len++; 6.123 - } 6.124 - return len; 6.125 -} 6.126 - 6.127 - 6.128 -/* Parse NAPTR regexp field of the form !pattern!replacement! and return its 6.129 - * components in pattern and replacement parameters. Regexp field starts at 6.130 - * address first and is len characters long. 6.131 - */ 6.132 -static inline int parse_naptr_regexp(char* first, int len, str* pattern, 6.133 - str* replacement) 6.134 -{ 6.135 - char *second, *third; 6.136 - 6.137 - if (len > 0) { 6.138 - if (*first == '!') { 6.139 - second = (char *)memchr((void *)(first + 1), '!', len - 1); 6.140 - if (second) { 6.141 - len = len - (second - first + 1); 6.142 - if (len > 0) { 6.143 - third = memchr(second + 1, '!', len); 6.144 - if (third) { 6.145 - pattern->len = second - first - 1; 6.146 - pattern->s = first + 1; 6.147 - replacement->len = third - second - 1; 6.148 - replacement->s = second + 1; 6.149 - return 1; 6.150 - } else { 6.151 - LM_ERR("Third ! missing from regexp\n"); 6.152 - return -1; 6.153 - } 6.154 - } else { 6.155 - LM_ERR("Third ! missing from regexp\n"); 6.156 - return -2; 6.157 - } 6.158 - } else { 6.159 - LM_ERR("Second ! missing from regexp\n"); 6.160 - return -3; 6.161 - } 6.162 - } else { 6.163 - LM_ERR("First ! missing from regexp\n"); 6.164 - return -4; 6.165 - } 6.166 - } else { 6.167 - LM_ERR("Regexp missing\n"); 6.168 - return -5; 6.169 - } 6.170 -} 6.171 -/* Checks if NAPTR record has flag u and its services field 6.172 - * e2u+[service:]sip or 6.173 - * e2u+service[+service[+service[+...]]] 6.174 - */ 6.175 -static inline int sip_match( struct naptr_rdata* naptr, str* service) 6.176 -{ 6.177 - if (service->len == 0) { 6.178 - return (naptr->flags_len == 1) && 6.179 - ((naptr->flags[0] == 'u') || (naptr->flags[0] == 'U')) && 6.180 - (naptr->services_len == 7) && 6.181 - ((strncasecmp(naptr->services, "e2u+sip", 7) == 0) || 6.182 - (strncasecmp(naptr->services, "sip+e2u", 7) == 0)); 6.183 - } else if (service->s[0] != '+') { 6.184 - return (naptr->flags_len == 1) && 6.185 - ((naptr->flags[0] == 'u') || (naptr->flags[0] == 'U')) && 6.186 - (naptr->services_len == service->len + 8) && 6.187 - (strncasecmp(naptr->services, "e2u+", 4) == 0) && 6.188 - (strncasecmp(naptr->services + 4, service->s, service->len) == 0) && 6.189 - (strncasecmp(naptr->services + 4 + service->len, ":sip", 4) == 0); 6.190 - } else { /* handle compound NAPTRs and multiple services */ 6.191 - str bakservice, baknaptr; /* we bakup the str */ 6.192 - int naptrlen, len; /* length of the extracted service */ 6.193 - 6.194 - /* RFC 3761, NAPTR service field must start with E2U+ */ 6.195 - if (strncasecmp(naptr->services, "e2u+", 4) != 0) { 6.196 - return 0; 6.197 - } 6.198 - baknaptr.s = naptr->services + 4; /* leading 'e2u+' */ 6.199 - baknaptr.len = naptr->services_len - 4; 6.200 - for (;;) { /* iterate over services in NAPTR */ 6.201 - bakservice.s = service->s + 1; /* leading '+' */ 6.202 - bakservice.len = service->len - 1; 6.203 - naptrlen = findchr(baknaptr.s,'+',baknaptr.len); 6.204 - 6.205 - for (;;) { /* iterate over services in enum_query */ 6.206 - len = findchr(bakservice.s,'+',bakservice.len); 6.207 - if ((naptrlen == len ) && !strncasecmp(baknaptr.s, bakservice.s, len)){ 6.208 - return 1; 6.209 - } 6.210 - if ( (bakservice.len -= len+1) > 0) { 6.211 - bakservice.s += len+1; 6.212 - continue; 6.213 - } 6.214 - break; 6.215 - } 6.216 - if ( (baknaptr.len -= naptrlen+1) > 0) { 6.217 - baknaptr.s += naptrlen+1; 6.218 - continue; 6.219 - } 6.220 - break; 6.221 - } 6.222 - /* no matching service found */ 6.223 - return 0; 6.224 - } 6.225 -} 6.226 - 6.227 - 6.228 -/* 6.229 - * Checks if argument is an e164 number starting with + 6.230 - */ 6.231 -static inline int is_e164(str* _user) 6.232 -{ 6.233 - int i; 6.234 - char c; 6.235 - 6.236 - if ((_user->len > 2) && (_user->len < 17) && ((_user->s)[0] == '+')) { 6.237 - for (i = 1; i < _user->len; i++) { 6.238 - c = (_user->s)[i]; 6.239 - if ((c < '0') || (c > '9')) return -1; 6.240 - } 6.241 - return 1; 6.242 - } else { 6.243 - return -1; 6.244 - } 6.245 -} 6.246 - 6.247 - 6.248 -/* 6.249 - * Call is_from_user_enum_2 with module parameter suffix and default service. 6.250 - */ 6.251 -int is_from_user_enum_0(struct sip_msg* _msg, char* _str1, char* _str2) 6.252 -{ 6.253 - return is_from_user_enum_2(_msg, (char *)(&suffix), (char *)(&service)); 6.254 -} 6.255 - 6.256 -/* 6.257 - * Call is_from_user_enum_2 with given suffix and default service. 6.258 - */ 6.259 -int is_from_user_enum_1(struct sip_msg* _msg, char* _suffix, char* _str2) 6.260 -{ 6.261 - return is_from_user_enum_2(_msg, _suffix, (char *)(&service)); 6.262 -} 6.263 - 6.264 -/* 6.265 - * Check if from user is a valid enum based user, and check to make sure 6.266 - * that the src_ip == an srv record that maps to the enum from user. 6.267 - */ 6.268 -int is_from_user_enum_2(struct sip_msg* _msg, char* _suffix, char* _service) 6.269 -{ 6.270 - struct ip_addr addr; 6.271 - struct hostent* he; 6.272 - unsigned short zp; 6.273 - unsigned short proto; 6.274 - char *user_s; 6.275 - int user_len, i, j; 6.276 - char name[MAX_DOMAIN_SIZE]; 6.277 - char uri[MAX_URI_SIZE]; 6.278 - struct sip_uri *furi; 6.279 - struct sip_uri luri; 6.280 - struct rdata* head; 6.281 - 6.282 - str* suffix; 6.283 - str* service; 6.284 - 6.285 - struct rdata* l; 6.286 - struct naptr_rdata* naptr; 6.287 - 6.288 - str pattern, replacement, result; 6.289 - char string[17]; 6.290 - 6.291 - if (parse_from_header(_msg) < 0) { 6.292 - LM_ERR("Failed to parse From header\n"); 6.293 - return -1; 6.294 - } 6.295 - 6.296 - if(_msg->from==NULL || get_from(_msg)==NULL) { 6.297 - LM_DBG("No From header\n"); 6.298 - return -1; 6.299 - } 6.300 - 6.301 - if ((furi = parse_from_uri(_msg)) == NULL) { 6.302 - LM_ERR("Failed to parse From URI\n"); 6.303 - return -1; 6.304 - } 6.305 - 6.306 - suffix = (str*)_suffix; 6.307 - service = (str*)_service; 6.308 - 6.309 - if (is_e164(&(furi->user)) == -1) { 6.310 - LM_ERR("From URI user is not an E164 number\n"); 6.311 - return -1; 6.312 - } 6.313 - 6.314 - /* assert: the from user is a valid formatted e164 string */ 6.315 - 6.316 - user_s = furi->user.s; 6.317 - user_len = furi->user.len; 6.318 - 6.319 - j = 0; 6.320 - for (i = user_len - 1; i > 0; i--) { 6.321 - name[j] = user_s[i]; 6.322 - name[j + 1] = '.'; 6.323 - j = j + 2; 6.324 - } 6.325 - 6.326 - memcpy(name + j, suffix->s, suffix->len + 1); 6.327 - 6.328 - head = get_record(name, T_NAPTR); 6.329 - 6.330 - if (head == 0) { 6.331 - LM_DBG("No NAPTR record found for %s.\n", name); 6.332 - return -3; 6.333 - } 6.334 - 6.335 - /* we have the naptr records, loop and find an srv record with */ 6.336 - /* same ip address as source ip address, if we do then true is returned */ 6.337 - 6.338 - for (l = head; l; l = l->next) { 6.339 - 6.340 - if (l->type != T_NAPTR) continue; /*should never happen*/ 6.341 - naptr = (struct naptr_rdata*)l->rdata; 6.342 - if (naptr == 0) { 6.343 - LM_ERR("Null rdata in DNS response\n"); 6.344 - free_rdata_list(head); 6.345 - return -4; 6.346 - } 6.347 - 6.348 - LM_DBG("ENUM query on %s: order %u, pref %u, flen %u, flags " 6.349 - "'%.*s', slen %u, services '%.*s', rlen %u, " 6.350 - "regexp '%.*s'\n", 6.351 - name, naptr->order, naptr->pref, 6.352 - naptr->flags_len, (int)(naptr->flags_len), ZSW(naptr->flags), naptr->services_len, 6.353 - (int)(naptr->services_len), ZSW(naptr->services), naptr->regexp_len, 6.354 - (int)(naptr->regexp_len), ZSW(naptr->regexp)); 6.355 - 6.356 - if (sip_match(naptr, service) != 0) { 6.357 - if (parse_naptr_regexp(&(naptr->regexp[0]), naptr->regexp_len, 6.358 - &pattern, &replacement) < 0) { 6.359 - free_rdata_list(head); /*clean up*/ 6.360 - LM_ERR("Parsing of NAPTR regexp failed\n"); 6.361 - return -5; 6.362 - } 6.363 -#ifdef LATER 6.364 - if ((pattern.len == 4) && (strncmp(pattern.s, "^.*$", 4) == 0)) { 6.365 - LM_DBG("Resulted in replacement: '%.*s'\n", 6.366 - replacement.len, ZSW(replacement.s)); 6.367 - retval = set_uri(_msg, replacement.s, replacement.len); 6.368 - free_rdata_list(head); /*clean up*/ 6.369 - return retval; 6.370 - } 6.371 -#endif 6.372 - result.s = &(uri[0]); 6.373 - result.len = MAX_URI_SIZE; 6.374 - /* Avoid making copies of pattern and replacement */ 6.375 - pattern.s[pattern.len] = (char)0; 6.376 - replacement.s[replacement.len] = (char)0; 6.377 - /* We have already checked the size of 6.378 - _msg->parsed_uri.user.s */ 6.379 - memcpy(&(string[0]), user_s, user_len); 6.380 - string[user_len] = (char)0; 6.381 - if (reg_replace(pattern.s, replacement.s, &(string[0]), 6.382 - &result) < 0) { 6.383 - pattern.s[pattern.len] = '!'; 6.384 - replacement.s[replacement.len] = '!'; 6.385 - LM_ERR("Regexp replace failed\n"); 6.386 - free_rdata_list(head); /*clean up*/ 6.387 - return -6; 6.388 - } 6.389 - LM_DBG("Resulted in replacement: '%.*s'\n", 6.390 - result.len, ZSW(result.s)); 6.391 - 6.392 - if(parse_uri(result.s, result.len, &luri) < 0) 6.393 - { 6.394 - LM_ERR("Parsing of URI <%.*s> failed\n", 6.395 - result.len, result.s); 6.396 - free_rdata_list(head); /*clean up*/ 6.397 - return -7; 6.398 - } 6.399 - 6.400 - pattern.s[pattern.len] = '!'; 6.401 - replacement.s[replacement.len] = '!'; 6.402 - 6.403 - zp = 0; 6.404 - proto = PROTO_NONE; 6.405 - he = sip_resolvehost(&luri.host, &zp, &proto, 6.406 - (luri.type==SIPS_URI_T)?1:0 , 0); 6.407 - 6.408 - hostent2ip_addr(&addr, he, 0); 6.409 - 6.410 - if(ip_addr_cmp(&addr, &_msg->rcv.src_ip)) 6.411 - { 6.412 - free_rdata_list(head); 6.413 - return(1); 6.414 - } 6.415 - } 6.416 - } 6.417 - free_rdata_list(head); /*clean up*/ 6.418 - LM_DBG("FAIL\n"); 6.419 - 6.420 - /* must not have found the record */ 6.421 - return(-8); 6.422 -} 6.423 - 6.424 - 6.425 - 6.426 -/* 6.427 - * Add parameter to URI. 6.428 - */ 6.429 -int add_uri_param(str *uri, str *param, str *new_uri) 6.430 -{ 6.431 - struct sip_uri puri; 6.432 - char *at; 6.433 - 6.434 - if (parse_uri(uri->s, uri->len, &puri) < 0) { 6.435 - return 0; 6.436 - } 6.437 - 6.438 - /* if current uri has no headers, pad param to the end of uri */ 6.439 - if (puri.headers.len == 0) { 6.440 - memcpy(uri->s + uri->len, param->s, param->len); 6.441 - uri->len = uri->len + param->len; 6.442 - new_uri->len = 0; 6.443 - return 1; 6.444 - } 6.445 - 6.446 - /* otherwise take the long path and create new_uri */ 6.447 - at = new_uri->s; 6.448 - switch (puri.type) { 6.449 - case SIP_URI_T: 6.450 - memcpy(at, "sip:", 4); 6.451 - at = at + 4; 6.452 - break; 6.453 - case SIPS_URI_T: 6.454 - memcpy(at, "sips:", 5); 6.455 - at = at + 5; 6.456 - break; 6.457 - case TEL_URI_T: 6.458 - memcpy(at, "tel:", 4); 6.459 - at = at + 4; 6.460 - break; 6.461 - case TELS_URI_T: 6.462 - memcpy(at, "tels:", 5); 6.463 - at = at + 5; 6.464 - break; 6.465 - default: 6.466 - LM_ERR("Unknown URI scheme <%d>\n", puri.type); 6.467 - return 0; 6.468 - } 6.469 - if (puri.user.len) { 6.470 - memcpy(at, puri.user.s, puri.user.len); 6.471 - at = at + puri.user.len; 6.472 - if (puri.passwd.len) { 6.473 - *at = ':'; 6.474 - at = at + 1; 6.475 - memcpy(at, puri.passwd.s, puri.passwd.len); 6.476 - at = at + puri.passwd.len; 6.477 - }; 6.478 - *at = '@'; 6.479 - at = at + 1; 6.480 - } 6.481 - memcpy(at, puri.host.s, puri.host.len); 6.482 - at = at + puri.host.len; 6.483 - if (puri.port.len) { 6.484 - *at = ':'; 6.485 - at = at + 1; 6.486 - memcpy(at, puri.port.s, puri.port.len); 6.487 - at = at + puri.port.len; 6.488 - } 6.489 - if (puri.params.len) { 6.490 - *at = ';'; 6.491 - at = at + 1; 6.492 - memcpy(at, puri.params.s, puri.params.len); 6.493 - at = at + puri.params.len; 6.494 - } 6.495 - memcpy(at, param->s, param->len); 6.496 - at = at + param->len; 6.497 - *at = '?'; 6.498 - at = at + 1; 6.499 - memcpy(at, puri.headers.s, puri.headers.len); 6.500 - at = at + puri.headers.len; 6.501 - new_uri->len = at - new_uri->s; 6.502 - return 1; 6.503 -} 6.504 - 6.505 -/* 6.506 - * Tests if one result record is "greater" that the other. Non-NAPTR records 6.507 - * greater that NAPTR record. An invalid NAPTR record is greater than a 6.508 - * valid one. Valid NAPTR records are compared based on their 6.509 - * (order,preference). 6.510 - */ 6.511 -static inline int naptr_greater(struct rdata* a, struct rdata* b) 6.512 -{ 6.513 - struct naptr_rdata *na, *nb; 6.514 - 6.515 - if (a->type != T_NAPTR) return 1; 6.516 - if (b->type != T_NAPTR) return 0; 6.517 - 6.518 - na = (struct naptr_rdata*)a->rdata; 6.519 - if (na == 0) return 1; 6.520 - 6.521 - nb = (struct naptr_rdata*)b->rdata; 6.522 - if (nb == 0) return 0; 6.523 - 6.524 - return (((na->order) << 16) + na->pref) > 6.525 - (((nb->order) << 16) + nb->pref); 6.526 -} 6.527 - 6.528 - 6.529 -/* 6.530 - * Bubble sorts result record list according to naptr (order,preference). 6.531 - */ 6.532 -static inline void naptr_sort(struct rdata** head) 6.533 -{ 6.534 - struct rdata *p, *q, *r, *s, *temp, *start; 6.535 - 6.536 - /* r precedes p and s points to the node up to which comparisons 6.537 - are to be made */ 6.538 - 6.539 - s = NULL; 6.540 - start = *head; 6.541 - while ( s != start -> next ) { 6.542 - r = p = start ; 6.543 - q = p -> next ; 6.544 - while ( p != s ) { 6.545 - if ( naptr_greater(p, q) ) { 6.546 - if ( p == start ) { 6.547 - temp = q -> next ; 6.548 - q -> next = p ; 6.549 - p -> next = temp ; 6.550 - start = q ; 6.551 - r = q ; 6.552 - } else { 6.553 - temp = q -> next ; 6.554 - q -> next = p ; 6.555 - p -> next = temp ; 6.556 - r -> next = q ; 6.557 - r = q ; 6.558 - } 6.559 - } else { 6.560 - r = p ; 6.561 - p = p -> next ; 6.562 - } 6.563 - q = p -> next ; 6.564 - if ( q == s ) s = p ; 6.565 - } 6.566 - } 6.567 - *head = start; 6.568 -} 6.569 - 6.570 - 6.571 -/* 6.572 - * Makes enum query on name. On success, rewrites user part and 6.573 - * replaces Request-URI. 6.574 - */ 6.575 -int do_query(struct sip_msg* _msg, char *user, char *name, str *service) { 6.576 - 6.577 - char uri[MAX_URI_SIZE]; 6.578 - char new_uri[MAX_URI_SIZE]; 6.579 - unsigned int priority, curr_prio, first; 6.580 - qvalue_t q; 6.581 - struct rdata* head; 6.582 - struct rdata* l; 6.583 - struct naptr_rdata* naptr; 6.584 - str pattern, replacement, result, new_result; 6.585 - 6.586 - head = get_record(name, T_NAPTR); 6.587 - 6.588 - if (head == 0) { 6.589 - LM_DBG("No NAPTR record found for %s.\n", name); 6.590 - return -1; 6.591 - } 6.592 - 6.593 - naptr_sort(&head); 6.594 - 6.595 - q = MAX_Q - 10; 6.596 - curr_prio = 0; 6.597 - first = 1; 6.598 - 6.599 - for (l = head; l; l = l->next) { 6.600 - 6.601 - if (l->type != T_NAPTR) continue; /*should never happen*/ 6.602 - naptr = (struct naptr_rdata*)l->rdata; 6.603 - if (naptr == 0) { 6.604 - LM_ERR("Null rdata in DNS response\n"); 6.605 - continue; 6.606 - } 6.607 - 6.608 - LM_DBG("ENUM query on %s: order %u, pref %u, flen %u, flags '%.*s', " 6.609 - "slen %u, services '%.*s', rlen %u, regexp '%.*s'\n", 6.610 - name, naptr->order, naptr->pref, 6.611 - naptr->flags_len, (int)(naptr->flags_len), ZSW(naptr->flags), 6.612 - naptr->services_len, 6.613 - (int)(naptr->services_len), ZSW(naptr->services), naptr->regexp_len, 6.614 - (int)(naptr->regexp_len), ZSW(naptr->regexp)); 6.615 - 6.616 - if (sip_match(naptr, service) == 0) continue; 6.617 - 6.618 - if (parse_naptr_regexp(&(naptr->regexp[0]), naptr->regexp_len, 6.619 - &pattern, &replacement) < 0) { 6.620 - LM_ERR("Parsing of NAPTR regexp failed\n"); 6.621 - continue; 6.622 - } 6.623 - result.s = &(uri[0]); 6.624 - result.len = MAX_URI_SIZE; 6.625 - /* Avoid making copies of pattern and replacement */ 6.626 - pattern.s[pattern.len] = (char)0; 6.627 - replacement.s[replacement.len] = (char)0; 6.628 - if (reg_replace(pattern.s, replacement.s, user, &result) < 0) { 6.629 - pattern.s[pattern.len] = '!'; 6.630 - replacement.s[replacement.len] = '!'; 6.631 - LM_ERR("Regexp replace failed\n"); 6.632 - continue; 6.633 - } 6.634 - LM_DBG("Resulted in replacement: '%.*s'\n", result.len, ZSW(result.s)); 6.635 - pattern.s[pattern.len] = '!'; 6.636 - replacement.s[replacement.len] = '!'; 6.637 - 6.638 - if (param.len > 0) { 6.639 - if (result.len + param.len > MAX_URI_SIZE - 1) { 6.640 - LM_ERR("URI is too long\n"); 6.641 - continue; 6.642 - } 6.643 - new_result.s = &(new_uri[0]); 6.644 - new_result.len = MAX_URI_SIZE; 6.645 - if (add_uri_param(&result, ¶m, &new_result) == 0) { 6.646 - LM_ERR("Parsing of URI <%.*s> failed\n", 6.647 - result.len, result.s); 6.648 - continue; 6.649 - } 6.650 - if (new_result.len > 0) { 6.651 - result = new_result; 6.652 - } 6.653 - } 6.654 - 6.655 - if (first) { 6.656 - if (set_ruri(_msg, &result) == -1) { 6.657 - goto done; 6.658 - } 6.659 - set_ruri_q(q); 6.660 - first = 0; 6.661 - curr_prio = ((naptr->order) << 16) + naptr->pref; 6.662 - } else { 6.663 - priority = ((naptr->order) << 16) + naptr->pref; 6.664 - if (priority > curr_prio) { 6.665 - q = q - 10; 6.666 - curr_prio = priority; 6.667 - } 6.668 - if (append_branch(_msg, &result, 0, 0, q, 0, 0) == -1) { 6.669 - goto done; 6.670 - } 6.671 - } 6.672 - } 6.673 - 6.674 -done: 6.675 - free_rdata_list(head); 6.676 - return first ? -1 : 1; 6.677 -} 6.678 - 6.679 - 6.680 -/* 6.681 - * Call enum_query_2 with module parameter suffix and default service. 6.682 - */ 6.683 -int enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2) 6.684 -{ 6.685 - return enum_query_2(_msg, (char *)(&suffix), (char *)(&service)); 6.686 -} 6.687 - 6.688 - 6.689 -/* 6.690 - * Call enum_query_2 with given suffix and default service. 6.691 - */ 6.692 -int enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2) 6.693 -{ 6.694 - return enum_query_2(_msg, _suffix, (char *)(&service)); 6.695 -} 6.696 - 6.697 - 6.698 -/* 6.699 - * See documentation in README file. 6.700 - */ 6.701 -int enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service) 6.702 -{ 6.703 - char *user_s; 6.704 - int user_len, i, j; 6.705 - char name[MAX_DOMAIN_SIZE]; 6.706 - char string[17]; 6.707 - 6.708 - str *suffix, *service; 6.709 - 6.710 - suffix = (str*)_suffix; 6.711 - service = (str*)_service; 6.712 - 6.713 - if (parse_sip_msg_uri(_msg) < 0) { 6.714 - LM_ERR("Parsing of R-URI failed\n"); 6.715 - return -1; 6.716 - } 6.717 - 6.718 - if (is_e164(&(_msg->parsed_uri.user)) == -1) { 6.719 - LM_ERR("R-URI user is not an E164 number\n"); 6.720 - return -1; 6.721 - } 6.722 - 6.723 - user_s = _msg->parsed_uri.user.s; 6.724 - user_len = _msg->parsed_uri.user.len; 6.725 - 6.726 - memcpy(&(string[0]), user_s, user_len); 6.727 - string[user_len] = (char)0; 6.728 - 6.729 - j = 0; 6.730 - for (i = user_len - 1; i > 0; i--) { 6.731 - name[j] = user_s[i]; 6.732 - name[j + 1] = '.'; 6.733 - j = j + 2; 6.734 - } 6.735 - 6.736 - memcpy(name + j, suffix->s, suffix->len + 1); 6.737 - 6.738 - return do_query(_msg, string, name, service); 6.739 -} 6.740 - 6.741 - 6.742 -/* 6.743 - * Call isn_query_2 with module parameter suffix and default service. 6.744 - */ 6.745 -int isn_query_0(struct sip_msg* _msg, char* _str1, char* _str2) 6.746 -{ 6.747 - return isn_query_2(_msg, (char *)(&isnsuffix), (char *)(&service)); 6.748 -} 6.749 - 6.750 - 6.751 -/* 6.752 - * Call isn_query_2 with given suffix and default service. 6.753 - */ 6.754 -int isn_query_1(struct sip_msg* _msg, char* _suffix, char* _str2) 6.755 -{ 6.756 - return isn_query_2(_msg, _suffix, (char *)(&service)); 6.757 -} 6.758 - 6.759 - 6.760 -/* 6.761 - * See documentation in README file. 6.762 - */ 6.763 -int isn_query_2(struct sip_msg* _msg, char* _suffix, char* _service) 6.764 -{ 6.765 - char *user_s = NULL; 6.766 - int user_len, i, j; 6.767 - char name[MAX_DOMAIN_SIZE] = {0}; 6.768 - char string[17] = {0}; 6.769 - char szItad[17] = {0}; 6.770 - size_t nItlen = 0; 6.771 - 6.772 - str *suffix, *service; 6.773 - 6.774 - suffix = (str*)_suffix; 6.775 - service = (str*)_service; 6.776 - 6.777 - if (parse_sip_msg_uri(_msg) < 0) { 6.778 - LM_ERR("Parsing of R-URI failed\n"); 6.779 - return -1; 6.780 - } 6.781 - 6.782 - user_s = _msg->parsed_uri.user.s; 6.783 - user_len = _msg->parsed_uri.user.len; 6.784 - 6.785 - memcpy(&(string[0]), user_s, user_len); 6.786 - string[user_len] = (char)0; 6.787 - 6.788 - /* Do primitive test for correct ISN format, */ 6.789 - /* and set szItad to the ISN ITAD (RFC 3872/2871). */ 6.790 - /* Correct ISN format guessed from freenum.org and IANA */ 6.791 - /* doc http://www.iana.org/assignments/trip-parameters/ */ 6.792 - { 6.793 - char *pAster = strchr(string, '*'); 6.794 - if (pAster && (nItlen = strspn(pAster + sizeof(char), "0123456789"))) 6.795 - strncpy(szItad, pAster + sizeof(char), nItlen); 6.796 - else { 6.797 - LM_ERR("R-URI user does not contain a valid ISN\n"); 6.798 - return -1; 6.799 - } 6.800 - } 6.801 - 6.802 - /* Ammend the original ENUM E.164 string logic to process */ 6.803 - /* ISN numbers instead, which include a nonreversed ITAD. */ 6.804 - i = user_len - nItlen - sizeof(char); /* Ex: *1212 */ 6.805 - j = 0; 6.806 - while (i--) { 6.807 - name[j] = user_s[i]; 6.808 - name[j + 1] = '.'; 6.809 - j = j + 2; 6.810 - } 6.811 - 6.812 - strcat(name + j, szItad); /* Copy the unreversed ITAD, */ 6.813 - name[j + nItlen] = '.'; /* and append a trailing dot. */ 6.814 - memcpy(name + j + nItlen + sizeof(char), suffix->s, suffix->len + 1); 6.815 - 6.816 - return do_query(_msg, string, name, service); 6.817 -} 6.818 - 6.819 - 6.820 -/*********** INFRASTRUCTURE ENUM ***************/ 6.821 - 6.822 -/* 6.823 - * Call enum_query_2 with default suffix and service. 6.824 - */ 6.825 -int i_enum_query_0(struct sip_msg* _msg, char* _suffix, char* _service) 6.826 -{ 6.827 - return i_enum_query_2(_msg, (char *)(&i_suffix), (char *)(&service)); 6.828 -} 6.829 - 6.830 -/* 6.831 - * Call enum_query_2 with given suffix and default service. 6.832 - */ 6.833 -int i_enum_query_1(struct sip_msg* _msg, char* _suffix, char* _service) 6.834 -{ 6.835 - return i_enum_query_2(_msg, _suffix, (char *)(&service)); 6.836 -} 6.837 - 6.838 - 6.839 -int i_enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service) 6.840 -{ 6.841 - char *user_s; 6.842 - int user_len, i, j; 6.843 - char name[MAX_DOMAIN_SIZE]; 6.844 - char apex[MAX_COMPONENT_SIZE + 1]; 6.845 - char separator[MAX_COMPONENT_SIZE + 1]; 6.846 - int sdl = 0; /* subdomain location: infrastructure enum offset */ 6.847 - int cc_len; 6.848 - struct rdata* head; 6.849 - 6.850 - char string[17]; 6.851 - 6.852 - str *suffix, *service; 6.853 - 6.854 - suffix = (str*)_suffix; 6.855 - service = (str*)_service; 6.856 - 6.857 - if (parse_sip_msg_uri(_msg) < 0) { 6.858 - LM_ERR("Parsing of R-URI failed\n"); 6.859 - return -1; 6.860 - } 6.861 - 6.862 - if (is_e164(&(_msg->parsed_uri.user)) == -1) { 6.863 - LM_ERR("R-URI user is not an E164 number\n"); 6.864 - return -1; 6.865 - } 6.866 - 6.867 - user_s = _msg->parsed_uri.user.s; 6.868 - user_len = _msg->parsed_uri.user.len; 6.869 - 6.870 - /* make sure we don't run out of space in strings */ 6.871 - if (( 2*user_len + MAX_COMPONENT_SIZE + MAX_COMPONENT_SIZE + 4) > MAX_DOMAIN_SIZE) { 6.872 - LM_ERR("Strings too long\n"); 6.873 - return -1; 6.874 - } 6.875 - if ( i_branchlabel.len > MAX_COMPONENT_SIZE ) { 6.876 - LM_ERR("i_branchlabel too long\n"); 6.877 - return -1; 6.878 - } 6.879 - if ( suffix->len > MAX_COMPONENT_SIZE ) { 6.880 - LM_ERR("Suffix too long\n"); 6.881 - return -1; 6.882 - } 6.883 - 6.884 - 6.885 - memcpy(&(string[0]), user_s, user_len); 6.886 - string[user_len] = (char)0; 6.887 - 6.888 - /* Set up parameters as for user-enum */ 6.889 - memcpy(apex, suffix->s , suffix->len); 6.890 - apex[suffix->len] = (char)0; 6.891 - sdl = 0; /* where to insert i-enum separator */ 6.892 - separator[0] = 0; /* don't insert anything */ 6.893 - 6.894 - cc_len = cclen(string + 1); 6.895 - 6.896 - if (!strncasecmp(i_bl_alg.s,"ebl",i_bl_alg.len)) { 6.897 - sdl = cc_len; /* default */ 6.898 - 6.899 - j = 0; 6.900 - memcpy(name, i_branchlabel.s, i_branchlabel.len); 6.901 - j += i_branchlabel.len; 6.902 - name[j++] = '.'; 6.903 - 6.904 - for (i = cc_len ; i > 0; i--) { 6.905 - name[j++] = user_s[i]; 6.906 - name[j++] = '.'; 6.907 - } 6.908 - memcpy(name + j, suffix->s, suffix->len + 1); 6.909 - 6.910 - LM_DBG("Looking for EBL record for %s.\n", name); 6.911 - head = get_record(name, T_EBL); 6.912 - if (head == 0) { 6.913 - LM_DBG("No EBL found for %s. Defaulting to user ENUM.\n",name); 6.914 - } else { 6.915 - struct ebl_rdata* ebl; 6.916 - ebl = (struct ebl_rdata *) head->rdata; 6.917 - 6.918 - LM_DBG("EBL record for %s is %d / %.*s / %.*s.\n", 6.919 - name, ebl->position, (int)ebl->separator_len, 6.920 - ebl->separator,(int)ebl->apex_len, ebl->apex); 6.921 - 6.922 - if ((ebl->apex_len > MAX_COMPONENT_SIZE) || (ebl->separator_len > MAX_COMPONENT_SIZE)) { 6.923 - LM_ERR("EBL strings too long\n"); 6.924 - return -1; 6.925 - } 6.926 - 6.927 - if (ebl->position > 15) { 6.928 - LM_ERR("EBL position too large (%d)\n", 6.929 - ebl->position); 6.930 - return -1; 6.931 - } 6.932 - 6.933 - sdl = ebl->position; 6.934 - 6.935 - memcpy(separator, ebl->separator, ebl->separator_len); 6.936 - separator[ebl->separator_len] = 0; 6.937 - 6.938 - memcpy(apex, ebl->apex, ebl->apex_len); 6.939 - apex[ebl->apex_len] = 0; 6.940 - free_rdata_list(head); 6.941 - } 6.942 - } else if (!strncasecmp(i_bl_alg.s,"txt",i_bl_alg.len)) { 6.943 - sdl = cc_len; /* default */ 6.944 - memcpy(separator, i_branchlabel.s, i_branchlabel.len); 6.945 - separator[i_branchlabel.len] = 0; 6.946 - /* no change to apex */ 6.947 - 6.948 - j = 0; 6.949 - memcpy(name, i_branchlabel.s, i_branchlabel.len); 6.950 - j += i_branchlabel.len; 6.951 - name[j++] = '.'; 6.952 - 6.953 - for (i = cc_len ; i > 0; i--) { 6.954 - name[j++] = user_s[i]; 6.955 - name[j++] = '.'; 6.956 - } 6.957 - memcpy(name + j, suffix->s, suffix->len + 1); 6.958 - 6.959 - head = get_record(name, T_TXT); 6.960 - if (head == 0) { 6.961 - LM_DBG("TXT found for %s. Defaulting to %d\n", 6.962 - name, cc_len); 6.963 - } else { 6.964 - sdl = atoi(((struct txt_rdata*)head->rdata)->txt); 6.965 - LM_DBG("TXT record for %s is %d.\n", name, sdl); 6.966 - 6.967 - if ((sdl < 0) || (sdl > 10)) { 6.968 - LM_ERR("Sdl %d out of bounds. Set back to cc_len.\n", sdl); 6.969 - sdl = cc_len; 6.970 - } 6.971 - free_rdata_list(head); 6.972 - } 6.973 - } else { /* defaults to CC */ 6.974 - sdl = cc_len; 6.975 - memcpy(separator, i_branchlabel.s, i_branchlabel.len); 6.976 - separator[i_branchlabel.len] = 0; 6.977 - /* no change to apex */ 6.978 - } 6.979 - 6.980 - j = 0; 6.981 - sdl++; /* to avoid comparing i to (sdl+1) */ 6.982 - for (i = user_len - 1; i > 0; i--) { 6.983 - name[j] = user_s[i]; 6.984 - name[j + 1] = '.'; 6.985 - j = j + 2; 6.986 - if (separator[0] && (i == sdl)) { /* insert the I-ENUM separator here? */ 6.987 - strcpy(name + j, separator); /* we've checked string sizes. */ 6.988 - j += strlen(separator); 6.989 - name[j++] = '.'; 6.990 - } 6.991 - } 6.992 - 6.993 - memcpy(name + j, apex, strlen(apex)+1); 6.994 - 6.995 - return do_query(_msg, string, name, service); 6.996 -} 6.997 - 6.998 - 6.999 - 6.1000 -/******************* FQUERY *******************/ 6.1001 - 6.1002 - 6.1003 -/* 6.1004 - * Call enum_pv_query_3 with pv arg, module parameter suffix, 6.1005 - * and default service. 6.1006 - */ 6.1007 -int enum_pv_query_1(struct sip_msg* _msg, char* _sp) 6.1008 -{ 6.1009 - return enum_pv_query_3(_msg, _sp, (char *)(&suffix), (char *)(&service)); 6.1010 -} 6.1011 - 6.1012 -/* 6.1013 - * Call enum_pv_query_3 with pv and suffix args and default service. 6.1014 - */ 6.1015 -int enum_pv_query_2(struct sip_msg* _msg, char* _sp, char* _suffix) 6.1016 -{ 6.1017 - return enum_pv_query_3(_msg, _sp, _suffix, (char *)(&service)); 6.1018 -} 6.1019 - 6.1020 -/* 6.1021 - * See documentation in README file. 6.1022 - */ 6.1023 - 6.1024 -int enum_pv_query_3(struct sip_msg* _msg, char* _sp, char* _suffix, 6.1025 - char* _service) 6.1026 -{ 6.1027 - char *user_s; 6.1028 - int user_len, i, j, first; 6.1029 - char name[MAX_DOMAIN_SIZE]; 6.1030 - char uri[MAX_URI_SIZE]; 6.1031 - char new_uri[MAX_URI_SIZE]; 6.1032 - unsigned int priority, curr_prio; 6.1033 - qvalue_t q; 6.1034 - char tostring[17]; 6.1035 - struct rdata* head; 6.1036 - struct rdata* l; 6.1037 - struct naptr_rdata* naptr; 6.1038 - str pattern, replacement, result, new_result; 6.1039 - str *suffix, *service; 6.1040 - char string[17]; 6.1041 - pv_spec_t *sp; 6.1042 - pv_value_t pv_val; 6.1043 - 6.1044 - sp = (pv_spec_t *)_sp; 6.1045 - suffix = (str*)_suffix; 6.1046 - service = (str*)_service; 6.1047 - 6.1048 - /* 6.1049 - * Get R-URI user to tostring 6.1050 - */ 6.1051 - if (parse_sip_msg_uri(_msg) < 0) { 6.1052 - LM_ERR("R-URI parsing failed\n"); 6.1053 - return -1; 6.1054 - } 6.1055 - 6.1056 - if (is_e164(&(_msg->parsed_uri.user)) == -1) { 6.1057 - LM_ERR("R-URI user is not an E164 number\n"); 6.1058 - return -1; 6.1059 - } 6.1060 - 6.1061 - user_s = _msg->parsed_uri.user.s; 6.1062 - user_len = _msg->parsed_uri.user.len; 6.1063 - 6.1064 - memcpy(&(tostring[0]), user_s, user_len); 6.1065 - tostring[user_len] = (char)0; 6.1066 - 6.1067 - /* 6.1068 - * Get E.164 number from pseudo variable 6.1069 - */ 6.1070 - if (sp && (pv_get_spec_value(_msg, sp, &pv_val) == 0)) { 6.1071 - if (pv_val.flags & PV_VAL_STR) { 6.1072 - if (pv_val.rs.len == 0 || pv_val.rs.s == NULL) { 6.1073 - LM_DBG("Missing E.164 number\n"); 6.1074 - return -1; 6.1075 - } 6.1076 - } else { 6.1077 - LM_DBG("Pseudo variable value is not string\n"); 6.1078 - return -1; 6.1079 - } 6.1080 - } else { 6.1081 - LM_DBG("Cannot get pseudo variable value\n"); 6.1082 - return -1; 6.1083 - } 6.1084 - if (is_e164(&(pv_val.rs)) == -1) { 6.1085 - LM_ERR("pseudo variable does not contain an E164 number\n"); 6.1086 - return -1; 6.1087 - } 6.1088 - 6.1089 - user_s = pv_val.rs.s; 6.1090 - user_len = pv_val.rs.len; 6.1091 - 6.1092 - memcpy(&(string[0]), user_s, user_len); 6.1093 - string[user_len] = (char)0; 6.1094 - 6.1095 - j = 0; 6.1096 - for (i = user_len - 1; i > 0; i--) { 6.1097 - name[j] = user_s[i]; 6.1098 - name[j + 1] = '.'; 6.1099 - j = j + 2; 6.1100 - } 6.1101 - 6.1102 - memcpy(name + j, suffix->s, suffix->len + 1); 6.1103 - 6.1104 - head = get_record(name, T_NAPTR); 6.1105 - 6.1106 - if (head == 0) { 6.1107 - LM_DBG("No NAPTR record found for %s.\n", name); 6.1108 - return -1; 6.1109 - } 6.1110 - 6.1111 - naptr_sort(&head); 6.1112 - 6.1113 - q = MAX_Q - 10; 6.1114 - curr_prio = 0; 6.1115 - first = 1; 6.1116 - 6.1117 - for (l = head; l; l = l->next) { 6.1118 - 6.1119 - if (l->type != T_NAPTR) continue; /*should never happen*/ 6.1120 - naptr = (struct naptr_rdata*)l->rdata; 6.1121 - if (naptr == 0) { 6.1122 - LM_ERR("Null rdata in DNS response\n"); 6.1123 - continue; 6.1124 - } 6.1125 - 6.1126 - LM_DBG("ENUM query on %s: order %u, pref %u, flen %u, flags " 6.1127 - "'%.*s', slen %u, services '%.*s', rlen %u, " 6.1128 - "regexp '%.*s'\n", 6.1129 - name, naptr->order, naptr->pref, 6.1130 - naptr->flags_len, (int)(naptr->flags_len), ZSW(naptr->flags), 6.1131 - naptr->services_len, 6.1132 - (int)(naptr->services_len), ZSW(naptr->services), naptr->regexp_len, 6.1133 - (int)(naptr->regexp_len), ZSW(naptr->regexp)); 6.1134 - 6.1135 - if (sip_match(naptr, service) == 0) continue; 6.1136 - 6.1137 - if (parse_naptr_regexp(&(naptr->regexp[0]), naptr->regexp_len, 6.1138 - &pattern, &replacement) < 0) { 6.1139 - LM_ERR("Parsing of NAPTR regexp failed\n"); 6.1140 - continue; 6.1141 - } 6.1142 - result.s = &(uri[0]); 6.1143 - result.len = MAX_URI_SIZE; 6.1144 - /* Avoid making copies of pattern and replacement */ 6.1145 - pattern.s[pattern.len] = (char)0; 6.1146 - replacement.s[replacement.len] = (char)0; 6.1147 - if (reg_replace(pattern.s, replacement.s, &(tostring[0]), 6.1148 - &result) < 0) { 6.1149 - pattern.s[pattern.len] = '!'; 6.1150 - replacement.s[replacement.len] = '!'; 6.1151 - LM_ERR("Regexp replace failed\n"); 6.1152 - continue; 6.1153 - } 6.1154 - LM_DBG("Resulted in replacement: '%.*s'\n", 6.1155 - result.len, ZSW(result.s)); 6.1156 - pattern.s[pattern.len] = '!'; 6.1157 - replacement.s[replacement.len] = '!'; 6.1158 - 6.1159 - if (param.len > 0) { 6.1160 - if (result.len + param.len > MAX_URI_SIZE - 1) { 6.1161 - LM_ERR("URI is too long\n"); 6.1162 - continue; 6.1163 - } 6.1164 - new_result.s = &(new_uri[0]); 6.1165 - new_result.len = MAX_URI_SIZE; 6.1166 - if (add_uri_param(&result, ¶m, &new_result) == 0) { 6.1167 - LM_ERR("Parsing of URI <%.*s> failed\n", 6.1168 - result.len, result.s); 6.1169 - continue; 6.1170 - } 6.1171 - if (new_result.len > 0) { 6.1172 - result = new_result; 6.1173 - } 6.1174 - } 6.1175 - 6.1176 - if (first) { 6.1177 - if (set_ruri(_msg, &result) == -1) { 6.1178 - goto done; 6.1179 - } 6.1180 - set_ruri_q(q); 6.1181 - first = 0; 6.1182 - curr_prio = ((naptr->order) << 16) + naptr->pref; 6.1183 - } else { 6.1184 - priority = ((naptr->order) << 16) + naptr->pref; 6.1185 - if (priority > curr_prio) { 6.1186 - q = q - 10; 6.1187 - curr_prio = priority; 6.1188 - } 6.1189 - if (append_branch(_msg, &result, 0, 0, q, 0, 0) == -1) { 6.1190 - goto done; 6.1191 - } 6.1192 - } 6.1193 - } 6.1194 - 6.1195 -done: 6.1196 - free_rdata_list(head); 6.1197 - return first ? -1 : 1; 6.1198 -} 6.1199 -
7.1 --- a/opensips/modules/enum/enum.h Wed Feb 10 21:25:01 2010 +0100 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,78 +0,0 @@ 7.4 -/* 7.5 - * $Id: enum.h 5901 2009-07-21 07:45:05Z bogdan_iancu $ 7.6 - * 7.7 - * Header file for Enum and E164 related functions 7.8 - * 7.9 - * Copyright (C) 2002-2008 Juha Heinanen 7.10 - * 7.11 - * This file is part of opensips, a free SIP server. 7.12 - * 7.13 - * opensips is free software; you can redistribute it and/or modify 7.14 - * it under the terms of the GNU General Public License as published by 7.15 - * the Free Software Foundation; either version 2 of the License, or 7.16 - * (at your option) any later version 7.17 - * 7.18 - * opensips is distributed in the hope that it will be useful, 7.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 7.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 7.21 - * GNU General Public License for more details. 7.22 - * 7.23 - * You should have received a copy of the GNU General Public License 7.24 - * along with this program; if not, write to the Free Software 7.25 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7.26 - */ 7.27 - 7.28 - 7.29 -#ifndef ENUM_H 7.30 -#define ENUM_H 7.31 - 7.32 - 7.33 -#include "../../parser/msg_parser.h" 7.34 - 7.35 - 7.36 -#define MAX_DOMAIN_SIZE 256 7.37 -#define MAX_COMPONENT_SIZE 32 /* separator, apex, ... This simplifies checks */ 7.38 - 7.39 - 7.40 -/* 7.41 - * Check if from user is an e164 number and has a naptr record 7.42 - */ 7.43 -int is_from_user_enum_0(struct sip_msg* _msg, char* _str1, char* _str2); 7.44 -int is_from_user_enum_1(struct sip_msg* _msg, char* _suffix, char* _str2); 7.45 -int is_from_user_enum_2(struct sip_msg* _msg, char* _suffix, char* _service); 7.46 - 7.47 -/* 7.48 - * do source number destination routing. 7.49 - * that is, make the ruri based on the from number 7.50 - * this is like source ip policy routing 7.51 - */ 7.52 -int enum_pv_query_1(struct sip_msg* _msg, char* _sp); 7.53 -int enum_pv_query_2(struct sip_msg* _msg, char* _sp, char* _suffix); 7.54 -int enum_pv_query_3(struct sip_msg* _msg, char* _sp, char* _suffix, 7.55 - char* _service); 7.56 - 7.57 -/* 7.58 - * Make enum query and if query succeeds, replace current uri with the 7.59 - * result of the query 7.60 - */ 7.61 -int enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2); 7.62 -int enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); 7.63 -int enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service); 7.64 - 7.65 -/* 7.66 - * Infrastructure ENUM versions. 7.67 - */ 7.68 -int i_enum_query_0(struct sip_msg* _msg, char* _str1, char* _str2); 7.69 -int i_enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); 7.70 -int i_enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service); 7.71 - 7.72 -/* 7.73 - * Make ISN query and if query succeeds, replace current uri with the 7.74 - * result of the query 7.75 - */ 7.76 -int isn_query_0(struct sip_msg* _msg, char* _str1, char* _str2); 7.77 -int isn_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); 7.78 -int isn_query_2(struct sip_msg* _msg, char* _suffix, char* _service); 7.79 - 7.80 - 7.81 -#endif /* ENUM_H */
8.1 --- a/opensips/modules/enum/enum_mod.c Wed Feb 10 21:25:01 2010 +0100 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,170 +0,0 @@ 8.4 -/* 8.5 - * $Id: enum_mod.c 5976 2009-08-18 13:35:23Z bogdan_iancu $ 8.6 - * 8.7 - * Enum module 8.8 - * 8.9 - * Copyright (C) 2002-2008 Juha Heinanen 8.10 - * 8.11 - * This file is part of opensips, a free SIP server. 8.12 - * 8.13 - * opensips is free software; you can redistribute it and/or modify 8.14 - * it under the terms of the GNU General Public License as published by 8.15 - * the Free Software Foundation; either version 2 of the License, or 8.16 - * (at your option) any later version 8.17 - * 8.18 - * opensips is distributed in the hope that it will be useful, 8.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 8.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 8.21 - * GNU General Public License for more details. 8.22 - * 8.23 - * You should have received a copy of the GNU General Public License 8.24 - * along with this program; if not, write to the Free Software 8.25 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 8.26 - * 8.27 - * History: 8.28 - * ------- 8.29 - * 2003-03-11: New module interface (janakj) 8.30 - * 2003-03-16: flags export parameter added (janakj) 8.31 - * 2003-12-15: added suffix parameter to enum_query (jh) 8.32 - */ 8.33 - 8.34 - 8.35 -#include "enum_mod.h" 8.36 -#include <stdio.h> 8.37 -#include <stdlib.h> 8.38 -#include "../../sr_module.h" 8.39 -#include "../../error.h" 8.40 -#include "../../mod_fix.h" 8.41 -#include "enum.h" 8.42 - 8.43 - 8.44 - 8.45 -/* 8.46 - * Module initialization function prototype 8.47 - */ 8.48 -static int mod_init(void); 8.49 - 8.50 - 8.51 -/* 8.52 - * Module parameter variables 8.53 - */ 8.54 -char* domain_suffix = "e164.arpa."; 8.55 -char* tel_uri_params = ""; 8.56 - 8.57 -char* branchlabel = "i"; 8.58 -char* i_enum_suffix = "e164.arpa."; 8.59 -char* bl_algorithm = "cc"; 8.60 - 8.61 -char* isn_suffix = "freenum.org."; 8.62 - 8.63 - 8.64 -/* 8.65 - * Internal module variables 8.66 - */ 8.67 -str suffix; 8.68 -str param; 8.69 -str service; 8.70 - 8.71 -str i_suffix; 8.72 -str i_branchlabel; 8.73 -str i_bl_alg; 8.74 - 8.75 -str isnsuffix; 8.76 - 8.77 - 8.78 -/* 8.79 - * Exported functions 8.80 - */ 8.81 -static cmd_export_t cmds[] = { 8.82 - {"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE}, 8.83 - {"enum_query", (cmd_function)enum_query_1, 1, fixup_str_null, 8.84 - fixup_free_str_null, REQUEST_ROUTE}, 8.85 - {"enum_query", (cmd_function)enum_query_2, 2, fixup_str_str, 8.86 - fixup_free_str_str, REQUEST_ROUTE}, 8.87 - {"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null, 8.88 - fixup_free_pvar_null, REQUEST_ROUTE}, 8.89 - {"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str, 8.90 - fixup_free_pvar_str, REQUEST_ROUTE}, 8.91 - {"enum_pv_query", (cmd_function)enum_pv_query_3, 3, 8.92 - fixup_pvar_str_str, fixup_free_pvar_str_str, REQUEST_ROUTE}, 8.93 - {"is_from_user_enum", (cmd_function)is_from_user_enum_0, 0, 0, 0, 8.94 - REQUEST_ROUTE}, 8.95 - {"is_from_user_enum", (cmd_function)is_from_user_enum_1, 1, 8.96 - fixup_str_null, fixup_free_str_null, REQUEST_ROUTE}, 8.97 - {"is_from_user_enum", (cmd_function)is_from_user_enum_2, 2, 8.98 - fixup_str_str, fixup_free_str_str, REQUEST_ROUTE}, 8.99 - {"i_enum_query", (cmd_function)i_enum_query_0, 0, 0, 0, REQUEST_ROUTE}, 8.100 - {"i_enum_query", (cmd_function)i_enum_query_1, 1, fixup_str_null, 0, 8.101 - REQUEST_ROUTE}, 8.102 - {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0, 8.103 - REQUEST_ROUTE}, 8.104 - {"isn_query", (cmd_function)isn_query_0, 0, 0, 0, REQUEST_ROUTE}, 8.105 - {"isn_query", (cmd_function)isn_query_1, 1, fixup_str_null, 8.106 - fixup_free_str_null, REQUEST_ROUTE}, 8.107 - {"isn_query", (cmd_function)isn_query_2, 2, fixup_str_str, 8.108 - fixup_free_str_str, REQUEST_ROUTE}, 8.109 - {0, 0, 0, 0, 0, 0} 8.110 -}; 8.111 - 8.112 - 8.113 -/* 8.114 - * Exported parameters 8.115 - */ 8.116 -static param_export_t params[] = { 8.117 - {"domain_suffix", STR_PARAM, &domain_suffix}, 8.118 - {"tel_uri_params", STR_PARAM, &tel_uri_params}, 8.119 - {"branchlabel", STR_PARAM, &branchlabel}, 8.120 - {"i_enum_suffix", STR_PARAM, &i_enum_suffix}, 8.121 - {"bl_algorithm", STR_PARAM, &bl_algorithm}, 8.122 - {"isn_suffix", STR_PARAM, &isn_suffix}, 8.123 - {0, 0, 0} 8.124 -}; 8.125 - 8.126 - 8.127 -/* 8.128 - * Module parameter variables 8.129 - */ 8.130 -struct module_exports exports = { 8.131 - "enum", 8.132 - MODULE_VERSION, 8.133 - DEFAULT_DLFLAGS, /* dlopen flags */ 8.134 - cmds, /* Exported functions */ 8.135 - params, /* Exported parameters */ 8.136 - 0, /* exported statistics */ 8.137 - 0, /* exported MI functions */ 8.138 - 0, /* exported pseudo-variables */ 8.139 - 0, /* extra processes */ 8.140 - mod_init, /* module initialization function */ 8.141 - 0, /* response function*/ 8.142 - 0, /* destroy function */ 8.143 - 0 /* per-child init function */ 8.144 -}; 8.145 - 8.146 - 8.147 -static int mod_init(void) 8.148 -{ 8.149 - LM_DBG("Initializing\n"); 8.150 - 8.151 - suffix.s = domain_suffix; 8.152 - suffix.len = strlen(suffix.s); 8.153 - 8.154 - param.s = tel_uri_params; 8.155 - param.len = strlen(param.s); 8.156 - 8.157 - service.len = 0; 8.158 - 8.159 - i_suffix.s = i_enum_suffix; 8.160 - i_suffix.len = strlen(i_enum_suffix); 8.161 - 8.162 - i_branchlabel.s = branchlabel; 8.163 - i_branchlabel.len = strlen(branchlabel); 8.164 - 8.165 - i_bl_alg.s = bl_algorithm; 8.166 - i_bl_alg.len = strlen(bl_algorithm); 8.167 - 8.168 - isnsuffix.s = isn_suffix; 8.169 - isnsuffix.len = strlen(isnsuffix.s); 8.170 - 8.171 - return 0; 8.172 -} 8.173 -
9.1 --- a/opensips/modules/enum/enum_mod.h Wed Feb 10 21:25:01 2010 +0100 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,47 +0,0 @@ 9.4 -/* 9.5 - * $Id: enum_mod.h 5901 2009-07-21 07:45:05Z bogdan_iancu $ 9.6 - * 9.7 - * Enum module headers 9.8 - * 9.9 - * Copyright (C) 2002-2003 Juha Heinanen 9.10 - * 9.11 - * This file is part of opensips, a free SIP server. 9.12 - * 9.13 - * opensips is free software; you can redistribute it and/or modify 9.14 - * it under the terms of the GNU General Public License as published by 9.15 - * the Free Software Foundation; either version 2 of the License, or 9.16 - * (at your option) any later version 9.17 - * 9.18 - * opensips is distributed in the hope that it will be useful, 9.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 9.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9.21 - * GNU General Public License for more details. 9.22 - * 9.23 - * You should have received a copy of the GNU General Public License 9.24 - * along with this program; if not, write to the Free Software 9.25 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9.26 - */ 9.27 - 9.28 - 9.29 -#ifndef ENUM_MOD_H 9.30 -#define ENUM_MOD_H 9.31 - 9.32 - 9.33 -#include "../../str.h" 9.34 - 9.35 - 9.36 -/* 9.37 - * Internal module variables 9.38 - */ 9.39 -extern str suffix; /* str version of domain_suffix */ 9.40 -extern str param; /* str version of tel_uri_params */ 9.41 -extern str service; /* default (empty) service */ 9.42 - 9.43 -extern str i_suffix; /* suffix for infrastructure ENUM */ 9.44 -extern str i_branchlabel; /* the label branching off the infrastructure tree */ 9.45 -extern str i_bl_alg; /* how to know where to branch off */ 9.46 - 9.47 -extern str isnsuffix; /* str version of isn_suffix */ 9.48 - 9.49 - 9.50 -#endif /* ENUM_MOD_H */