opensips/modules/enum/README

Mon, 18 Jan 2010 19:47:23 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 18 Jan 2010 19:47:23 +0100
changeset 12
a3ac912f2857
child 13
b63f281afe6b
permissions
-rw-r--r--

Import unmodified vendor sources for correction and improvement.

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

mercurial