[asterisk-users] Rewriting numbers while processing dial plan?

Martin Lima ra25 at atlas.cz
Tue Feb 10 15:59:57 CST 2009


> What I am trying to do, is get rid of the initial "+" in phone numbers
> coming in from VoIP clients on mobile phones. I have outgoing extensions
> that choose which of two providers to choose (based on cost for different
> destinations), and I was hoping not having to have two sets of extension
> rules - one for the 00 and one for the + variety.

You dont have to keep two sets. Just rewrite + by 00 and jump to appropriate 
context/extension.
I use this for almost the same, just replacing 00xxxxxx, 011xxxx and 1xxxx by 
+ or +1. 


[long-distance]
exten => _00.,1,Goto(+${EXTEN:2},1)
exten => _1NXXNXXXXXX,1,Goto(+${EXTEN},1)
exten => _011.,1,Goto(+${EXTEN:3},1)

;USA
exten => _+1NXXNXXXXXX,1,Answer()
exten => _+1NXXNXXXXXX,n,Macro(enumdial,${EXTEN})
exten => _+1NXXNXXXXXX,n,Set(CALLERID(num)=+18579284409)
exten => _+1NXXNXXXXXX,n,Playback(pls-hold-while-try)
and so on...
Martin
> An example of how I'm having to do this now:
>
> [outgoing]
>
> exten => _00.,1,Verbose(International call 00 - Vyke)
> exten => _00.,n,Dial(SIP/vyke/$EXTEN,30,tr)
> exten => _00.,n,Hangup
>
> exten => _+.,1,Verbose(International call + - Vyke)
> exten => _+.,n,Dial(SIP/vyke/00${EXTEN:1},30,tr)
> exten => _+.,n,Hangup
>
> I was however hoping that it'd be possible to have a general rule that
> would match the initial +, rewrite it to 00 and continue with the first of
> the two patterns shown above.
>
> A banale example (which does not work):
>
> [outgoing]
>
> exten => _+.,1,Goto(outgoing,00${EXTEN:1},1)
>
> exten => _00.,1,Verbose(International call 00 - Vyke)
>
> exten => _00.,n,Dial(SIP/vyke/$EXTEN,30,tr)
>
> exten => _00.,n,Hangup
>
>
> What am I doing wrong here?
>
> Thanks in advance for your kind assistance!
>
> Best regards
> Jan
>
> _________________________________________________________________
> Twice the fun—Share photos while you chat with Windows Live Messenger.
> Learn more.
> http://www.microsoft.com/uk/windows/windowslive/products/messenger.aspx





More information about the asterisk-users mailing list