README 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. Enum Module
  2. Juha Heinanen
  3. <[email protected]>
  4. Otmar Lendl
  5. <[email protected]>
  6. Copyright © 2002, 2003 Juha Heinanen
  7. Revision History
  8. Revision $Revision$ $Date$
  9. __________________________________________________________________
  10. Table of Contents
  11. 1. Admin Guide
  12. 1. Overview
  13. 2. Dependencies
  14. 3. Exported Parameters
  15. 3.1. domain_suffix (string)
  16. 3.2. tel_uri_params (string)
  17. 3.3. i_enum_suffix (string)
  18. 3.4. branchlabel (string)
  19. 3.5. bl_algorithm (string)
  20. 4. Exported Functions
  21. 4.1. enum_query(["suffix"[,"service"]])
  22. 4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
  23. 4.3. i_enum_query(["suffix"[,"service"]])
  24. 4.4. is_from_user_enum()
  25. List of Examples
  26. 1.1. Setting domain_suffix module parameter
  27. 1.2. Setting tel_uri_params module parameter
  28. 1.3. Setting i_enum_suffix module parameter
  29. 1.4. Setting brachlabel module parameter
  30. 1.5. Zone file example
  31. 1.6. Zone file example
  32. 1.7. Setting the bl_algorithm module parameter
  33. 1.8. enum_query usage
  34. 1.9. enum_pv_query usage
  35. 1.10. is_from_user_enum usage
  36. Chapter 1. Admin Guide
  37. Table of Contents
  38. 1. Overview
  39. 2. Dependencies
  40. 3. Exported Parameters
  41. 3.1. domain_suffix (string)
  42. 3.2. tel_uri_params (string)
  43. 3.3. i_enum_suffix (string)
  44. 3.4. branchlabel (string)
  45. 3.5. bl_algorithm (string)
  46. 4. Exported Functions
  47. 4.1. enum_query(["suffix"[,"service"]])
  48. 4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
  49. 4.3. i_enum_query(["suffix"[,"service"]])
  50. 4.4. is_from_user_enum()
  51. 1. Overview
  52. Enum module implements [i_]enum_query functions that make an enum query
  53. based on the user part of the current Request-URI. These functions
  54. assume that the Request URI user part consists of an international
  55. phone number of the form +decimal-digits, where the number of digits is
  56. at least 2 and at most 15. Out of this number enum_query forms a domain
  57. name, where the digits are in reverse order and separated by dots
  58. followed by domain suffix that by default is "e164.arpa.". For example,
  59. if the user part is +35831234567, the domain name will be
  60. "7.6.5.4.3.2.1.3.8.5.3.e164.arpa.". i_enum_query operates in a similar
  61. fashion. The only difference is that it adds a label (default "i") to
  62. branch off from the default, user-ENUM tree to an infrastructure ENUM
  63. tree.
  64. After forming the domain name, enum_query queries DNS for enum NAPTR
  65. records. From the possible responses enum_query chooses those records,
  66. whose flags field has string value "u", and whose services field has
  67. string value "e2u+[service:]sip" or
  68. "e2u+type[:subtype][+type[:subtype]...]" (case is ignored in both
  69. cases), and whose regexp field is of the form !pattern!replacement!.
  70. Then enum_query sorts the chosen NAPTR records based on their <order,
  71. preference>. After sorting, enum_query replaces the current Request URI
  72. by applying the regular expression of the most preferred NAPTR record
  73. to its user part and appends to the request new branches by applying
  74. regexp of each remaining NAPTR record to the user part of the current
  75. Request URI. If a new URI is a tel: URI, enum_query appends to it as
  76. tel: URI parameters the value of tel_uri_params module parameter.
  77. Finally, enum_query associates a q value with each new URI based on the
  78. <order, preference> of the corresponding NAPTR record.
  79. When using enum_query without any parameters, it searches for NAPTRs
  80. with service type "e2u+sip" in the default enum tree. When using
  81. enum_query with a single parameter, this parameter will be used as enum
  82. tree. When using enum_query with two parameters, the functionality
  83. depends on the first letter in the second parameter. When the first
  84. letter is not a '+' sign, the second parameter will be used to search
  85. for NAPTRs with service type "e2u+parameter:sip". When the second
  86. parameter starts with a '+' sign, the ENUM lookup also supports
  87. compound NAPTRs (e.g. "e2u+voice:sip+video:sip") and searching for
  88. multiple service types within one lookup. Multiple service types must
  89. be separeted by a '+' sign.
  90. Most of the time you want to route based on the RURI. On rare occasions
  91. you may wish to route based on something else. The function
  92. enum_pv_query mimics the behavior of the enum_query function except the
  93. E.164 number in its pseudo variable argument is used for the enum
  94. lookup instead of the user part of the RURI. Obviously the user part of
  95. the RURI is still used in the NAPTR regexp.
  96. Enum query returns 1 if the current Request URI was replaced and -1 if
  97. not.
  98. Enum module also implements is_from_user_enum function. This function
  99. does an enum lookup on the from user and returns true if found, false
  100. otherwise.
  101. 2. Dependencies
  102. The module depends on the following modules (in other words the listed
  103. modules must be loaded before this module):
  104. * No dependencies.
  105. 3. Exported Parameters
  106. 3.1. domain_suffix (string)
  107. 3.2. tel_uri_params (string)
  108. 3.3. i_enum_suffix (string)
  109. 3.4. branchlabel (string)
  110. 3.5. bl_algorithm (string)
  111. 3.1. domain_suffix (string)
  112. The domain suffix to be added to the domain name obtained from the
  113. digits of an E164 number. Can be overridden by a parameter to
  114. enum_query.
  115. Default value is "e164.arpa."
  116. Example 1.1. Setting domain_suffix module parameter
  117. modparam("enum", "domain_suffix", "e1234.arpa.")
  118. 3.2. tel_uri_params (string)
  119. A string whose contents is appended to each new tel URI in the request
  120. as tel URI parameters.
  121. Note
  122. Currently Kamailio does not support tel URIs. This means that at
  123. present tel_uri_params is appended as URI parameters to every URI.
  124. Default value is ""
  125. Example 1.2. Setting tel_uri_params module parameter
  126. modparam("enum", "tel_uri_params", ";npdi")
  127. 3.3. i_enum_suffix (string)
  128. The domain suffix to be used for i_enum_query() lookups. Can be
  129. overridden by a parameter to i_enum_query.
  130. Default value is "e164.arpa."
  131. Example 1.3. Setting i_enum_suffix module parameter
  132. modparam("enum", "i_enum_suffix", "e1234.arpa.")
  133. 3.4. branchlabel (string)
  134. This parameter determines which label i_enum_query() will use to branch
  135. off to the infrastructure ENUM tree.
  136. Default value is ""i""
  137. Example 1.4. Setting brachlabel module parameter
  138. modparam("enum", "branchlabel", "i")
  139. 3.5. bl_algorithm (string)
  140. This parameter determines which algorithm i_enum_query() will use to
  141. select the position in the DNS tree where the infrastructure tree
  142. branches off the user ENUM tree.
  143. If set to "cc", i_enum_query() will always insert the label at the
  144. country-code level. Examples: i.1.e164.arpa, i.3.4.e164.arpa,
  145. i.2.5.3.e164.arpa
  146. If set to "txt", i_enum_query() will look for a TXT record at
  147. [branchlabel].[reverse-country-code].[i_enum_suffix] to indicate after
  148. how many digits the label should in inserted.
  149. Example 1.5. Zone file example
  150. i.1.e164.arpa. IN TXT "4"
  151. 9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678 999"
  152. If set to "ebl", i_enum_query() will look for an EBL (ENUM Branch
  153. Label) record at [branchlabel].[reverse-country-code].[i_enum_suffix].
  154. See
  155. http://www.ietf.org/internet-drafts/draft-lendl-enum-branch-location-re
  156. cord-00.txt for a description of that record and the meaning of the
  157. fields. The RR type for the EBL has not been allocated yet. This
  158. version of the code uses 65300. See resolve.h.
  159. Example 1.6. Zone file example
  160. i.1.e164.arpa. TYPE65300 \# 14 (
  161. 04 ; position
  162. 01 69 ; separator
  163. 04 65 31 36 34 04 61 72 70 61 00 ; e164.arpa
  164. ; )
  165. 9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678 999"
  166. Default value is "cc"
  167. Example 1.7. Setting the bl_algorithm module parameter
  168. modparam("enum", "bl_algorithm", "txt")
  169. 4. Exported Functions
  170. 4.1. enum_query(["suffix"[,"service"]])
  171. 4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
  172. 4.3. i_enum_query(["suffix"[,"service"]])
  173. 4.4. is_from_user_enum()
  174. 4.1. enum_query(["suffix"[,"service"]])
  175. The function performs an enum query and rewrites the Request-URI with
  176. the result of the query. See Section 1, "Overview" for more
  177. information.
  178. Meaning of the parameters is as follows:
  179. * suffix - Suffix to be appended to the domain name.
  180. * service - Service string to be used in the service field.
  181. This function can be used from REQUEST_ROUTE.
  182. Example 1.8. enum_query usage
  183. ...
  184. # search for "e2u+sip" in freenum.org
  185. enum_query("freenum.org.");
  186. ...
  187. # search for "e2u+sip" in default tree (configured as parameter)
  188. enum_query();
  189. ...
  190. # search for "e2u+voice:sip" in e164.arpa
  191. enum_query("e164.arpa.","voice");
  192. ...
  193. # search for service type "sip" or "voice:sip" or "video:sip"
  194. # note the '+' sign in front of the second parameter
  195. enum_query("e164.arpa.","+sip+voice:sip+video:sip");
  196. ...
  197. # quering for service sip and voice:sip
  198. enum_query("e164.arpa.");
  199. enum_query("e164.arpa.","voice");
  200. # or use instead
  201. enum_query("e164.arpa.","+sip+voice:sip");
  202. ...
  203. 4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
  204. The function performs an enum query on E.164 number stored in its
  205. pseudo variable argument and rewrites the Request-URI with the result
  206. of the query. See Section 1, "Overview" for more information.
  207. Meaning of the parameters is as follows:
  208. * pvar - Pseudo variable that holds an E.164 number on which enum
  209. query is performed.
  210. * suffix - Suffix to be appended to the domain name.
  211. * service - Service string to be used in the service field.
  212. This function can be used from REQUEST_ROUTE.
  213. Example 1.9. enum_pv_query usage
  214. ...
  215. # search for "e2u+sip" in freenum.org
  216. enum_pv_query("$avp(i:100)", "freenum.org.");
  217. ...
  218. # search for "e2u+sip" in default tree (configured as parameter)
  219. enum_pv_query("$fU");
  220. ...
  221. # search for "e2u+voice:sip" in e164.arpa
  222. enum_pv_query("$avp(i:100)","e164.arpa.","voice");
  223. ...
  224. # search for service type "sip" or "voice:sip" or "video:sip"
  225. # note the '+' sign in front of the second parameter
  226. enum_pv_query("$fU","e164.arpa.","+sip+voice:sip+video:sip");
  227. ...
  228. # quering for service sip and voice:sip
  229. enum_pv_query("$avp(i:100)","e164.arpa.");
  230. enum_pv_query("$avp(i:100)","e164.arpa.","voice");
  231. # or use instead
  232. enum_pv_query("$avp(i:100)","e164.arpa.","+sip+voice:sip");
  233. ...
  234. 4.3. i_enum_query(["suffix"[,"service"]])
  235. The function performs an enum query and rewrites the Request-URI with
  236. the result of the query. This the Infrastructure-ENUM version of
  237. enum_query(). The only difference to enum_query() is in the calculation
  238. of the FQDN where NAPTR records are looked for.
  239. See
  240. ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberler-carrie
  241. r-enum-01.txt for the rationale behind this function.
  242. 4.4. is_from_user_enum()
  243. Checks if the user part of from URI is found in an enum lookup. Returns
  244. 1 if yes and -1 if not.
  245. This function can be used from REQUEST_ROUTE.
  246. Example 1.10. is_from_user_enum usage
  247. ...
  248. if (is_from_user_enum()) {
  249. ....
  250. };
  251. ...