michael@13: Index: modules/enum/enum_mod.h michael@13: diff -Nau modules/enum/enum_mod.h.orig modules/enum/enum_mod.h michael@13: --- modules/enum/enum_mod.h.orig 2010-01-18 15:54:52.842465412 +0100 michael@13: +++ modules/enum/enum_mod.h 2010-01-18 15:55:20.812190874 +0100 michael@13: @@ -41,5 +41,7 @@ michael@13: extern str i_branchlabel; /* the label branching off the infrastructure tree */ michael@13: extern str i_bl_alg; /* how to know where to branch off */ michael@13: michael@13: +extern str isnsuffix; /* str version of isn_suffix */ michael@13: + michael@13: michael@13: #endif /* ENUM_MOD_H */ michael@13: Index: modules/enum/enum_mod.c michael@13: diff -Nau modules/enum/enum_mod.c.orig modules/enum/enum_mod.c michael@13: --- modules/enum/enum_mod.c.orig 2010-01-18 15:52:57.316263519 +0100 michael@13: +++ modules/enum/enum_mod.c 2010-01-18 15:52:42.844229824 +0100 michael@13: @@ -55,6 +55,8 @@ michael@13: char* i_enum_suffix = "e164.arpa."; michael@13: char* bl_algorithm = "cc"; michael@13: michael@13: +char* isn_suffix = "freenum.org."; michael@13: + michael@13: michael@13: /* michael@13: * Internal module variables michael@13: @@ -67,6 +69,8 @@ michael@13: str i_branchlabel; michael@13: str i_bl_alg; michael@13: michael@13: +str isnsuffix; michael@13: + michael@13: michael@13: /* michael@13: * Exported functions michael@13: @@ -94,6 +98,11 @@ michael@13: REQUEST_ROUTE}, michael@13: {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0, michael@13: REQUEST_ROUTE}, michael@13: + {"isn_query", (cmd_function)isn_query_0, 0, 0, 0, REQUEST_ROUTE}, michael@13: + {"isn_query", (cmd_function)isn_query_1, 1, fixup_str_null, michael@13: + fixup_free_str_null, REQUEST_ROUTE}, michael@13: + {"isn_query", (cmd_function)isn_query_2, 2, fixup_str_str, michael@13: + fixup_free_str_str, REQUEST_ROUTE}, michael@13: {0, 0, 0, 0, 0, 0} michael@13: }; michael@13: michael@13: @@ -107,6 +116,7 @@ michael@13: {"branchlabel", STR_PARAM, &branchlabel}, michael@13: {"i_enum_suffix", STR_PARAM, &i_enum_suffix}, michael@13: {"bl_algorithm", STR_PARAM, &bl_algorithm}, michael@13: + {"isn_suffix", STR_PARAM, &isn_suffix}, michael@13: {0, 0, 0} michael@13: }; michael@13: michael@13: @@ -152,6 +162,9 @@ michael@13: i_bl_alg.s = bl_algorithm; michael@13: i_bl_alg.len = strlen(bl_algorithm); michael@13: michael@13: + isnsuffix.s = isn_suffix; michael@13: + isnsuffix.len = strlen(isn_suffix.s); michael@13: + michael@13: return 0; michael@13: } michael@13: michael@13: Index: modules/enum/enum.h michael@13: diff -Nau modules/enum/enum.h.orig modules/enum/enum.h michael@13: --- modules/enum/enum.h.orig 2010-01-18 15:54:40.361624448 +0100 michael@13: +++ modules/enum/enum.h 2010-01-18 15:54:43.090330399 +0100 michael@13: @@ -66,5 +66,13 @@ michael@13: int i_enum_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); michael@13: int i_enum_query_2(struct sip_msg* _msg, char* _suffix, char* _service); michael@13: michael@13: +/* michael@13: + * Make ISN query and if query succeeds, replace current uri with the michael@13: + * result of the query michael@13: + */ michael@13: +int isn_query_0(struct sip_msg* _msg, char* _str1, char* _str2); michael@13: +int isn_query_1(struct sip_msg* _msg, char* _suffix, char* _str2); michael@13: +int isn_query_2(struct sip_msg* _msg, char* _suffix, char* _service); michael@13: + michael@13: michael@13: #endif /* ENUM_H */ michael@13: Index: modules/enum/enum.c michael@13: diff -Nau modules/enum/enum.c.orig modules/enum/enum.c michael@13: --- modules/enum/enum.c.orig 2010-01-18 15:57:10.995902181 +0100 michael@13: +++ modules/enum/enum.c 2010-01-18 15:46:19.642209178 +0100 michael@13: @@ -736,6 +736,84 @@ michael@13: } michael@13: michael@13: michael@13: +/* michael@13: + * Call isn_query_2 with module parameter suffix and default service. michael@13: + */ michael@13: +int isn_query_0(struct sip_msg* _msg, char* _str1, char* _str2) michael@13: +{ michael@13: + return isn_query_2(_msg, (char *)(&isnsuffix), (char *)(&service)); michael@13: +} michael@13: + michael@13: + michael@13: +/* michael@13: + * Call isn_query_2 with given suffix and default service. michael@13: + */ michael@13: +int isn_query_1(struct sip_msg* _msg, char* _suffix, char* _str2) michael@13: +{ michael@13: + return isn_query_2(_msg, _suffix, (char *)(&service)); michael@13: +} michael@13: + michael@13: + michael@13: +/* michael@13: + * See documentation in README file. michael@13: + */ michael@13: +int isn_query_2(struct sip_msg* _msg, char* _suffix, char* _service) michael@13: +{ michael@13: + char *user_s = NULL; michael@13: + int user_len, i, j; michael@13: + char name[MAX_DOMAIN_SIZE] = {0}; michael@13: + char string[17] = {0}; michael@13: + char szItad[17] = {0}; michael@13: + size_t nItlen = 0; michael@13: + michael@13: + str *suffix, *service; michael@13: + michael@13: + suffix = (str*)_suffix; michael@13: + service = (str*)_service; michael@13: + michael@13: + if (parse_sip_msg_uri(_msg) < 0) { michael@13: + LM_ERR("Parsing of R-URI failed\n"); michael@13: + return -1; michael@13: + } michael@13: + michael@13: + user_s = _msg->parsed_uri.user.s; michael@13: + user_len = _msg->parsed_uri.user.len; michael@13: + michael@13: + memcpy(&(string[0]), user_s, user_len); michael@13: + string[user_len] = (char)0; michael@13: + michael@13: + /* Do primitive test for correct ISN format, */ michael@13: + /* and set szItad to the ISN ITAD (RFC 3872/2871). */ michael@13: + /* Correct ISN format guessed from freenum.org and IANA */ michael@13: + /* doc http://www.iana.org/assignments/trip-parameters/ */ michael@13: + { michael@13: + char *pAster = strchr(string, '*'); michael@13: + if (pAster && (nItlen = strspn(pAster + sizeof(char), "0123456789"))) michael@13: + strncpy(szItad, pAster + sizeof(char), nItlen); michael@13: + else { michael@13: + LM_ERR("R-URI user does not contain a valid ISN\n"); michael@13: + return -1; michael@13: + } michael@13: + } michael@13: + michael@13: + /* Ammend the original ENUM E.164 string logic to process */ michael@13: + /* ISN numbers instead, which include a nonreversed ITAD. */ michael@13: + i = user_len - nItlen - sizeof(char); /* Ex: *1212 */ michael@13: + j = 0; michael@13: + while (i--) { michael@13: + name[j] = user_s[i]; michael@13: + name[j + 1] = '.'; michael@13: + j = j + 2; michael@13: + } michael@13: + michael@13: + strcat(name + j, szItad); /* Copy the unreversed ITAD, */ michael@13: + name[j + nItlen] = '.'; /* and append a trailing dot. */ michael@13: + memcpy(name + j + nItlen + sizeof(char), suffix->s, suffix->len + 1); michael@13: + michael@13: + return do_query(_msg, string, name, service); michael@13: +} michael@13: + michael@13: + michael@13: /*********** INFRASTRUCTURE ENUM ***************/ michael@13: michael@13: /* michael@13: Index: modules/enum/README michael@13: diff -Nau modules/enum/README.orig modules/enum/README michael@13: --- modules/enum/README.orig 2010-01-18 17:59:52.034172367 +0100 michael@13: +++ modules/enum/README 2010-01-18 18:01:30.730633377 +0100 michael@13: @@ -10,8 +10,8 @@ michael@13: michael@13: Copyright © 2002, 2003 Juha Heinanen michael@13: Revision History michael@13: - Revision $Revision: 5906 $ $Date: 2009-07-21 10:45:05 +0300 michael@13: - (Tue, 21 Jul 2009) $ michael@13: + Revision $Revision: 5907 $ $Date: 2010-01-18 10:45:05 +0100 michael@13: + (Mon, 18 Jan 2010) $ michael@13: __________________________________________________________ michael@13: michael@13: Table of Contents michael@13: @@ -25,28 +25,32 @@ michael@13: 1.3.1. domain_suffix (string) michael@13: 1.3.2. tel_uri_params (string) michael@13: 1.3.3. i_enum_suffix (string) michael@13: - 1.3.4. branchlabel (string) michael@13: - 1.3.5. bl_algorithm (string) michael@13: + 1.3.4. isn_suffix (string) michael@13: + 1.3.5. branchlabel (string) michael@13: + 1.3.6. bl_algorithm (string) michael@13: michael@13: 1.4. Exported Functions michael@13: michael@13: 1.4.1. enum_query(["suffix"[,"service"]]) michael@13: 1.4.2. enum_pv_query("pvar"[,"suffix"[,"service"]]) michael@13: 1.4.3. i_enum_query(["suffix"[,"service"]]) michael@13: - 1.4.4. is_from_user_enum() michael@13: + 1.4.4. isn_query(["suffix"[,"service"]]) michael@13: + 1.4.5. is_from_user_enum() michael@13: michael@13: List of Examples michael@13: michael@13: 1.1. Setting domain_suffix module parameter michael@13: 1.2. Setting tel_uri_params module parameter michael@13: 1.3. Setting i_enum_suffix module parameter michael@13: - 1.4. Setting brachlabel module parameter michael@13: - 1.5. Zone file example michael@13: + 1.4. Setting isn_query usage module parameter michael@13: + 1.5. Setting branchlabel module parameter michael@13: 1.6. Zone file example michael@13: - 1.7. Setting the bl_algorithm module parameter michael@13: - 1.8. enum_query usage michael@13: - 1.9. enum_pv_query usage michael@13: - 1.10. is_from_user_enum usage michael@13: + 1.7. Zone file example michael@13: + 1.8. Setting the bl_algorithm module parameter michael@13: + 1.9. enum_query usage michael@13: + 1.10. enum_pv_query usage michael@13: + 1.11. isn_query usage michael@13: + 1.12. is_from_user_enum usage michael@13: michael@13: Chapter 1. Admin Guide michael@13: michael@13: @@ -113,6 +117,22 @@ michael@13: function does an enum lookup on the from user and returns true michael@13: if found, false otherwise. michael@13: michael@13: + In addition to standard ENUM, support for ISN (ITAD Subscriber michael@13: + Numbers) is provided as well. To allow ISN lookups to resolve, michael@13: + a different formatting algorithm is expected by the DNS server. michael@13: + Whereas a ENUM NAPTR record expects a DNS query of the form michael@13: + 9.8.7.6.5.4.3.2.1., ISN method expects a DNS query of michael@13: + the form 6.5.1212.. That is, a valid ISN number includes michael@13: + a prefix of '56' in the example. The rest of the number is a michael@13: + ITAD (Internet Telephony Administrative Domain) as defined michael@13: + in RFCs 3872 and 2871, and as allocated by the IANA in michael@13: + http://www.iana.org/assignments/trip-parameters. The ITAD is michael@13: + left intact and not refersed as ENUM requires. To learn more michael@13: + about ISN please refer to documents at www.freenum.org. michael@13: + michael@13: + To complete a ISN lookup on the user part of the Request-URI, michael@13: + isn_query() is used instead of enum_query(). michael@13: + michael@13: 1.2. Dependencies michael@13: michael@13: The module depends on the following modules (in the other words michael@13: @@ -158,17 +178,27 @@ michael@13: Example 1.3. Setting i_enum_suffix module parameter michael@13: modparam("enum", "i_enum_suffix", "e1234.arpa.") michael@13: michael@13: -1.3.4. branchlabel (string) michael@13: +1.3.4. isn_suffix (string) michael@13: + michael@13: + The domain suffix to be used for isn_query() lookups. Can be michael@13: + overridden by a parameter to isn_query. michael@13: + michael@13: + Default value is "freenum.org." michael@13: + michael@13: + Example 1.4. Setting isn_suffix module parameter michael@13: +modparam("enum", "isn_suffix", "freenum.org.") michael@13: + michael@13: +1.3.5. branchlabel (string) michael@13: michael@13: This parameter determines which label i_enum_query() will use michael@13: to branch off to the infrastructure ENUM tree. michael@13: michael@13: Default value is ""i"" michael@13: michael@13: - Example 1.4. Setting brachlabel module parameter michael@13: + Example 1.5. Setting branchlabel module parameter michael@13: modparam("enum", "branchlabel", "i") michael@13: michael@13: -1.3.5. bl_algorithm (string) michael@13: +1.3.6. bl_algorithm (string) michael@13: michael@13: This parameter determines which algorithm i_enum_query() will michael@13: use to select the position in the DNS tree where the michael@13: @@ -182,7 +212,7 @@ michael@13: [branchlabel].[reverse-country-code].[i_enum_suffix] to michael@13: indicate after how many digits the label should in inserted. michael@13: michael@13: - Example 1.5. Zone file example michael@13: + Example 1.6. Zone file example michael@13: i.1.e164.arpa. IN TXT "4" michael@13: 9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5 michael@13: 678 999" michael@13: @@ -196,7 +226,7 @@ michael@13: allocated yet. This version of the code uses 65300. See michael@13: resolve.h. michael@13: michael@13: - Example 1.6. Zone file example michael@13: + Example 1.7. Zone file example michael@13: i.1.e164.arpa. TYPE65300 \# 14 ( michael@13: 04 ; position michael@13: 01 69 ; separator michael@13: @@ -208,7 +238,7 @@ michael@13: michael@13: Default value is "cc" michael@13: michael@13: - Example 1.7. Setting the bl_algorithm module parameter michael@13: + Example 1.8. Setting the bl_algorithm module parameter michael@13: modparam("enum", "bl_algorithm", "txt") michael@13: michael@13: 1.4. Exported Functions michael@13: @@ -225,7 +255,7 @@ michael@13: michael@13: This function can be used from REQUEST_ROUTE. michael@13: michael@13: - Example 1.8. enum_query usage michael@13: + Example 1.9. enum_query usage michael@13: ... michael@13: # search for "e2u+sip" in freenum.org michael@13: enum_query("freenum.org."); michael@13: @@ -262,7 +292,7 @@ michael@13: michael@13: This function can be used from REQUEST_ROUTE. michael@13: michael@13: - Example 1.9. enum_pv_query usage michael@13: + Example 1.10. enum_pv_query usage michael@13: ... michael@13: # search for "e2u+sip" in freenum.org michael@13: enum_pv_query("$avp(i:100)", "freenum.org."); michael@13: @@ -296,14 +326,42 @@ michael@13: ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberle michael@13: r-carrier-enum-01.txt for the rationale behind this function. michael@13: michael@13: -1.4.4. is_from_user_enum() michael@13: +1.4.4. isn_query(["suffix"[,"service"]]) michael@13: + michael@13: + The function performs a ISN query and rewrites the michael@13: + Request-URI with the result of the query. See Section 1.1, michael@13: + "Overview" for more information. michael@13: + michael@13: + Meaning of the parameters is as follows: michael@13: + * suffix - Suffix to be appended to the domain name. michael@13: + * service - Service string to be used in the service field. michael@13: + michael@13: + This function can be used from REQUEST_ROUTE. michael@13: + michael@13: + See ftp://www.ietf.org/rfc/rfc3872.txt and michael@13: + ftp://www.ietf.org/rfc/rfc2871.txt for information michael@13: + regarding the ITAD part of the ISN string. michael@13: + michael@13: + Example 1.11. isn_query usage michael@13: +... michael@13: +# search for "e2u+sip" in freenum.org michael@13: +isn_query("freenum.org."); michael@13: +... michael@13: +# search for "e2u+sip" in default tree (configured as parameter) michael@13: +enum_query(); michael@13: +... michael@13: +# search for "e2u+voice:sip" in freenum.org michael@13: +enum_query("freenum.org.","voice"); michael@13: +... michael@13: + michael@13: +1.4.5. is_from_user_enum() michael@13: michael@13: Checks if the user part of from URI is found in an enum lookup. michael@13: Returns 1 if yes and -1 if not. michael@13: michael@13: This function can be used from REQUEST_ROUTE. michael@13: michael@13: - Example 1.10. is_from_user_enum usage michael@13: + Example 1.12. is_from_user_enum usage michael@13: ... michael@13: if (is_from_user_enum()) { michael@13: .... michael@13: Index: modules/enum/doc/enum.xml michael@13: diff -Nau modules/enum/doc/enum.xml.orig modules/enum/doc/enum.xml michael@13: --- modules/enum/doc/enum.xml.orig 2009-10-16 02:31:52.000000000 +0200 michael@13: +++ modules/enum/doc/enum.xml 2010-01-18 18:01:15.954172402 +0100 michael@13: @@ -33,8 +33,8 @@ michael@13: michael@13: michael@13: michael@13: - $Revision: 5901 $ michael@13: - $Date: 2009-07-21 10:45:05 +0300 (Tue, 21 Jul 2009) $ michael@13: + $Revision: 5907 $ michael@13: + $Date: 2010-01-18 10:45:05 +0100 (Mon, 18 Jan 2010) $ michael@13: michael@13: michael@13: michael@13: Index: modules/enum/doc/enum_admin.xml michael@13: diff -Nau modules/enum/doc/enum_admin.xml.orig modules/enum/doc/enum_admin.xml michael@13: --- modules/enum/doc/enum_admin.xml.orig 2010-01-18 12:33:30.053644000 +0100 michael@13: +++ modules/enum/doc/enum_admin.xml 2010-01-18 18:14:59.583157910 +0100 michael@13: @@ -75,6 +75,24 @@ michael@13: and -1 if not. michael@13: michael@13: michael@13: + In addition to standard ENUM, support for ISN (ITAD Subscriber michael@13: + Numbers) is provided as well. To allow ISN lookups to resolve, michael@13: + a different formatting algorithm is expected by the DNS server. michael@13: + Whereas a ENUM NAPTR record expects a DNS query of the form michael@13: + 9.8.7.6.5.4.3.2.1., ISN method expects a DNS query of michael@13: + the form 6.5.1212.. That is, a valid ISN number includes michael@13: + a prefix of '56' in the example. The rest of the number is a michael@13: + ITAD (Internet Telephony Administrative Domain) as defined michael@13: + in RFCs 3872 and 2871, and as allocated by the IANA in michael@13: + http://www.iana.org/assignments/trip-parameters. The ITAD is michael@13: + left intact and not refersed as ENUM requires. To learn more michael@13: + about ISN please refer to documents at www.freenum.org. michael@13: + michael@13: + michael@13: + To complete a ISN lookup on the user part of the Request-URI, michael@13: + isn_query() is used instead of enum_query(). michael@13: + michael@13: + michael@13: Enum module also implements is_from_user_enum function. michael@13: This function does an enum lookup on the from user and michael@13: returns true if found, false otherwise. michael@13: @@ -153,6 +171,22 @@ michael@13: michael@13: michael@13:
michael@13: + <varname>isn_suffix</varname> (string) michael@13: + michael@13: + The domain suffix to be used for isn_query() lookups. Can michael@13: + be overridden by a parameter to isn_query. michael@13: + michael@13: + michael@13: + Default value is freenum.org. michael@13: + michael@13: + michael@13: + Setting isn_suffix module parameter michael@13: + michael@13: +modparam("enum", "isn_suffix", "freenum.org.") michael@13: + michael@13: + michael@13: +
michael@13: +
michael@13: <varname>branchlabel</varname> (string) michael@13: michael@13: This parameter determines which label i_enum_query() will use michael@13: @@ -162,7 +196,7 @@ michael@13: Default value is "i" michael@13: michael@13: michael@13: - Setting brachlabel module parameter michael@13: + Setting branchlabel module parameter michael@13: michael@13: modparam("enum", "branchlabel", "i") michael@13: michael@13: @@ -353,6 +387,53 @@ michael@13:
michael@13: michael@13:
michael@13: + michael@13: + <function moreinfo="none">isn_query(["suffix"[,"service"]])</function> michael@13: + michael@13: + michael@13: + The function performs a ISN query and rewrites the Request-URI with michael@13: + the result of the query. See for more michael@13: + information. michael@13: + michael@13: + Meaning of the parameters is as follows: michael@13: + michael@13: + michael@13: + suffix - Suffix to be appended to the michael@13: + domain name. michael@13: + michael@13: + michael@13: + michael@13: + service - Service string to be used in michael@13: + the service field. michael@13: + michael@13: + michael@13: + michael@13: + michael@13: + This function can be used from REQUEST_ROUTE. michael@13: + michael@13: + michael@13: + See ftp://www.ietf.org/rfc/rfc3872.txt and michael@13: + ftp://www.ietf.org/rfc/rfc2871.txt for information michael@13: + regarding the ITAD part of the ISN string. michael@13: + michael@13: + michael@13: + <function moreinfo="none">isn_query</function> usage michael@13: + michael@13: +... michael@13: +# search for "e2u+sip" in freenum.org michael@13: +isn_query("freenum.org."); michael@13: +... michael@13: +# search for "e2u+sip" in default tree (configured as parameter) michael@13: +isn_query(); michael@13: +... michael@13: +# search for "e2u+voice:sip" in freenum.org michael@13: +isn_query("freenum.org.","voice"); michael@13: +... michael@13: + michael@13: + michael@13: +
michael@13: + michael@13: +
michael@13: <function moreinfo="none">is_from_user_enum()</function> michael@13: michael@13: Checks if the user part of from URI