Chapter 1. User's Guide

Enum module implements [i_]enum_query functions that make an enum query
based on the user part of the current Request-URI. These functions
assume that the user part consists of an international phone number
of the form +decimal-digits, where the number of digits is at
least 2 and at most 15. Out of this number
enum_query forms a domain name,
where the digits are in reverse order and separated by dots followed by
domain suffix that by default is "e164.arpa.". For example,
if the user part is +35831234567, the domain
name will be "7.6.5.4.3.2.1.3.8.5.3.e164.arpa.".
i_enum_query operates in a similar
fashion. The only difference is that it adds a label (default "i")
to branch off from the default, user-ENUM tree to an infrastructure ENUM tree.

After forming the domain name,
enum_query queries
DNS for its NAPTR records. From the possible response
enum_query chooses those records,
whose flags field has string value "u", and whose services field has
string value "e2u+[service:]sip" or
"e2u+type[:subtype][+type[:subtype]...]" (case is ignored in both
cases), and whose regexp field is of the form !pattern!replacement!.

Then enum_query sorts the chosen
NAPTR records based on their <order, preference>. After sorting,
enum_query replaces the current
Request URI by applying regexp of the most preferred NAPTR record its
user part and appends to the request new branches by applying regexp of
each remaining NAPTR record to the user part of the
current Request URI. If a new URI is a tel URI,
enum_query appends to it as tel
URI parameters the value of tel_uri_params module parameter. Finally,
enum_query associates a q value
with each new URI based on the <order, preference> of the
corresponding NAPTR record.

When using enum_query without any
parameters, it searches for NAPTRs with service type "e2u+sip" in the
default enum tree. When using
enum_query with a single parameter,
this parameter will be used as enum tree. When using
enum_query
with two parameters, the functionality depends on the first letter in
the second parameter. When the first letter is not a '+' sign, the
second parameter will be used to search for NAPTRs with service type
"e2u+parameter:sip". When the second parameter starts with a '+' sign,
the ENUM lookup also supports compound NAPTRs
(e.g. "e2u+voice:sip+video:sip") and searching for multiple service
types within one lookup. Multiple service types must be separeted
by a '+' sign.

Most of the time you want to route based on the RURI. On rare occasions
you may wish to route based on the user part of the "From:" tag,
analogous to source based policy routing in the ip world. The function
enum_fquery mimics the behaviour
of the enum_query function except the
user part of the "From:" is used for the enum lookup instead of the user
part of the RURI. Obviously the user part of the RURI is still used in the
naptr regexp.

Enum query returns 1 if the current Request URI was replaced
and -1 if not.

Enum module also implements is_from_user_enum function.
This function does an enum lookup on the from user and
returns true if found, false otherwise.

If set to "ebl", i_enum_query() will look for an EBL (ENUM Branch Label) record at
[branchlabel].[reverse-country-code].[i_enum_suffix]. See http://www.ietf.org/internet-drafts/draft-lendl-enum-branch-location-record-00.txt for a description of that record and the
meaning of the fields. The RR type for the EBL has not been allocated yet.
This version of the code uses 65300. See resolve.h.

The function performs an enum query and rewrites the Request-URI with
the result of the query. This the Infrastructure-ENUM version of enum_query().
The only difference to enum_query() is in the calculation of the
FQDN where NAPTR records are looked for.

See ftp://ftp.rfc-editor.org/in-notes/internet-drafts/draft-haberler-carrier-enum-01.txt
for the rationale behind this function.