README 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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.
  95. Enum query returns 1 if the current Request URI was replaced and -1 if
  96. not.
  97. Enum module also implements is_from_user_enum function. This function
  98. does an enum lookup on the from user and returns true if found, false
  99. otherwise.
  100. 2. Dependencies
  101. The module depends on the following modules (in other words the listed
  102. modules must be loaded before this module):
  103. * No dependencies.
  104. 3. Exported Parameters
  105. 3.1. domain_suffix (string)
  106. 3.2. tel_uri_params (string)
  107. 3.3. i_enum_suffix (string)
  108. 3.4. branchlabel (string)
  109. 3.5. bl_algorithm (string)
  110. 3.1. domain_suffix (string)
  111. The domain suffix to be added to the domain name obtained from the
  112. digits of an E164 number. Can be overridden by a parameter to
  113. enum_query.
  114. Default value is “e164.arpa.”
  115. Example 1.1. Setting domain_suffix module parameter
  116. modparam("enum", "domain_suffix", "e1234.arpa.")
  117. 3.2. tel_uri_params (string)
  118. A string whose contents is appended to each new tel URI in the request
  119. as tel URI parameters.
  120. Note
  121. Currently SIP Router does not support tel URIs. This means that at
  122. present tel_uri_params is appended as URI parameters to every URI.
  123. Default value is “”
  124. Example 1.2. Setting tel_uri_params module parameter
  125. modparam("enum", "tel_uri_params", ";npdi")
  126. 3.3. i_enum_suffix (string)
  127. The domain suffix to be used for i_enum_query() lookups. Can be
  128. overridden by a parameter to i_enum_query.
  129. Default value is “e164.arpa.”
  130. Example 1.3. Setting i_enum_suffix module parameter
  131. modparam("enum", "i_enum_suffix", "e1234.arpa.")
  132. 3.4. branchlabel (string)
  133. This parameter determines which label i_enum_query() will use to branch
  134. off to the infrastructure ENUM tree.
  135. Default value is “"i"”
  136. Example 1.4. Setting brachlabel module parameter
  137. modparam("enum", "branchlabel", "i")
  138. 3.5. bl_algorithm (string)
  139. This parameter determines which algorithm i_enum_query() will use to
  140. select the position in the DNS tree where the infrastructure tree
  141. branches off the user ENUM tree.
  142. If set to "cc", i_enum_query() will always insert the label at the
  143. country-code level. Examples: i.1.e164.arpa, i.3.4.e164.arpa,
  144. i.2.5.3.e164.arpa
  145. If set to "txt", i_enum_query() will look for a TXT record at
  146. [branchlabel].[reverse-country-code].[i_enum_suffix] to indicate after
  147. how many digits the label should in inserted.
  148. Example 1.5. Zone file example
  149. i.1.e164.arpa. IN TXT "4"
  150. 9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678 999"
  151. If set to "ebl", i_enum_query() will look for an EBL (ENUM Branch
  152. Label) record at [branchlabel].[reverse-country-code].[i_enum_suffix].
  153. See
  154. http://www.ietf.org/internet-drafts/draft-lendl-enum-branch-location-re
  155. cord-00.txt for a description of that record and the meaning of the
  156. fields. The RR type for the EBL has not been allocated yet. This
  157. version of the code uses 65300. See resolve.h.
  158. Example 1.6. Zone file example
  159. i.1.e164.arpa. TYPE65300 \# 14 (
  160. 04 ; position
  161. 01 69 ; separator
  162. 04 65 31 36 34 04 61 72 70 61 00 ; e164.arpa
  163. ; )
  164. 9.9.9.8.7.6.5.i.4.3.2.1.e164.arpa. IN NAPTR "NAPTR content for +1 234 5678 999"
  165. Default value is “cc”
  166. Example 1.7. Setting the bl_algorithm module parameter
  167. modparam("enum", "bl_algorithm", "txt")
  168. 4. Exported Functions
  169. 4.1. enum_query(["suffix"[,"service"]])
  170. 4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
  171. 4.3. i_enum_query(["suffix"[,"service"]])
  172. 4.4. is_from_user_enum()
  173. 4.1. enum_query(["suffix"[,"service"]])
  174. The function performs an enum query and rewrites the Request-URI with
  175. the result of the query. See Section 1, “Overview” for more
  176. information.
  177. Meaning of the parameters is as follows:
  178. * suffix - Suffix string to be appended to the domain name. String
  179. may contain pseudo variables.
  180. * service - Service string to be used in the service field. String
  181. may contain pseudo variables.
  182. This function can be used from REQUEST_ROUTE.
  183. Example 1.8. enum_query usage
  184. ...
  185. # search for "e2u+sip" in freenum.org
  186. enum_query("freenum.org.");
  187. ...
  188. # search for "e2u+sip" in default tree (configured as parameter)
  189. enum_query();
  190. ...
  191. # search for "e2u+voice:sip" in e164.arpa
  192. enum_query("e164.arpa.","voice");
  193. ...
  194. # search for service type "sip" or "voice:sip" or "video:sip"
  195. # note the '+' sign in front of the second parameter
  196. enum_query("e164.arpa.","+sip+voice:sip+video:sip");
  197. ...
  198. # quering for service sip and voice:sip
  199. enum_query("e164.arpa.");
  200. enum_query("e164.arpa.","voice");
  201. # or use instead
  202. enum_query("e164.arpa.","+sip+voice:sip");
  203. ...
  204. 4.2. enum_pv_query("pvar"[,"suffix"[,"service"]])
  205. The function performs an enum query on E.164 number stored in its
  206. pseudo variable argument and rewrites the Request-URI with the result
  207. of the query. See Section 1, “Overview” for more information.
  208. Meaning of the parameters is as follows:
  209. * pvar - Pseudo variable that holds an E.164 number on which enum
  210. query is performed.
  211. * suffix - Suffix to be appended to the domain name.
  212. * service - Service string to be used in the service field.
  213. This function can be used from REQUEST_ROUTE.
  214. Example 1.9. enum_pv_query usage
  215. ...
  216. # search for "e2u+sip" in freenum.org
  217. enum_pv_query("$avp(i:100)", "freenum.org.");
  218. ...
  219. # search for "e2u+sip" in default tree (configured as parameter)
  220. enum_pv_query("$fU");
  221. ...
  222. # search for "e2u+voice:sip" in e164.arpa
  223. enum_pv_query("$avp(i:100)","e164.arpa.","voice");
  224. ...
  225. # search for service type "sip" or "voice:sip" or "video:sip"
  226. # note the '+' sign in front of the second parameter
  227. enum_pv_query("$fU","e164.arpa.","+sip+voice:sip+video:sip");
  228. ...
  229. # quering for service sip and voice:sip
  230. enum_pv_query("$avp(i:100)","e164.arpa.");
  231. enum_pv_query("$avp(i:100)","e164.arpa.","voice");
  232. # or use instead
  233. enum_pv_query("$avp(i:100)","e164.arpa.","+sip+voice:sip");
  234. ...
  235. 4.3. i_enum_query(["suffix"[,"service"]])
  236. The function performs an enum query and rewrites the Request-URI with
  237. the result of the query. This the Infrastructure-ENUM version of
  238. enum_query(). The only difference to enum_query() is in the calculation
  239. of the FQDN where NAPTR records are looked for.
  240. See
  241. ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberler-carrie
  242. r-enum-01.txt for the rationale behind this function.
  243. 4.4. is_from_user_enum()
  244. Checks if the user part of from URI is found in an enum lookup. Returns
  245. 1 if yes and -1 if not.
  246. This function can be used from REQUEST_ROUTE.
  247. Example 1.10. is_from_user_enum usage
  248. ...
  249. if (is_from_user_enum()) {
  250. ....
  251. };
  252. ...