Dialling ZAP channel from analogue phone

Hi,

Asterisk Version : 1.2.15
Card : TDM11B (1 x FXO , 1 x FXS)

I have internal dialling working okay SIP->ZAP (analogue phone) and ZAP (analogue phone) -> SIP.

The problem comes when I try and make a outbound call.

Here is my extensions.conf :-

[code][incoming]
exten => s,1,GoToIfTime(17:00-09:00\mon-fri**?outofhours|s,1)
exten => s,2,GoToIfTime(*\sat-sun**?outofhours|s,1)
exten => s,3,Answer()
exten => s,4,Dial(Zap/1,20)
exten => s,5,Playback(cybermog)
exten => s,6,VoiceMail(5000@incoming,s)
exten => s,7,Hangup()

[outofhours]
exten => s,1,Answer()
exten => s,2,Playback(cybermog)
exten => s,3,VoiceMail(5000@incoming,s)
exten => s,4,Hangup()

[internal]
include => outbound-local
include => uri
exten => 123,1,VoiceMailMain(@incoming)
exten => 123,2,Hangup()
exten => 6000,1,Dial(${ANGELA},20)
exten => 6000,2,VoiceMail(5000@incoming)
exten => 6000,3,Hangup()
exten => 6001,1,Dial(sip/uxbod,20)
exten => 6001,2,VoiceMail(5001@incoming)
exten => 6001,3,Hangup()

[in]
exten => uxbod,1,Dial(sip/uxbod,20)
exten => uxbod,2,VoiceMail(5001@incoming)
exten => uxbod,3,Hangup()

[outbound-local]
exten => _9NXXXXXX,1,Dial(${TRUNK}/${EXTEN:1})
exten => _9NXXXXXX,2,Congestion()
exten => _9NXXXXXX,102,Congestion()

[uri]
exten => _[a-z].,1,Macro(uridial,${EXTEN}@${SIPDOMAIN})
exten => _[A-Z].,1,Macro(uridial,${EXTEN}@${SIPDOMAIN})
exten => _X.,1,Macro(uridial,${EXTEN}@${SIPDOMAIN})

[macro-uridial]
exten => s,1,NoOp(Calling remote SIP peer ${ARG1})
exten => s,n,Dial(SIP/${ARG1},120,tr)
exten => s,n,Congestion()
[/code]

When I try dialling 912345678 the above configuration thinks that I am dialling a SIP number, and does not bridge the call to the ZAP FXO channel.

What am I doing wrong please ?

This is the debug output :-

[code]mailhub asterisk # asterisk -vvvvvvr
== Parsing ‘/etc/asterisk/asterisk.conf’: Found
== Parsing ‘/etc/asterisk/extconfig.conf’: Found
Asterisk 1.2.15, Copyright © 1999 - 2006 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘show license’ for details.

Connected to Asterisk 1.2.15 currently running on mailhub (pid = 6327)
Verbosity is at least 6
– Remote UNIX connection
– Starting simple switch on ‘Zap/1-1’
– Executing Macro(“Zap/1-1”, “uridial|9674035@”) in new stack
– Executing NoOp(“Zap/1-1”, “Calling remote SIP peer 9674035@”) in new stack
– Executing Dial(“Zap/1-1”, “SIP/9674035@|120|tr”) in new stack
Feb 25 18:59:38 WARNING[6365]: chan_sip.c:1993 create_addr: No such host:
Feb 25 18:59:38 NOTICE[6365]: app_dial.c:1055 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 3 - No route to destination)
== Everyone is busy/congested at this time (1:0/0/1)
– Executing Congestion(“Zap/1-1”, “”) in new stack
== Spawn extension (macro-uridial, s, 3) exited non-zero on ‘Zap/1-1’ in macro ‘uridial’
== Spawn extension (macro-uridial, s, 3) exited non-zero on ‘Zap/1-1’
– Hungup ‘Zap/1-1’
[/code]

It appears that everything is treated as a SIP call.

It seems that the system is prefering to go thru you uri context instead of goingt thru your zap card. Try removing include => uri and see what happens. If it works then, then you will have to redo your uri dial plan.

The last line of the uri context :-

exten => _X.,1,Macro(uridial,${EXTEN}@${SIPDOMAIN})

is causing the problem. So, how can I tell Asterisk too route via SIP if ${SIPDOMAIN} is not NULL, else route via another path ie. the ZAP interface ?

Not really. If the posted dial plan is exact, (and I’m guessing that your FXS goes to [internal] context) the problem is in your dial string. According to posted dial plan, only 92345678 can go to Zap channel; 91234567 or 912345678 only matches _9X., and NOT _9NXXXXXX. The latter restricts the dial string to be exactly 8 digits including a leading 9, and the second digit must be 2-9. So this is essentially for 9 followed by a 7-digit North American local number.

