# ENUM Query

### Introduction

Starting with release 3.1, it is possible to issue ENUM Query requests to DNS servers from routing scripts. To do so, the params\[:enum\_query] object must be filled with the required ENUM Query attributes params\[:enum\_query]\[:fqdn] and [an exception must be raised](/configuration-details/configuration-by-web-portal-category/routing-scripts/development-guides-and-tutorials/enum-query.md) with reason :enum\_query\_required.

\
When ENUM Query completes, the routing script is called again with the result. The params\[:enum\_query] object will be filled with the ENUM Query attributes from the response. The params\[:enum\_query]\[:result] field will also contain a string indicating the result of the ENUM Query:

<br>

* *ok*: The ENUM Query was successful.
* *timeout*: The ENUM Query was not answered.

\
The params\[:enum\_query]\[:responses\_list] field will contain a list of hash responses for each NAPTR records.

NAPTR records contain:

* *:uri*
* *:order*
* *:preference*

\
Example:

***

> params\[:enum\_query]\[:responses\_list] \[{:order=>"200", :preference=>"10", :uri=>"!^03111.\*$!<sip:123456782@example-2.com>!"}, {:order=>"100", :preference=>"1", :uri=>"!^03222.\*$!<sip:123456782@example-3.com>!"}, {:order=>"200", :preference=>"1", :uri=>"!^03111.\*$!<sip:123456782@example-1.com>!"}]

***

Using enum\_called\_remap.rb before filter script allows handling of ENUM query requests/responses. The match and replace regular expression from ENUM query responses are applied to params\[:call]\[:called] to get "new called". This script allows update of the call parameters according to "new called" value. Refer to enum\_called\_remap.rb before filter script to get instructions on how to integrate this script into the main routing script (i.e. simple\_routing\_sbc.rb):

***

> ... require 'enum\_called\_remap' unless defined?(EnumCalledRemap) ... include EnumCalledRemap ... before\_filter :method => :enum\_called\_remap ...

***

### Resolve ENUM Query down to type A records

The ENUM query could also resolve uri from responses and get matching outgoing NAP, NAP proxy IP and port through a sequence of DNS queries (i.e. NAPTR, SRV down to type A records). This behavior could be requested using "dns\_query" parameter:

***

> params\[:enum\_query]\[:dns\_query] = true

***

When ENUM and DNS Queries complete, the routing script is called again with the results. The params\[:enum\_query] and params\[:dns\_query] objects will be filled with the ENUM Query and the DNS Query attributes from the responses. The DNS query responses are available through params\[:dns\_query]\[:responses\_list] call parameters:

***

> params\[:dns\_query]\[:responses\_list] \[{:nap=>"NAP\_UDP", :nap\_proxy\_ip=>"10.3.14.191", :nap\_proxy\_port=>"8080", :transport=>"UDP", :order=>"100", :preference=>"1", :priority=>"0", :weight=>"5"}, {:nap=>"NAP\_TCP", :nap\_proxy\_ip=>"10.3.14.192", :nap\_proxy\_port=>"8081", :transport=>"TCP", :order=>"100", :preference=>"2", :priority=>"1", :weight=>"10"}]

***

### Add dynamic routes

The ENUM query could also add dynamic routes base on DNS query responses. This could be requested using the "add\_dynamic\_routes" call parameter:

***

> params\[:enum\_query]\[:dns\_query] = true params\[:enum\_query]\[:add\_dynamic\_routes] = true

***

Note that it is mandatary to send DNS query to add dynamic routes.

The "base\_routing.rb" script version should be greater then 1.37 in order to allow dynamic routes creation base on DNS query responses.

When requesting to add\_dynamic\_routes, the dns\_query responses are used to create routes. Make sure that your configuration includes a route with remapped\_nap = "Registered or DNS users". A route will be created for each DNS query responses. The routes "remapped\_nap" takes NAP value from DNS query responses.

It is required to modify main routing script (i.e. simple\_routing\_sbc.rb) to forward IP/port values from params\[:routes] to params\[:call] like we are doing for NAP. See following example:

<br>

> ***
>
> ...
>
> \# This will select the outgoing NAP for this call according to the "remapped\_nap" route parameter route\_remap :call\_field\_name => :nap, :route\_field\_name => :remapped\_nap
>
> \# This will select the outgoing NAP proxy ip address for this call according to the "remapped\_nap\_proxy\_ip" route parameter route\_remap :call\_field\_name => :nap\_proxy\_ip, :route\_field\_name => :remapped\_nap\_proxy\_ip
>
> \# This will select the outgoing NAP proxy port for this call according to the "remapped\_nap\_proxy\_port" route parameter route\_remap :call\_field\_name => :nap\_proxy\_port, :route\_field\_name => :remapped\_nap\_proxy\_port ...

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://prosbcdocs.telcobridges.com/configuration-details/configuration-by-web-portal-category/routing-scripts/development-guides-and-tutorials/enum-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
