[asterisk-users] Prefix/Suffix/StripLSD/StripMSD gone?
Paul Schenkeveld
asterisk-users at psconsult.nl
Tue Nov 21 13:41:45 MST 2006
On Tue, Nov 21, 2006 at 01:18:47PM -0600, Don Pobanz wrote:
> >Have Prefix, Suffix, StripLSD and StripMSD disappeared?
>
> yes
>
> >Is there another way to manipulate the current extention
> >an continue at the appropriate line in the current context?
>
> see substrings and String Concatenation under variables
> http://www.voip-info.org/wiki-Asterisk+variables
Ok, but if I use this to change EXTEN, asterisk will continue to
process statements in the same context based on the original value
of EXTEN.
What I tried to accomplish is this:
112 emergency call to be routed through
_0. outside line calls using LCR rules in extensions.conf
_90. force outside calls through ISDN
_91. force outside calls through provider 1
_92. force outside calls through provider 2
Note that in many countries here in Europe 0 is used for outside lines,
06 are cellphone numbers, 0800 tollfree, 09XX payed services and 112 is
the emergency number.
So what I had thought up is:
[globals]
PROV_EMERG=90 ; Emergency calls go out via ISDN
PROV_INT=91 ; Provider 1 for international calls
PROV_NAT=92 ; Provider 2 for national calls
PROV_0800=90 ; Tollfree calls go out via ISDN
PROV_09XX=90 ; Payed services calls go out via ISDN
PROV_06=90 ; Cellphone calls go out via ISDN
[outgoing]
; Allow emergency calls with or without 0 for outside lines
exten => 112,1,Prefix(0)
; Emergency calls always via ISDN
exten => 0112,1,NoOp(Emergency call)
exten => 0112,n,Prefix(${PROV_EMERG})
; International calls
exten => _00.,1,NoOp(International call to ${EXTEN})
exten => _00.,n,Prefix(${PROV_INT})
; National calls (always 10 digits)
exten => _0[1-57]XXXXXXXX,1,NoOp(National call to ${EXTEN})
exten => _0[1-57]XXXXXXXX,n,Prefix(${PROV_NAT})
; Cell phone calls (always 10 digits)
exten => _06XXXXXXXX,1,NoOp(06 call to ${EXTEN})
exten => _06XXXXXXXX,n,Prefix(${PROV_06})
; Tollfree calls (variable length)
exten => _0800.,1,NoOp(0800 call to ${EXTEN})
exten => _0800.,n,Prefix(${PROV_0800})
; Payed services (variable length)
exten => _09XX.,1,NoOp(0800 call to ${EXTEN})
exten => _09XX.,n,Prefix(${PROV_09XX})
; Out via ISDN
exten => _90.,1,NoOp(Routing via ISDN)
exten => _90.,n, ...
; Out via provider 1
exten => _91.,1,NoOp(Routing via provider 1)
exten => _91.,n, ...
; Out via provider 1
exten => _92.,1,NoOp(Routing via provider 2)
exten => _92.,n, ...
; Out via provider 1
exten => _93.,1,NoOp(Routing via provider 3)
exten => _93.,n, ...
exten => _X,1,Congestion()
According to the online docs and the O'Reilly book, after a Prefix()
asterisk continues at the first match of the new value of EXTEN. With
SetVar I see that asterisk continues with the next priority of the old
EXTEN value.
Is there another way to accomplish the above?
Note that originating a call to a provider sometimes needs more than
just a Dial() application. For example, one of my providers wants
customers to do round-robin and failover voice routing:
[macro-safedial]
exten = s,1,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten = s,n,Goto(s-${DIALSTATUS},1)
exten = s-CANCEL,1,Hangup
exten = s-NOANSWER,1,GotoIf($["${DIALEDTIME}" = "0"]?out)
exten = s-NOANSWER,n,Hangup
exten = s-NOANSWER,n(out),Verbose(1,Need failover for "${ARG1}")
exten = s-BUSY,1,Busy
exten = s-CHANUNAVAIL,1,Verbose(1,Need failover for "${ARG1}")
exten = s-CONGESTION,1,Congestion()
exten = _s-.,1,Congestion()
exten = s-,1,Congestion()
[route-pstn]
exten = _X.,1,Random(33:switch03)
exten = _X.,n,Random(50:switch02)
exten = _X.,n(switch01),Macro(safedial,IAX2/switch01/${EXTEN})
exten = _X.,n,Macro(safedial,IAX2/switch02/${EXTEN})
exten = _X.,n,Macro(safedial,IAX2/switch03/${EXTEN})
exten = _X.,n,Goto(out)
exten = _X.,n(switch02),Macro(safedial,IAX2/switch02/${EXTEN})
exten = _X.,n,Macro(safedial,IAX2/switch03/${EXTEN})
exten = _X.,n,Macro(safedial,IAX2/switch01/${EXTEN})
exten = _X.,n,Goto(out)
exten = _X.,n(switch03),Macro(safedial,IAX2/switch03/${EXTEN})
exten = _X.,n,Macro(safedial,IAX2/switch01/${EXTEN})
exten = _X.,n,Macro(safedial,IAX2/switch02/${EXTEN})
exten = _X.,n(out),Congestion()
exten = i,1,Congestion()
-- Paul Schenkeveld
More information about the asterisk-users
mailing list