[Asterisk-Users] Toll-Free Gateway Beta Test: freenum.org

John Todd jtodd at loligo.com
Tue Jan 20 21:57:50 MST 2004


The freenum.org beta continues to roll forward.  If you have an Asterisk or SER SIP gateway/proxy, please see if you can make some sense of the examples below and install them in your system.  Your users will hopefully be able to dial toll free numbers in various nations just like they dial regular numbers in those same country codes.  

I'd like to get some additional people trying to make some calls out through the service so I can catch any bugs.  Currently, this is only a test but will move to "production" soon.  This message is to illustrate some simple methods of integrating the ENUM capable free-number dialing into your SIP infrastructure, and also to see if the momentum we've gathered can convince some additional trunk providers that they should offer some toll-free paths to the project for testing.

Also: if you have some spare trunks in your nation that you wouldn't mind allowing for use as toll-free gateways into your country code, let me know and I'll add you to the rotation.  Multiple trunks per nation are supported in a round-robin method; the more the merrier.

JT

====== countries on-line ======

Countries/Dialing codes currently served:

Austria:*             +43-800-...
 via: Vienna University


Finland:*             +358-800-...
 via: mobileghost


France:*              +33-800-...
                      +33-805-...
 via: Axialys Interactive


Germany: *            +49-800-...
                      +49-130-...
 via: [netzquadrat] GmbH

 
Netherlands:*         +31-800-...
 via: ag-projects.com


United Kingdom:*      +44-800-...
                      +44-808-...
                      +44-500-...
 via: Magrathea Systems Ltd.
 via: Telecomplete Ltd.


United States:*       +1-800-...
                      +1-888-...
                      +1-877-...
                      +1-866-...
 via: Telesthetic/Local Exchange Carriers of Michigan

