README 11 KB

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