ENUM Query
Last updated
Was this helpful?
Last updated
Was this helpful?
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 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:
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.*$!!"}, {:order=>"100", :preference=>"1", :uri=>"!^03222.*$!!"}, {:order=>"200", :preference=>"1", :uri=>"!^03111.*$!!"}]
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 ...
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"}]
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:
...
# 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 ...