[asterisk-users] macro-dialout-trunk without agi or manager

Nathan Bell nathanb at actarg.com
Wed Sep 20 13:45:48 MST 2006


Hi everybody,

I'm working on implementing asterisk to sit between an outside T1 line 
and an aging pbx (intertel axxess). I've already received much help from 
the list, from Mimmus in particular, and for that I am very grateful.

Right now I'm getting stuck on implementing the macro for dialout-trunk. 
All of the implementations I have seen seem to come from freePBX. Simply 
dropping the freePBX macro into my extensions.conf does not result in a 
working macro as I am not using freePBX, or any other manager/AGI system 
at all right now.

Let's walk through the macro as I see it, and you can give me pointers 
on what needs to be changed.

[macro-dialout-trunk]
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(ROUTE_PASSWD=${ARG3})
exten => s,n,GotoIf($["${ROUTE_PASSWD}" = ""]?noauth) ; arg3 is pattern 
password
exten => s,n(auth),Authenticate(${ROUTE_PASSWD})
exten => s,n(noauth),Set(GROUP()=OUT_${DIAL_TRUNK})

As far as I can tell, this defines macro-dialout-trunk and takes a 
trunk, a number, and a password. For my implementation I won't need a 
password as everyone can call all trunks and any long-distance number 
they choose. I assume I can just chop off the last 4 lines of this part 
then.

exten => s,n,Macro(user-callerid)
exten => s,n,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})

I don't know what any of this is doing, or why it's doing it. I'll want 
to set the caller ID using a manager at some point in time, but as of 
right now I'll just be passing the caller id from the outside T1 along 
to the pbx.

exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n(checkmax),GotoIf($[ ${GROUP_COUNT()} > 
${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),AGI(fixlocalprefix) ; this sets DIAL_NUMBER to the 
proper dial string for this trunk

Right here is where I run into some serious problems. As my trunk is not 
defined by any manager I can only assume that the OUTMAXCHANS would be 
24. Is GROUP_COUNT() a function that I can define in extensions.conf to 
keep track of how many channels are currently used up? Each line could 
be used by an incoming or an outgoing connection, would this only 
keeping track of outgoing connections? Lastly, n(nomax) will "fix" the 
local prefix. What does this actually do?

exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER}) ; 
OUTNUM is the final dial number

That seems straightforward enough.

exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)}) ; Custom trunks 
are prefixed with "AMP:"
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},120,${TRUNK_OPTIONS}) ; 
Regular Trunk Dial
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)}) ; this is where 
we expect to find string OUTNUM
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum) ; if 
we didn't find "OUTNUM", then skip to Dial
exten => s,n(outnum),Set(the_num=${OUTNUM}) ; replace "OUTNUM" with the 
actual number to dial
exten => 
s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},120,${TRUNK_OPTIONS}) 

exten => s,n,Goto(s-${DIALSTATUS},1)

Oy vey, what a doozy. I'm quite sure that I won't need the 
n(customtrunk) part at all. I assume that I'll just be using the Dial 
and the following Goto.

exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,NoOp(Trunk is reporting BUSY)
exten => s-BUSY,2,Busy()
exten => s-BUSY,3,Wait(60)
exten => s-BUSY,4,NoOp()
exten => _s-.,1,NoOp(Dial failed due to ${DIALSTATUS})

Once again, this part is fairly straightforward, and I assume it will be 
a direct copy over to the end macro definition.


Perhaps I'm asking too much all at once, but I'd really like to better 
understand how I'm actually dialling a group of lines rather than just 
hacking at until it works. Thanks in advance to anyone that can explain 
it all to me.

Nathan Bell
IT Manager
Action Target, Inc.
nathanb at actarg.com


More information about the asterisk-users mailing list