TOLL=SIP/YourVoipCarrier

p 149 of Asterisk, the Definitive Guide says that the TOLL variable “…is to simplify management of your dialplan…”. Fair enough, but how does it simplify management?

they have:

[globals]
TOLL = SIP/YourVoipCarrier

fair enough, but what does that accomplish, exactly, that’s advantageous?

Is there some flaw in doing this:

mordor*CLI> 
mordor*CLI> dialplan show myphones
[ Context 'myphones' created by 'pbx_config' ]
  '1000' =>         1. Dial(SIP/1000)                             [pbx_config]
                    2. Hangup()                                   [pbx_config]
  '1001' =>         1. Dial(SIP/1001)                             [pbx_config]
                    2. Hangup()                                   [pbx_config]
  '201' =>          1. Answer()                                   [pbx_config]
                    2. Playback(tt-monty-knights)                 [pbx_config]
                    3. Hangup()                                   [pbx_config]
  '202' =>          1. Answer()                                   [pbx_config]
                    2. Playback(welcome)                          [pbx_config]
                    3. Playback(demo-echotest)                    [pbx_config]
                    4. Echo()                                     [pbx_config]
                    5. Playback(demo-echodone)                    [pbx_config]
                    6. Playback(vm-goodbye)                       [pbx_config]
                    7. Hangup()                                   [pbx_config]
  '4000' =>         1. Playback(tt-monkeys)                       [pbx_config]
  '5000' =>         1. Playback(tt-monkeysintro)                  [pbx_config]
  '555' =>          1. Playback(hello-world)                      [pbx_config]
                    2. Playback(echo-test)                        [pbx_config]
                    3. Echo()                                     [pbx_config]
                    4. Playback(demo-echodone)                    [pbx_config]
  '6001' =>         1. Dial(SIP/demo_alice,20)                    [pbx_config]
  '6002' =>         1. Dial(SIP/demo_bob,20)                      [pbx_config]
  '6003' =>         1. Dial(SIP/thufir,20)                        [pbx_config]
  '6004' =>         1. Dial(SIP/hawat,20)                         [pbx_config]
  Include =>        'outgoing'                                    [pbx_config]

-= 11 extensions (24 priorities) in 1 context. =-
mordor*CLI> 
mordor*CLI> dialplan show outgoing
[ Context 'outgoing' created by 'pbx_config' ]
  '_1NXXNXXXXXX' => 1. NoOp()                                     [pbx_config]
                    2. Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:1} through TELNYX) [pbx_config]
                    3. Dial(SIP/TELNYX/${EXTEN:1},60)             [pbx_config]
                    4. Playtones(congestion)                      [pbx_config]
                    5. Hangup()                                   [pbx_config]

-= 1 extension (5 priorities) in 1 context. =-
mordor*CLI> 
mordor*CLI> 
mordor*CLI> 
mordor*CLI> 
mordor*CLI> channel originate SIP/thufir extension 18003569377@outgoing
  == Using SIP RTP CoS mark 5
    -- Called thufir
    -- SIP/thufir-00000032 is ringing
    -- SIP/thufir-00000032 answered
    -- Executing [18003569377@outgoing:1] NoOp("SIP/thufir-00000032", "") in new stack
    -- Executing [18003569377@outgoing:2] Log("SIP/thufir-00000032", "NOTICE, Dialing out from "" <> to 8003569377 through TELNYX") in new stack
[Jul  3 00:35:05] NOTICE[5495][C-00000024]: Ext. 18003569377:2 @ outgoing:  Dialing out from "" <> to 8003569377 through TELNYX
    -- Executing [18003569377@outgoing:3] Dial("SIP/thufir-00000032", "SIP/TELNYX/8003569377,60") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/TELNYX/8003569377
       > 0x7f25a005f400 -- Probation passed - setting RTP source address to 192.168.1.5:16394
    -- SIP/TELNYX-00000033 is ringing
    -- SIP/TELNYX-00000033 is making progress passing it to SIP/thufir-00000032
       > 0x7f25e0005e60 -- Probation passed - setting RTP source address to 64.16.240.36:20954
    -- SIP/TELNYX-00000033 answered SIP/thufir-00000032
    -- Channel SIP/thufir-00000032 joined 'simple_bridge' basic-bridge <6ba41abb-76e3-4e2e-9f78-f91e1b50c35d>
    -- Channel SIP/TELNYX-00000033 joined 'simple_bridge' basic-bridge <6ba41abb-76e3-4e2e-9f78-f91e1b50c35d>
       > Bridge 6ba41abb-76e3-4e2e-9f78-f91e1b50c35d: switching from simple_bridge technology to native_rtp
    -- Channel SIP/thufir-00000032 left 'native_rtp' basic-bridge <6ba41abb-76e3-4e2e-9f78-f91e1b50c35d>
    -- Channel SIP/TELNYX-00000033 left 'native_rtp' basic-bridge <6ba41abb-76e3-4e2e-9f78-f91e1b50c35d>
  == Spawn extension (outgoing, 18003569377, 3) exited non-zero on 'SIP/thufir-00000032'
  == Using SIP RTP CoS mark 5
    -- Executing [18003569377@myphones:1] NoOp("SIP/thufir-00000034", "") in new stack
    -- Executing [18003569377@myphones:2] Log("SIP/thufir-00000034", "NOTICE, Dialing out from "thufir" <thufir> to 8003569377 through TELNYX") in new stack