Universal Toll Free:* +800-...
 via: [netzquadrat] GmbH 
 via: Magrathea Systems Ltd
  (more info at http://www.tollfreeworld.com/)

* = tested and found to be functional as of 2004-01-19



======= Asterisk configuration =========

Here is what your enum.conf file would look like:

 ; start
 [general]
 search => freenum.org
 search => e164.arpa
 ; end

Here is an example of what you'd put in your extensions.conf to use ENUM lookups:


[enum-test]
;
; This routine checks to see if the number being dialed can
;  be handled with an ENUM lookup.  I have enabled enum for
;  freenum.org and e164.arpa in enum.conf.  If there
;  is no match found in ENUM, then the number is passed
;  back out to my "normal" dialing routines.  Freenum uses
;  a variety of toll-free gateways in other nations in a 
;  dynamic fashion - see http://www.freenum.org/ for info.

; I am not looping through ENUM results.  It is the case that
;  there are ENUM lookups which will return multiple NAPTRs
;  for the same record lookup (for redundancy/load balancing)
;  and if the first NAPTR fails we should probably try to 
;  connect to a different one in the list.  This can be
;  accomplished by doing the ENUM lookup again, since DNS
;  will round-robin the replies and so we will probably get
;  a different response on the second try.  However, that
;  is a bit too complex for this example.
;
; This context is a "first served" context for my particular
;  dialplan, meaning that I have some of my sip phones listed
;  with "context=enum-test" so that when a number is dialed the
;  call flow starts here.  You may choose to use ENUM lookups
;  as a last resort; it's up to you.
;
; Here in North America, we dial "011" before any international
;  call.  So, to dial a number in the UK (44) we would dial
;  0114480033330000 as an example.  I need to strip the first
;  three digits off the number to get the e164 number, which
;  just starts with the country code and everything after it.
; 
exten => _011X.,1,EnumLookup(${EXTEN:3})
;
; EnumLookup will result in success, which goes to n+1, or
;  if a tel: answer is provided, it jumps to n+51, and if 
;  the lookup fails entirely it will jump to n+101.  The two
;  failure cases (n+51 and n+101) should just jump to the
;  pointer for normal case dialing out an analog or other
;  path, as no ENUM result was found.
;
exten => _011X.,52,Goto(normal-dial,${EXTEN},1)
exten => _011X.,102,Goto(normal-dial,${EXTEN},1)
;
; So, we have a successful lookup!  Let's continue and see if we
;  can use it to actually create a VoIP dial method.  EnumLookup
;  sets the ${ENUM} variable to the dial string that we should
;  use for the dial attempt.
;
; Are the first three digits of the returned value of ${ENUM} are
;  either SIP or IAX?  If not, we ignore and pass to normal
;  dialing path at priority 4.  If you have H.323 enabled, then
;  you should modify accordingly.
;
exten => _011X.,2,GotoIf($[$[${ENUM:0:3} = SIP] | $[${ENUM:0:3} = IAX]]?3:4)
;
; Dial the number; end of routine.  If you have some type of
;  standard macro that handles dialing, you should replace
;  priority 4 with that macro.
;
exten => _011X.,3,Dial(${ENUM})
;
; Oops!  We got an error of some type back from the Dial. 
;  This could be for many reasons, but let's assume that
;  we should continue sending the call out through other
;  methods.  We handle both the busy and "other" error 
;  cases, which jump to n+101 and n+1 cases.
;
exten => _011X.,4,Goto(normal-dial,${EXTEN},1)
exten => _011X.,104,Goto(normal-dial,${EXTEN},1)
;
;
; Now that we've handled international numbers, let's repeat the
;  process but for North American numbers, which are dialed differently
;  from international numbers.  We look for 1-800, 1-866, 1-877, and 1-888
; This is the same methodology for international, but without comments, and
;  we leave the leading "1" on the number when we do the lookup since 
;  conveniently that is the country code for North America.
; 
exten => _18[88|77|66|00]X.,1,EnumLookup(${EXTEN})
exten => _18[88|77|66|00]X.,52,Goto(normal-dial,${EXTEN},1)
exten => _18[88|77|66|00]X.,102,Goto(normal-dial,${EXTEN},1)
exten => _18[88|77|66|00]X.,2,GotoIf($[$[${ENUM:0:3} = SIP] | $[${ENUM:0:3} = IAX]]?3:4)
exten => _18[88|77|66|00]X.,3,Dial(${ENUM})
exten => _18[88|77|66|00]X.,4,Goto(normal-dial,${EXTEN},1)
exten => _18[88|77|66|00]X.,104,Goto(normal-dial,${EXTEN},1)
;
exten => t,1,Hangup
exten => i,1,Hangup
exten => h,1,Hangup
;
include => normal-dial
;
;
[normal-dial]
; the normal-dial context just serves as a placeholder for
;  my regular inbound context for my SIP phones, which is [intern]
; I use an include in the enum-test context so that if there is no
;  match on any of the ENUM-capable dialstrings, then we just jump
;  to [intern] with the original dialed number.
; In practice, adding the ENUM lookup adds about 1/10th of a second
;  to the dialing process using my local resolvers for both the 
;  freenum.org and e164.arpa lookups (which happen transparently as
;  part of the EnumLookup function) so I see no reason not to put
;  this lookup in front of every call.
;
exten => _.,1,Goto(intern,${EXTEN},1)
;
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup
;
; end of example


====== SER configuration ========

 # note: anyone with a better recipe is welcome to send it
 # to me, as this has not been tested by me personally.  numbers at freenum.org

        # catch voice:sip ENUM entries, only if PSTN not forced
        if (enum_query("e164.arpa.", "voice")) {
            if (is_uri_host_local()) {
                route(5);
                break;
            };
            if (!t_relay()) {
                xlog("L_ERR", "%is [%Tf]: %rm %fu -> %ru [R4]: ENUM destination: relaying failed\n");
                sl_reply_error();
                break;
            };
            break;
        };
        #start
        # look up freenum.org ENUM entries
        if (enum_query("freenum.org")) {
            if (!t_relay()) {
                xlog("L_ERR", "%is [%Tf]: %rm %fu -> %ru [R4]: freenum.org destination: relaying failed\n");
                sl_reply_error();
                break;
            };
            xlog("L_ERR", "%is [%Tf]: %rm %fu -> %ru [R4]: freenum.org destination\n");
            break;
        };
        #end
        # nothing found, try PSTN
        if (method=="CANCEL" || method=="BYE" || method=="ACK") {
            xlog("L_INFO", "%is [%Tf]: %rm %fu -> %ru [R4]: just forwarding to PSTN");
            rewritehostport("1.2.3.4:5060");
            t_relay();
            break;
        };

====== end of configurations ========





More information about the asterisk-users mailing list