[Asterisk-Users] Fail over using CHANAVAIL

Chris Bagnall asterisk at minotaur.cc
Mon Jan 23 08:38:56 MST 2006


> > I am trying to construct a macro for long distance dialling. I have 
> > two internet feeds, I have all routes including Teliax on 
> Internet A 
> > and a static route to Voxee on Internet B.

Here's an AEL macro I use on our boxes. Modify for your needs.

// dial a number with a range of routing options
macro outbound (number, clid, route1, route2, route3, route4) {
        if ("${clid}" = "") {
                   CALLERID(number)=${DEFAULTCID};
        } else
                CALLERID(number)=${clid};
        dialstart:
        switch (${route1}) {
                case direct:
                        &dialout (${number});
                        break;
                case providera:
                        &dialout (IAX2/providera/${number});
                        break;
                case providerb:
                        &dialout (IAX2/providerb/${number});
                        break;
                case providerc:
                        &dialout (SIP/${number}@providerc);
                        break;
                case pstn:
                        &dialout (SIP/${number}@pstn);
                        break;
                default:
                        NoOp (invalid route: ${route1});
        };
        route1=${route2};
        route2=${route3};
        route3=${route4};
        if ("${route1}" = "") {
                Playtones (info);
                Congestion ();
        };
        goto dialstart;
};

// dial a number ignoring anything except busy
macro dialout (dialstring) {
        Dial (${dialstring},,TW);
        switch (${DIALSTATUS}) {
                case BUSY:
                        Playtones (busy);
                        Busy ();
                        break;
        };
};


Basically, replace dial commands in extensions.conf with a call to macro
"outbound", passing it the number to dial, callerid to present, and any
number of routes in the order you want them to be tried. The macro "dialout"
just ensures that if the number called is genuinely busy, "outbound" doesn't
plough on with routes 2,3,4 regardless.

Hope that helps.

Regards,

Chris
-- 
C.M. Bagnall, Director, Minotaur I.T. Limited
This email is made from 100% recycled electrons





More information about the asterisk-users mailing list