[Jul  3 00:35:17] NOTICE[5499][C-00000025]: Ext. 18003569377:2 @ myphones:  Dialing out from "thufir" <thufir> to 8003569377 through TELNYX
    -- Executing [18003569377@myphones:3] Dial("SIP/thufir-00000034", "SIP/TELNYX/8003569377,60") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/TELNYX/8003569377
    -- SIP/TELNYX-00000035 is ringing
    -- SIP/TELNYX-00000035 is making progress passing it to SIP/thufir-00000034
    -- SIP/TELNYX-00000035 answered SIP/thufir-00000034
    -- Channel SIP/thufir-00000034 joined 'simple_bridge' basic-bridge <5f6d5b07-a688-4a51-bd59-6bcc0985e4c5>
    -- Channel SIP/TELNYX-00000035 joined 'simple_bridge' basic-bridge <5f6d5b07-a688-4a51-bd59-6bcc0985e4c5>
       > Bridge 5f6d5b07-a688-4a51-bd59-6bcc0985e4c5: switching from simple_bridge technology to native_rtp
       > 0x7f25d000adf0 -- Probation passed - setting RTP source address to 192.168.1.5:16396
       > 0x7f25880056b0 -- Probation passed - setting RTP source address to 64.16.240.36:19042
    -- Channel SIP/thufir-00000034 left 'native_rtp' basic-bridge <5f6d5b07-a688-4a51-bd59-6bcc0985e4c5>
    -- Channel SIP/TELNYX-00000035 left 'native_rtp' basic-bridge <5f6d5b07-a688-4a51-bd59-6bcc0985e4c5>
  == Spawn extension (myphones, 18003569377, 3) exited non-zero on 'SIP/thufir-00000034'
mordor*CLI>

Ok, I see how you can use the TOLL variable in extensions.conf now:

root@mordor:/etc/asterisk# 
root@mordor:/etc/asterisk# cat extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no

[globals]
TOLL=SIP/TELNYX
#include extensions.telnyx.myphones.conf
#include extensions.telnyx.outgoing.conf
root@mordor:/etc/asterisk# 
root@mordor:/etc/asterisk# cat extensions.telnyx.myphones.conf 
[myphones]

exten => 1000,1,Dial(SIP/1000)
exten => 1000,n,Hangup()

exten => 1001,1,Dial(SIP/1001)
exten => 1001,n,Hangup()

exten => 201,1,Answer()
exten => 201,n,Playback(tt-monty-knights)
exten => 201,n,Hangup()

exten => 202,1,Answer()
exten => 202,n,Playback(welcome)
exten => 202,n,Playback(demo-echotest)
exten => 202,n,Echo()
exten => 202,n,Playback(demo-echodone)
exten => 202,n,Playback(vm-goodbye)
exten => 202,n,Hangup()



;-----------------------------------------hard phone-----------------------------

exten => 555,1,Playback(hello-world)
exten => 555,n,Playback(echo-test)
exten => 555,n,Echo
exten => 555,n,Playback(demo-echodone)

exten=>4000,1,Playback(tt-monkeys)
exten=>5000,1,Playback(tt-monkeysintro)

exten=>6001,1,Dial(SIP/demo_alice,20)
exten=>6002,1,Dial(SIP/demo_bob,20)
exten=>6003,1,Dial(SIP/thufir,20)
exten=>6004,1,Dial(SIP/hawat,20)




include => outgoing

root@mordor:/etc/asterisk# 
root@mordor:/etc/asterisk# cat extensions.telnyx.outgoing.conf 
[outgoing]
exten =>  _1NXXNXXXXXX,1,NoOp()
;exten =>  _1NXXNXXXXXX,n,Set(CALLFILENAME=${EXTEN:1}.${CDR(uniqueid)})
exten =>  _1NXXNXXXXXX,n,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:1} through ${TOLL})
;exten =>  _1NXXNXXXXXX,n,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:1} through ${TOLL} recorded to ${CALLFILENAME}.wav)
;exten =>  _1NXXNXXXXXX,n,MixMonitor(${CALLFILENAME}.wav,ab)
exten =>  _1NXXNXXXXXX,n,Dial(${TOLL}/${EXTEN:1},60)
exten =>  _1NXXNXXXXXX,n,Playtones(congestion)
;exten =>  _1NXXNXXXXXX,n,StopMixMonitor()
exten =>  _1NXXNXXXXXX,n,Hangup()
root@mordor:/etc/asterisk#