A useful diagnostic trick is

CLI> show dialplan 912345678@internal
(or dialplan show if 1.4). The first displayed entry will be used.

Hope this helps.

Sorry, should have said. Yes, I understand now that on the outbound-local the number of '9’s must match the number of digits dialled. But what happens if I was to dial 1234567@xyz.com that would match on the outbound local and would try to use the ZAP interface, instead of routing via SIP.

Are the above one and same problem or two separate issues? If latter, what is the remaining problem, and what is expected behaviour?

This by itself is fairly straight forward:

exten => _X.,1,GotoIf(${SIPDOMAIN}?uridial) ; prefix with 9 to beconsistent with existing context ; but still need to make sure that EXTEN does not begin with 1 exten => _X.,n,Goto(outbound-local,9${EXTEN},1) exten => _X.,n(uridial),Macro(uridial,${EXTEN}@${SIPDOMAIN})

Thanks Valley :smiley:

Valley, I am being really dumb now as cannot get this to work. Should I be removing the include lines and using the goto instead so that it branches. ie.

[code][incoming]
exten => s,1,GoToIfTime(17:00-09:00\mon-fri**?outofhours|s,1)
exten => s,2,GoToIfTime(*\sat-sun**?outofhours|s,1)
exten => s,3,Answer()
exten => s,4,Dial(Zap/1,20)
exten => s,5,Playback(cybermog)
exten => s,6,VoiceMail(5000@incoming,s)
exten => s,7,Hangup()

[outofhours]
exten => s,1,Answer()
exten => s,2,Playback(cybermog)
exten => s,3,VoiceMail(5000@incoming,s)
exten => s,4,Hangup()

[internal]
exten => 123,1,VoiceMailMain(@incoming)
exten => 123,2,Hangup()
exten => 6000,1,Dial(${ANGELA},20)
exten => 6000,2,VoiceMail(5000@incoming)
exten => 6000,3,Hangup()
exten => 6001,1,Dial(sip/uxbod,20)
exten => 6001,2,VoiceMail(5001@incoming)
exten => 6001,3,Hangup()
exten => _X.,1,GotoIf(${SIPDOMAIN}?uridial)
exten => _X.,n,Goto(outbound-local,9${EXTEN},1)

[in]
exten => uxbod,1,Dial(sip/uxbod,20)
exten => uxbod,2,VoiceMail(5001@incoming)
exten => uxbod,3,Hangup()

[outbound-local]
exten => _9NXXXXX,1,Dial(${TRUNK}/${EXTEN})
exten => _9NXXXXX,2,Congestion()
exten => _9NXXXXX,102,Congestion()
include => outbound-national

[outbound-national]
exten => _9NXXXXXXXXXX,1,Dial(${TRUNK}/${EXTEN})
exten => _9NXXXXXXXXXX,2,Congestion()

[uri]
exten => _X.,n(uridial),Macro(uridial,${EXTEN}@${SIPDOMAIN})

[macro-uridial]
exten => s,1,NoOp(Calling remote SIP peer ${ARG1})
exten => s,n,Dial(SIP/${ARG1},120,tr)
exten => s,n,Congestion()[/code]

Thanks,

[quote=“uxbod”][outbound-local]
exten => _9NXXXXX,1,Dial(${TRUNK}/${EXTEN})

include => outbound-national

[outbound-national]
exten => _9NXXXXXXXXXX,1,Dial(${TRUNK}/${EXTEN})
[/quote]

Include should be fine. And what exactly does not work? What do you see happening?

If Asterisk has problem routing your dialed numbers between local and national, it could be a numbering plan issue. From the above, I figure you are not in North America? You need to clarify your local numbering plan.

[quote=“uxbod”][internal]

exten => _X.,1,GotoIf(${SIPDOMAIN}?uridial)
exten => _X.,n,Goto(outbound-local,9${EXTEN},1)[/quote]

One part I don’t understand from your config is how [internal] receives value of SIPDOMAIN after you dial a number. Unless Asterisk has some way to tell if this variable is defined, it’s going to send all calls to one channel or the other.

Correct, I am based in the UK.

The outbound-local should match 6 numbers which is correct for UK local number, and the outbound-national should match 11 numbers.

Hmmm, I thought SIPDOMAIN was a inbuilt variable that gets extracted from the called number ie. sip:xyz@domain.com

Will do some more reading.

SIPDOMAIN is extracted from an incoming SIP call. To do what you wanted, you can use a standard-based data source (such as ENUM), or build a data source of your own for internal use.