How to apply this patch:HELP!

Hi, I am trying to apply following patch issues.asterisk.org/view.php?id=18192 .
As you can see is writed so I suppose I have to copy and paste in a file “.diff” then apply it. Right? I tried but without succes.
Can you help me?
Thnaks

Hello,
Save it in .diff file(better in root off asterisk src directory),in root of asterisk src directory run

and check if file main/channel.c has been changed.

also you can check this.

forums.digium.com/viewtopic.php?f=4&t=72423

That issue is marked duplicate and the patch it contains was not properly submitted and won’t have been checked for validity. Why not use the patch from the issue that it duplicates, which has been committed to the SVN repository, so will be considered valid?

@ DAVID55
Hi David, I really appreciate your suggestions,every time, but as I said in past posts I am a beginner so I am not so skilled about SVN, etc… This is also why I am writing on Asterisk Forum. I would really happy if you could understand me and suggest me realy how to apply or doing what you say.
Thank you very much

@EG
Thanks Eg for your help. I did what you suggested me but I get no response from command line. it stays there and seems is doing something for a long time. I tried also with this:

[root@freepbx asterisk-1.8.4.4]# patch --ignore-whitespace main/channel.c < patch_fax.patch

but i get this error:

patching file main/channel.c
Hunk #1 FAILED at 3620.
1 out of 1 hunk FAILED – saving rejects to file main/channel.c.rej

Any idea??

For me it’s look like something wrong with this patch , maybe wrong version of src.
Please follow advices from DAVID55 and look at - https://issues.asterisk.org/view.php?id=18185 - it’s the right topic for this problem.

Thanks Eg for your reply. I already checked at issues.asterisk.org/view.php?id=18185 but I don’t understand how to solve the issue. There is not a patch to install. Can you please explain me how to solve this issue?
Thnak you very much to be patient

Ok I suppose I am getting close to solution but some error again. I have walked by google into this site reviewboard.asterisk.org/r/1013/ and I found patch.diff ( bug18171_ 18185_ 18192_ 18211_ 18230.patch ).
I copied it into /usr/src/asterisk/asterisk-1.8.4.4 and tried to apply it by

[root@freepbx asterisk-1.8.4.4]# patch --ignore-whitespace apps/app_macro.c < bug18171_\ 18185_\ 18192_\ 18211_\ 18230.patch

but the result is:

patching file apps/app_macro.c
Hunk #1 FAILED at 542.
1 out of 1 hunk FAILED – saving rejects to file apps/app_macro.c.rej
can’t find file to patch at input line 18
Perhaps you should have used the -p or --strip option?
The text leading up to this was:

|Index: /branches/1.8/include/asterisk/channel.h
|===================================================================
|— /branches/1.8/include/asterisk/channel.h (revision 295221)

+++ /branches/1.8/include/asterisk/channel.h (working copy)

File to patch:

What Am i wrong?

this is the output of “apps/app_macro.c.rej”


*** 542,548 ****
/* If we’re leaving the macro normally, restore original information */
chan->priority = oldpriority;
ast_copy_string(chan->context, oldcontext, sizeof(chan->context));

  •           if (!(ast_check_hangup(chan) & AST_SOFTHANGUP_ASYNCGOTO)) {
                      /* Copy the extension, so long as we're not in softhangup, where we could be given an asyncgoto */
                      const char *offsets;
                      ast_copy_string(chan->exten, oldexten, sizeof(chan->exten));
    

— 542,548 ----
/* If we’re leaving the macro normally, restore original information */
chan->priority = oldpriority;
ast_copy_string(chan->context, oldcontext, sizeof(chan->context));

  •           if (!(ast_check_hangup(chan) & AST_SOFTHANGUP_ASYNCGOTO)) {/* BUGBUG this is stupid here. ast_check_hangup() returns 0|1 and AST_SOFTHANGUP_ASYNCGOTO is 2. */
                      /* Copy the extension, so long as we're not in softhangup, where we could be given an asyncgoto */
                      const char *offsets;
                      ast_copy_string(chan->exten, oldexten, sizeof(chan->exten));
    

What’s wrong???

That patch is already in 1.8.4.4, so no wonder there is a conflict!

Ha, ok, Thanks David. So, Can you explain me why I still have issue with receiving fax? I supposed, reading on google, that issue was releated to this problem. I am currently using asterisk 1.8.4.4 and,as you said, that patch ( that should resolve fax issue as well ) is already present.

I poste you the log of incoming fax call:

freepbx*CLI>
== Using UDPTL TOS bits 184
== Using UDPTL CoS mark 5
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [3950@from-sip-external:1] NoOp(“SIP/172.16.52.7:5061-00000036”, “Received incoming SIP connection from unknown peer to 3950”) in new stack
– Executing [3950@from-sip-external:2] Set(“SIP/172.16.52.7:5061-00000036”, “DID=3950”) in new stack
– Executing [3950@from-sip-external:3] Goto(“SIP/172.16.52.7:5061-00000036”, “s,1”) in new stack
– Goto (from-sip-external,s,1)
– Executing [s@from-sip-external:1] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?checklang:noanonymous”) in new stack
– Goto (from-sip-external,s,2)
– Executing [s@from-sip-external:2] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?setlanguage:from-trunk,3950,1”) in new stack
– Goto (from-trunk,3950,1)
– Executing [3950@from-trunk:1] Set(“SIP/172.16.52.7:5061-00000036”, “__FROM_DID=3950”) in new stack
– Executing [3950@from-trunk:2] Gosub(“SIP/172.16.52.7:5061-00000036”, “app-blacklist-check,s,1”) in new stack
– Executing [s@app-blacklist-check:1] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?blacklisted”) in new stack
– Executing [s@app-blacklist-check:2] Set(“SIP/172.16.52.7:5061-00000036”, “CALLED_BLACKLIST=1”) in new stack
– Executing [s@app-blacklist-check:3] Return(“SIP/172.16.52.7:5061-00000036”, “”) in new stack
– Executing [3950@from-trunk:3] ExecIf(“SIP/172.16.52.7:5061-00000036”, “0 ?Set(CALLERID(name)=+390522375507)”) in new stack
– Executing [3950@from-trunk:4] Set(“SIP/172.16.52.7:5061-00000036”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
– Executing [3950@from-trunk:5] Set(“SIP/172.16.52.7:5061-00000036”, “CALLERPRES()=allowed_not_screened”) in new stack
– Executing [3950@from-trunk:6] Set(“SIP/172.16.52.7:5061-00000036”, “FAX_DEST=from-did-direct^3950^1”) in new stack
– Executing [3950@from-trunk:7] Answer(“SIP/172.16.52.7:5061-00000036”, “”) in new stack
– Executing [3950@from-trunk:8] Wait(“SIP/172.16.52.7:5061-00000036”, “4”) in new stack
== Redirecting ‘SIP/172.16.52.7:5061-00000036’ to fax extension due to CNG detection
== Spawn extension (from-trunk, fax, 1) exited non-zero on ‘SIP/172.16.52.7:5061-00000036’
– Executing [fax@from-trunk:1] Goto(“SIP/172.16.52.7:5061-00000036”, “from-did-direct,3950,1”) in new stack
– Goto (from-did-direct,3950,1)
– Executing [3950@from-did-direct:1] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?ext-local,3950,1”) in new stack
– Executing [3950@from-did-direct:2] Macro(“SIP/172.16.52.7:5061-00000036”, “user-callerid,”) in new stack
– Executing [s@macro-user-callerid:1] Set(“SIP/172.16.52.7:5061-00000036”, “AMPUSER=+390522375507”) in new stack
– Executing [s@macro-user-callerid:2] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?report”) in new stack
– Executing [s@macro-user-callerid:3] ExecIf(“SIP/172.16.52.7:5061-00000036”, “1?Set(REALCALLERIDNUM=+390522375507)”) in new stack
– Executing [s@macro-user-callerid:4] Set(“SIP/172.16.52.7:5061-00000036”, “AMPUSER=”) in new stack
– Executing [s@macro-user-callerid:5] Set(“SIP/172.16.52.7:5061-00000036”, “AMPUSERCIDNAME=”) in new stack
– Executing [s@macro-user-callerid:6] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?report”) in new stack
– Goto (macro-user-callerid,s,13)
– Executing [s@macro-user-callerid:13] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?continue”) in new stack
– Executing [s@macro-user-callerid:14] Set(“SIP/172.16.52.7:5061-00000036”, “__TTL=64”) in new stack
– Executing [s@macro-user-callerid:15] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,26)
– Executing [s@macro-user-callerid:26] Set(“SIP/172.16.52.7:5061-00000036”, “CALLERID(number)=+390522375507”) in new stack
– Executing [s@macro-user-callerid:27] Set(“SIP/172.16.52.7:5061-00000036”, “CALLERID(name)=Fax Alcatel”) in new stack
– Executing [s@macro-user-callerid:28] Set(“SIP/172.16.52.7:5061-00000036”, “CHANNEL(language)=en”) in new stack
– Executing [3950@from-did-direct:3] Set(“SIP/172.16.52.7:5061-00000036”, “__EXTTOCALL=3950”) in new stack
– Executing [3950@from-did-direct:4] Set(“SIP/172.16.52.7:5061-00000036”, “__PICKUPMARK=3950”) in new stack
– Executing [3950@from-did-direct:5] Macro(“SIP/172.16.52.7:5061-00000036”, “blkvm-setifempty,”) in new stack
– Executing [s@macro-blkvm-setifempty:1] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?init”) in new stack
– Goto (macro-blkvm-setifempty,s,4)
– Executing [s@macro-blkvm-setifempty:4] Set(“SIP/172.16.52.7:5061-00000036”, “__BLKVM_CHANNEL=SIP/172.16.52.7:5061-00000036”) in new stack
– Executing [s@macro-blkvm-setifempty:5] Set(“SIP/172.16.52.7:5061-00000036”, “SHARED(BLKVM,SIP/172.16.52.7:5061-00000036)=TRUE”) in new stack
– Executing [s@macro-blkvm-setifempty:6] Set(“SIP/172.16.52.7:5061-00000036”, “GOSUB_RETVAL=TRUE”) in new stack
– Executing [s@macro-blkvm-setifempty:7] MacroExit(“SIP/172.16.52.7:5061-00000036”, “”) in new stack
– Executing [3950@from-did-direct:6] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?skipov”) in new stack
– Goto (from-did-direct,3950,9)
– Executing [3950@from-did-direct:9] Set(“SIP/172.16.52.7:5061-00000036”, “RRNODEST=”) in new stack
– Executing [3950@from-did-direct:10] Set(“SIP/172.16.52.7:5061-00000036”, “__NODEST=3950”) in new stack
– Executing [3950@from-did-direct:11] GosubIf(“SIP/172.16.52.7:5061-00000036”, “0?sub-fmsetcid,s,1”) in new stack
– Executing [3950@from-did-direct:12] Set(“SIP/172.16.52.7:5061-00000036”, “RecordMethod=Group”) in new stack
– Executing [3950@from-did-direct:13] Macro(“SIP/172.16.52.7:5061-00000036”, “record-enable,3950-3950,Group”) in new stack
– Executing [s@macro-record-enable:1] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?check”) in new stack
– Goto (macro-record-enable,s,4)
– Executing [s@macro-record-enable:4] ExecIf(“SIP/172.16.52.7:5061-00000036”, “0?MacroExit()”) in new stack
– Executing [s@macro-record-enable:5] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?Group:OUT”) in new stack
– Goto (macro-record-enable,s,6)
– Executing [s@macro-record-enable:6] Set(“SIP/172.16.52.7:5061-00000036”, “LOOPCNT=2”) in new stack
– Executing [s@macro-record-enable:7] Set(“SIP/172.16.52.7:5061-00000036”, “ITER=1”) in new stack
– Executing [s@macro-record-enable:8] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?continue”) in new stack
– Goto (macro-record-enable,s,12)
– Executing [s@macro-record-enable:12] Set(“SIP/172.16.52.7:5061-00000036”, “ITER=2”) in new stack
– Executing [s@macro-record-enable:13] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?begin”) in new stack
– Goto (macro-record-enable,s,8)
– Executing [s@macro-record-enable:8] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?continue”) in new stack
– Goto (macro-record-enable,s,12)
– Executing [s@macro-record-enable:12] Set(“SIP/172.16.52.7:5061-00000036”, “ITER=3”) in new stack
– Executing [s@macro-record-enable:13] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?begin”) in new stack
– Executing [s@macro-record-enable:14] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?IN”) in new stack
– Executing [s@macro-record-enable:15] ExecIf(“SIP/172.16.52.7:5061-00000036”, “1?MacroExit()”) in new stack
– Executing [3950@from-did-direct:14] Set(“SIP/172.16.52.7:5061-00000036”, “RingGroupMethod=ringallv2”) in new stack
– Executing [3950@from-did-direct:15] Set(“SIP/172.16.52.7:5061-00000036”, “_FMGRP=3950”) in new stack
– Executing [3950@from-did-direct:16] GotoIf(“SIP/172.16.52.7:5061-00000036”, “0?doconfirm”) in new stack
– Executing [3950@from-did-direct:17] Macro(“SIP/172.16.52.7:5061-00000036”, “dial,24,tr,3950”) in new stack
– Executing [s@macro-dial:1] GotoIf(“SIP/172.16.52.7:5061-00000036”, “1?dial”) in new stack
– Goto (macro-dial,s,3)
– Executing [s@macro-dial:3] AGI(“SIP/172.16.52.7:5061-00000036”, “dialparties.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi
dialparties.agi: Starting New Dialparties.agi
dialparties.agi: Caller ID name is ‘Fax Alcatel’ number is ‘+390522375507’
> dialparties.agi: USE_CONFIRMATION: ‘FALSE’
> dialparties.agi: RINGGROUP_INDEX: ''
dialparties.agi: Methodology of ring is ‘ringallv2’
– dialparties.agi: Added extension 3950 to extension map
> dialparties.agi: got fmgrp_prering: 4, fmgrp_grptime: 20
> dialparties.agi: fmgrp_totalprering: 24
> dialparties.agi: found extension in pre-ring and array
> dialparties.agi: ringallv2 ring times: REALPRERING: 24, PRERING: 4
> dialparties.agi: Extension 3950 has call screening off
– dialparties.agi: Extension 3950 cf is disabled
– dialparties.agi: Extension 3950 do not disturb is disabled
> dialparties.agi: extnum 3950 has: cw: 1; hascfb: 0 [] hascfu: 0 []
– dialparties.agi: dbset CALLTRACE/3950 to +390522375507
– dialparties.agi: Filtered ARG3: 3950
> dialparties.agi: NODEST: 3950 adding M(auto-blkvm) to dialopts: trM(auto-blkvm)
> dialparties.agi: NODEST: 3950 blkvm enabled macro already in dialopts: trM(auto-blkvm)
– <SIP/172.16.52.7:5061-00000036>AGI Script dialparties.agi completed, returning 0
– Executing [s@macro-dial:7] Dial(“SIP/172.16.52.7:5061-00000036”, “SIP/3950,24,trM(auto-blkvm)”) in new stack
== Using UDPTL TOS bits 184
== Using UDPTL CoS mark 5
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Called 3950
– SIP/3950-00000037 is ringing
– Nobody picked up in 24000 ms

As you can see “Redirecting ‘SIP/172.16.52.7:5061-00000036’ to fax extension due to CNG detection” fax call is detected but it does not go to fax but istead to phone 3950.
Any idea?

What does:

[from-trunk]
exten => fax,1,…

contain?

I can’t really find this part on extension config files.
If I do:

freepbx*CLI> dialplan show from-trunk
[ Context ‘from-trunk’ created by ‘pbx_config’ ]
Include => ‘from-pstn’ [pbx_config]

-= 0 extensions (0 priorities) in 1 context. =-

Nothing more.
If i do

freepbx*CLI> dialplan show from-pstn
[ Context ‘from-pstn’ created by ‘pbx_config’ ]
Include => ‘from-pstn-custom’ [pbx_config]
Include => ‘ext-did’ [pbx_config]
Include => ‘ext-did-post-custom’ [pbx_config]
Include => ‘from-did-direct’ [pbx_config]
Include => ‘ext-did-catchall’ [pbx_config]

-= 0 extensions (0 priorities) in 1 context. =-

Could be releated to this my own issue?
As you understood I configured by FreePBX GUI; could be some bugs.
What do you suggest me?
As I understood, fax call goes to a non present extension, right ???

Ok, a deeper investigation lead me on it:

freepbx*CLI> dialplan show ext-did-0002
[ Context ‘ext-did-0002’ created by ‘pbx_config’ ]
‘3900’ => 1. Set(__FROM_DID=${EXTEN}) [pbx_config]
2. Gosub(app-blacklist-check,s,1) [pbx_config]
3. ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)})) [pbx_config]
4. Set(__CALLINGPRES_SV=${CALLERPRES()}) [pbx_config]
5. Set(CALLERPRES()=allowed_not_screened) [pbx_config]
[dest-ext] 6. Goto(custom-fax-iaxmodem,s,1) [pbx_config]
‘3950’ => 1. Set(__FROM_DID=${EXTEN}) [pbx_config]
2. Gosub(app-blacklist-check,s,1) [pbx_config]
3. ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)})) [pbx_config]
4. Set(__CALLINGPRES_SV=${CALLERPRES()}) [pbx_config]
5. Set(CALLERPRES()=allowed_not_screened) [pbx_config]
6. Set(FAX_DEST=from-did-direct^3950^1) [pbx_config]
7. Answer() [pbx_config]
8. Wait(4) [pbx_config]
[dest-ext] 9. Goto(from-did-direct,3950,1) [pbx_config]
‘3999’ => 1. Set(__FROM_DID=${EXTEN}) [pbx_config]
2. Gosub(app-blacklist-check,s,1) [pbx_config]
3. ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)})) [pbx_config]
4. Set(__CALLINGPRES_SV=${CALLERPRES()}) [pbx_config]
5. Set(CALLERPRES()=allowed_not_screened) [pbx_config]
6. Set(exchdiversion=${SIP_HEADER(To)}) [pbx_config]
7. Set(exchdiversion=${CUT(exchdiversion,@,1)}) [pbx_config]
8. Set(exchdiversion=${CUT(exchdiversion,:,2)}) [pbx_config]
9. Set(exchdiversion=${IF($["${exchdiversion}"=“3999”]?${CALLERID(number)}:${exchdiversion})}) [pbx_config]
[dest-ext] 10. Goto(macro-bridge_oxe_vmexchange2010,s,1) [pbx_config]
‘fax’ => 1. Goto(${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}) [pbx_config]
Include => ‘ext-did-0002-custom’ [pbx_config]

-= 4 extensions (26 priorities) in 1 context. =-

I can’t find Fax@from-trunk

:frowning:

What is FAX_DEST set to?

I suppose is set

exten => 3950,n,Set(FAX_DEST=from-did-direct^3950^1)

It’s not so clear, in my point of view. I post you all Extension.conf and extension_additional.conf

extension.conf

[quote];--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make ;
; custom modifications, details at: freepbx.org/configuration_files ;
;--------------------------------------------------------------------------------;
;
; This file is part of FreePBX.
;
; FreePBX is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 2 of the License, or
; (at your option) any later version.
;
; FreePBX is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with FreePBX. If not, see http://www.gnu.org/licenses/.
;
; Copyright © 2004 Coalescent Systems Inc (Canada)
; Copyright © 2006 Why Pay More 4 Less Pty Ltd (Australia)
; Copyright © 2007 Astrogen LLC (USA)
;--------------------------------------------------------------------------------;

;*******************************************************************************
; AUTO-GENERATED AND CUSOTM USER DIALPLAN INCLUDED HERE *
;*******************************************************************************
;

;--------------------------------------------------------------------------------;
; Customizations to this dialplan should be made in extensions_custom.conf
; See extensions_custom.conf.sample for an example.
;
; If you need to use [macro-dialout-trunk-predial-hook], [ext-did-custom], or
; [from-internal-custom] for example, place these in this file or they will get overwritten.
;
; WARNING ABOUT: #include extensions_override_freepbx.conf
;
; This include file is put first to allow the auto-generated dialplan in FreePBX
; to be overwritten if necessary. Overriding auto-generated dialplan should be done
; with extreme caution. In almost all cases any custom dialplan SHOULD be put in
; extensions_custom.conf which will not hurt a FreePBX generated dialplan. In some
; very rare and custom situations users may have a need to override what FreePBX
; automatically generates. If so anything in this file will do that. If you come up
; with situations where you need to modify the existing dialplan or macros, put it
; here.
;
#include extensions_override_freepbx.conf
#include extensions_additional.conf
#include extensions_custom.conf
;--------------------------------------------------------------------------------;

;*******************************************************************************
; DIALPLAN OPEN TO THE PUBLIC, USING INBOUND DIDS AND SIMILAR *
;*******************************************************************************
;

;-------------------------------------------------------------------------------
; from-digital:
;
; Context to set for PRI’s and equivalent
;
[from-digital]
include => from-pstn
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-analog:
;
; Context to set for analog DAHDi cards and equivalent
;
[from-analog]
include => from-dahdi
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-trunk:
;
; Context is really just an aliax of from-pstn
;
[from-trunk]
include => from-pstn
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-pstn:
;
; Entry context for calls from the outside world to hit FreePBX
[from-pstn]
include => from-pstn-custom ; create this context in extensions_custom.conf to include customizations
include => ext-did
include => ext-did-post-custom
include => from-did-direct
include => ext-did-catchall ; THIS MUST COME AFTER ext-did
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-pstn-e164-us:
;
; The context is designed for providers who send calls in e164 format and is
; biased towards NPA calls, callerid and dialing rules. It will do the following:
;
; DIDs in an NPA e164 format of +1NXXNXXXXXX will be converted to 10 digit DIDs
;
; DIDs in any other format will be delivered as they are, including e164 non NPA
; DIDs which means they will need the full format including the + in the inbound
; route.
;
; CallerID(number) presented in e164 NPA format will be trimmed to a 10 digit CID
;
; CallerID(number) presented in e164 non-NPA (country code other than 1) will be
; reformated from: + to 011
;
[from-pstn-e164-us]
exten => +1NXXNXXXXXX/+1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => _+1NXXNXXXXXX/_NXXNXXXXXX,2,Goto(from-pstn,${EXTEN:2},1)
exten => +1NXXNXXXXXX/+X.,1,Set(CALLERID(number)=011${CALLERID(number):1})
exten => _+1NXXNXXXXXX/_011X.,n,Goto(from-pstn,${EXTEN:2},1)
exten => _+1NXXNXXXXXX,1,Goto(from-pstn,${EXTEN:2},1)
exten => [0-9+]./+1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => _[0-9+]./_NXXNXXXXXX,n,Goto(from-pstn,${EXTEN},1)
exten => [0-9+]./+X.,1,Set(CALLERID(number)=011${CALLERID(number):1})
exten => _[0-9+]./_011X.,n,Goto(from-pstn,${EXTEN},1)
exten => [0-9+].,1,Goto(from-pstn,${EXTEN},1)
exten => s/
+1NXXNXXXXXX,1,Set(CALLERID(number)=${CALLERID(number):2})
exten => s/NXXNXXXXXX,n,Goto(from-pstn,${EXTEN},1)
exten => s/
+X.,1,Set(CALLERID(number)=011${CALLERID(number):1})
exten => s/_011X.,n,Goto(from-pstn,${EXTEN},1)
exten => s,1,Goto(from-pstn,${EXTEN},1)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-pstn-to-did:
;
; The context is designed for providers who send the DID in the TO: SIP header
; only. The format of this header is:
;
; To: sip:2125551212@172.31.74.25
;
; So the DID must be extracted between the sip: and the @, which this does
;
[from-pstn-toheader]
exten => _.,1,Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-sip-external
;
; This context is the default SIP context unless otherwise changed in the SIP
; Settings module or other sip configuration locations. This context is hit by
; either anonymous SIP calls or mis-configured SIP trunks when the incoming call
; can not be matched with a SIP section.
;
[from-sip-external]
exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
exten => _.,n,Goto(s,1)
exten => s,1,GotoIf($["${ALLOW_SIP_ANON}"=“yes”]?checklang:noanonymous)
exten => s,n(checklang),GotoIf($["${SIPLANG}"!=""]?setlanguage:from-trunk,${DID},1)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
exten => s,n,Goto(from-trunk,${DID},1)
exten => s,n(noanonymous),Set(TIMEOUT(absolute)=15)
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup
;-------------------------------------------------------------------------------

;*******************************************************************************
; INTERNAL DIALPLAN, NOT OPEN TO THE PUBLIC WORLD *
;*******************************************************************************
;

;-------------------------------------------------------------------------------
; from-internal:
;
; Internal dialplan that most internal phones have access to
;
[from-internal]
include => from-internal-noxfer
include => from-internal-xfer
include => bad-number ; auto-generated
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-internal-noxfer:
;
; Place to put internal dialplan that should not be accessible during a blind
; transfer, this context will not be visible during such.
;
[from-internal-noxfer]
include => from-internal-noxfer-custom
include => from-internal-noxfer-additional ; auto-generated
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; from-internal-xfer:
;
; Place to put most internal dialplan, will be visible during normal calls and
; blind transfers.
;
[from-internal-xfer]
include => from-internal-custom
include => from-internal-additional ; auto-generated
exten => s,1,Macro(hangupcall)
exten => h,1,Macro(hangupcall)
;-------------------------------------------------------------------------------

;*******************************************************************************
; INTERNAL MACROS & SPECIAL CONTEXTS *
;*******************************************************************************
;

;-------------------------------------------------------------------------------
; from-did-direct:
;
; forces ext-findmefollow to take precedence over ext-local. Also exposed to
; the public side to allow an extension number to be used as an external DID
; without requiring inbound routes to be created, common in many PRI installations
; where the last 4 digits are used as the extnension and DIDs are delivered in
; 4 digit formats.
;
[from-did-direct]
include => ext-findmefollow
include => ext-local
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-dial:
;
; Rings one or more extensions. Handles things like call forwarding and DND
; We don’t call dial directly for anything internal anymore.
; ARGS: $TIMER, $OPTIONS, $EXT1, $EXT2, $EXT3, …
; Use a Macro call such as the following:
;
; Macro(dial,$DIAL_TIMER,$DIAL_OPTIONS,$EXT1,$EXT2,$EXT3,…)
;
[macro-dial]
exten => s,1,GotoIf($["${MOHCLASS}" = “”]?dial)
exten => s,n,SetMusicOnHold(${MOHCLASS})
exten => s,n(dial),AGI(dialparties.agi)
exten => s,n,NoOp(Returned from dialparties with no extensions to call and DIALSTATUS: ${DIALSTATUS})

exten => s,n+2(normdial),Dial(${ds}) ; dialparties will set the priority to 10 if $ds is not null
exten => s,n,Set(DIALSTATUS=${IF($["${DIALSTATUS_CW}"!="" ]?${DIALSTATUS_CW}:${DIALSTATUS})})
exten => s,n,GosubIf($["${SCREEN}" != “” | “${DIALSTATUS}” = “ANSWER”]?${DIALSTATUS},1)

exten => s,20(huntdial),NoOp(Returned from dialparties with hunt groups to dial )
exten => s,n,Set(HuntLoop=0)
exten => s,n(a22),GotoIf($[${HuntMembers} >= 1]?a30) ; if this is from rg-group, don’t strip prefix
exten => s,n,NoOp(Returning there are no members left in the hunt group to ring)

; dialparties.agi has setup the dialstring for each hunt member in a variable labeled HuntMember0, HuntMember1 etc for each iteration
; and The total number in HuntMembers. So for each iteration, we will update the CALLTRACE Data.
;
exten => s,n+2(a30),Set(HuntMember=HuntMember${HuntLoop})
exten => s,n,GotoIf($[$["${CALLTRACE_HUNT}" != “” ] & $[$["${RingGroupMethod}" = “hunt” ] | $["${RingGroupMethod}" = “firstavailable”] | $["${RingGroupMethod}" = “firstnotonphone”]]]?a32:a35)

exten => s,n(a32),Set(CT_EXTEN=${CUT(FILTERED_DIAL,$[${HuntLoop} + 1])})
exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
exten => s,n,Goto(s,a42)

;Set Call Trace for each hunt member we are going to call “Memory groups have multiple members to set CALL TRACE For” hence the loop
;
exten => s,n(a35),GotoIf($[$["${CALLTRACE_HUNT}" != “” ] & $["${RingGroupMethod}" = “memoryhunt” ]]?a36:a50)
exten => s,n(a36),Set(CTLoop=0)
exten => s,n(a37),GotoIf($[${CTLoop} > ${HuntLoop}]?a42) ; if this is from rg-group, don’t strip prefix
exten => s,n,Set(CT_EXTEN=${CUT(FILTERED_DIAL,$[${CTLoop} + 1])})
exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
exten => s,n,Set(CTLoop=$[1 + ${CTLoop}])
exten => s,n,Goto(s,a37)

exten => s,n(a42),Dial(${${HuntMember}}${ds})
exten => s,n,GotoIf($["${DIALSTATUS}" = “ANSWER”]?ANSWER,1)
exten => s,n,Set(HuntLoop=$[1 + ${HuntLoop}])
exten => s,n,GotoIf($[$[$[“foo${RingGroupMethod}” != “foofirstavailable”] & $[“foo${RingGroupMethod}” != “foofirstnotonphone”]] | $[“foo${DialStatus}” = “fooBUSY”]]?a46)
exten => s,n,Set(HuntMembers=0)
exten => s,n(a46),Set(HuntMembers=$[${HuntMembers} - 1])
exten => s,n,Goto(s,a22)

exten => s,n(a50),DBdel(CALLTRACE/${CT_EXTEN})
exten => s,n,Goto(s,a42)

; For call screening
exten => NOANSWER,1,Macro(vm,${SCREEN_EXTEN},BUSY,${IVR_RETVM})
exten => NOANSWER,n,GotoIf($["${IVR_RETVM}" != “RETURN” | “${IVR_CONTEXT}” = “”]?bye)
exten => NOANSWER,n,Return
exten => NOANSWER,n(bye),Macro(hangupcall)
exten => TORTURE,1,Goto(app-blackhole,musiconhold,1)
exten => TORTURE,n,Macro(hangupcall)
exten => DONTCALL,1,Answer
exten => DONTCALL,n,Wait(1)
exten => DONTCALL,n,Zapateller()
exten => DONTCALL,n,Playback(ss-noservice)
exten => DONTCALL,n,Macro(hangupcall)
exten => ANSWER,1,Noop(Call successfully answered - Hanging up now)
exten => ANSWER,n,Macro(hangupcall,)

; make sure hungup calls go here so that proper cleanup occurs from call confirmed calls and the like
;
exten => h,1,Macro(hangupcall)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-get-vmcontext:
;
; returns the user’s voicemail context
;
[macro-get-vmcontext]
exten => s,1,Set(VMCONTEXT=${DB(AMPUSER/${ARG1}/voicemail)})
exten => s,2,GotoIf($[“foo${VMCONTEXT}” = “foo”]?200:300)
exten => s,200,Set(VMCONTEXT=default)
exten => s,300,NoOp()
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-outisbusy:
;
; called if all trunks are busy. This macro is overwridden by the
; Outbound Route Messages module if installed and configured to provide
; better messages or choices of tones.
;
[macro-outisbusy]
exten => s,1,Progress
exten => s,n,Playback(all-circuits-busy-now,noanswer)
exten => s,n,Playback(pls-try-call-later,noanswer)
exten => s,n,Macro(hangupcall)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-dialout-trunk-predial-hook:
;
; this macro intentionally left blank so it may be safely overwritten for any custom
; requirements that an installation may have.
;
; the macro is called by macro-dialout-trunk just prior to making a Dial() attempt
; to a trunk.
;
; MACRO RETURN CODE: ${PREDIAL_HOOK_RET}
; if set to “BYPASS” then this trunk will be skipped
;
;
[macro-dialout-trunk-predial-hook]
exten => s,1,MacroExit()
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-user-logon:
;
; Used to log a user onto an adhoc device. Most of the work is done by
; user_login_out.agi AGI script
;
[macro-user-logon]
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,Answer()
exten => s,n,Wait(1)
exten => s,n,GotoIf($["${DEVICETYPE}" = “fixed”]?s-FIXED,1)
; get user’s extension
;
exten => s,n,Set(AMPUSER=${ARG1})
exten => s,n,GotoIf($["${AMPUSER}" != “”]?gotpass)
exten => s,n(playagain),Read(AMPUSER,please-enter-your-extension-then-press-pound,4)
; get user’s password and authenticate
;
exten => s,n,GotoIf($["${AMPUSER}" = “”]?s-MAXATTEMPTS,1)
exten => s,n(gotpass),GotoIf($["${DB_EXISTS(AMPUSER/${AMPUSER}/password)}" = “0”]?s-NOUSER,1)
exten => s,n,Set(AMPUSERPASS=${DB_RESULT})
exten => s,n,GotoIf($[${LEN(${AMPUSERPASS})} = 0]?s-NOPASSWORD,1)
; do not continue if the user has already logged onto this device
;
exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
exten => s,n,GotoIf($["${DEVICEUSER}" = “${AMPUSER}”]?s-ALREADYLOGGEDON,1)
exten => s,n,Authenticate(${AMPUSERPASS})
exten => s,n,AGI(user_login_out.agi,login,${CALLERID(number)},${AMPUSER})
exten => s,n,Playback(agent-loginok)

exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into)
exten => s-FIXED,n,Playback(ha/phone)
exten => s-FIXED,n,SayDigits(${CALLERID(number)})
exten => s-FIXED,n,Playback(is-curntly-unavail&vm-goodbye)
exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into

exten => s-ALREADYLOGGEDON,1,NoOp(This device has already been logged into by this user)
exten => s-ALREADYLOGGEDON,n,Playback(vm-goodbye)
exten => s-ALREADYLOGGEDON,n,Hangup ;TODO should play msg indicated device is already logged into

exten => s-NOPASSWORD,1,NoOp(This extension does not exist or no password is set)
exten => s-NOPASSWORD,n,Playback(pbx-invalid)
exten => s-NOPASSWORD,n,Goto(s,playagain)

exten => s-MAXATTEMPTS,1,NoOp(Too many login attempts)
exten => s-MAXATTEMPTS,n,Playback(vm-goodbye)
exten => s-MAXATTEMPTS,n,Hangup

exten => s-NOUSER,1,NoOp(Invalid extension ${AMPUSER} entered)
exten => s-NOUSER,n,Playback(pbx-invalid)
exten => s-NOUSER,n,Goto(s,playagain)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-user-logoff:
;
; Used to log a user off of an adhoc device. Most of the work is done by
; user_login_out.agi AGI script
;
[macro-user-logoff]
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,GotoIf($["${DEVICETYPE}" = “fixed”]?s-FIXED,1)
exten => s,n,AGI(user_login_out.agi,logout,${CALLERID(number)})
exten => s,n(done),Playback(agent-loggedoff)

exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of)
exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye)
exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-privacy-mgr:
;
; Privacy Manager Macro makes sure that any calls that don’t pass the privacy manager are presented
; with congestion since there have been observed cases of the call continuing if not stopped with a
; congestion, and this provides a slightly more friendly ‘sorry’ message in case the user is
; legitimately trying to be cooperative.
;
; Note: the following options are configurable in privacy.conf:
;
; maxretries = 3 ; default value, number of retries before failing
; minlength = 10 ; default value, number of digits to be accepted as valid CID
;
[macro-privacy-mgr]
exten => s,1,Set(KEEPCID=${CALLERID(num)})
exten => s,n,GotoIf($[“foo${CALLERID(num):0:1}”=“foo+”]?CIDTEST2:CIDTEST1)
exten => s,n(CIDTEST1),Set(TESTCID=${MATH(1+${CALLERID(num)})})
exten => s,n,Goto(TESTRESULT)
exten => s,n(CIDTEST2),Set(TESTCID=${MATH(1+${CALLERID(num):1})})
exten => s,n(TESTRESULT),GotoIf($[“foo${TESTCID}”=“foo”]?CLEARCID:PRIVMGR)
exten => s,n(CLEARCID),Set(CALLERID(num)=)
exten => s,n(PRIVMGR),PrivacyManager(${ARG1},${ARG2})
exten => s,n,GotoIf($["${PRIVACYMGRSTATUS}"=“FAILED”]?fail)
exten => s,n,GosubIf($["${CALLED_BLACKLIST}" = “1”]?app-blacklist-check,s,1)
exten => s,n,SetCallerPres(allowed_passed_screen); stop gap until app_privacy.c clears unavailable bit
exten => s,PRIVMGR+101(fail),Noop(STATUS: ${PRIVACYMGRSTATUS} CID: ${CALLERID(num)} ${CALLERID(name)} CALLPRES: ${CALLLINGPRES})
exten => s,n,Playback(sorry-youre-having-problems)
exten => s,n,Playback(goodbye)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,Hangup
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; default
;
; FreePBX does not use the default context. This context is used by asterisk when
; it has no other information provided and needs to deliver a call. Hitting this means
; there has been some sort of configuration error, or a potential bug somehwere.
; This context can be reached from either internal or external sources.
;
[default]
include => ext-local
exten => s,1,Playback(vm-goodbye)
exten => s,n,Noop(ERROR: FreePBX Does not use the [default] context, confguration error)
exten => s,n,Macro(hangupcall)
;-------------------------------------------------------------------------------

;*******************************************************************************
; DEPRECATED DIALPLAN - THESE WILL BE REMOVED, NOT USED BY FREEPBX *
;*******************************************************************************
;

;-------------------------------------------------------------------------------
; macro-fixcid: [DEPRECATED]
;
; For some reason, if I don’t run setCIDname, CALLERID(name) will be blank in my AGI
;
[macro-fixcid]
exten => s,1,Set(CALLERID(name)=${CALLERID(name)})
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-rg-group: [DEPRECATED]
;
; Ring groups of phones
; ARGS: comma separated extension list
; 1 - Ring Group Strategy
; 2 - ringtimer
; 3 - prefix
; 4 - extension list
;
[macro-rg-group]
exten => s,1,Macro(user-callerid,SKIPTTL) ; already called from ringgroup
exten => s,2,GotoIf($["${CALLERID(name):0:${LEN(${RGPREFIX})}}" != “${RGPREFIX}”]?4:3) ; check for old prefix
exten => s,3,Set(CALLERID(name)=${CALLERID(name):${LEN(${RGPREFIX})}}) ; strip off old prefix
exten => s,4,Set(RGPREFIX=${ARG3}) ; set new prefix
exten => s,5,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)}) ; add prefix to callerid name
exten => s,6,Set(RecordMethod=Group) ; set new prefix
exten => s,7,Macro(record-enable,${MACRO_EXTEN},${RecordMethod})
exten => s,8,Set(RingGroupMethod=${ARG1}) ;
exten => s,9,Macro(dial,${ARG2},${DIAL_OPTIONS},${ARG4})
exten => s,10,Set(RingGroupMethod=’’) ;
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-dialout: [DEPRECATED]
;
; dialout and strip the prefix
;
[macro-dialout]
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,2,GotoIf($["${ECID${CALLERID(number)}}" = “”]?5) ;check for CID override for exten
exten => s,3,Set(CALLERID(all)=${ECID${CALLERID(number)}})
exten => s,4,Goto(7)
exten => s,5,GotoIf($["${OUTCID_${ARG1}}" = “”]?7) ;check for CID override for trunk
exten => s,6,Set(CALLERID(all)=${OUTCID_${ARG1}})
exten => s,7,Set(length=${LEN(${DIAL_OUT_${ARG1}})})
exten => s,8,Dial(${OUT_${ARG1}}/${ARG2:${length}})
exten => s,9,Playtones(congestion)
exten => s,10,Congestion(5)
exten => s,109,Macro(outisbusy)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-dialout-default: [DEPRECATED]
;
; dialout using default OUT trunk - no prefix
;
[macro-dialout-default]
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,3,Macro(outbound-callerid,${ARG1})
exten => s,4,Dial(${OUT}/${ARG1})
exten => s,5,Playtones(congestion)
exten => s,6,Congestion(5)
exten => s,105,Macro(outisbusy)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-sayXXXX: [DEPRECATED]
;
; Text-To-Speech related macros
; These all follow common actions. First try to playback a file “tts/custom-md5”
; where “md5” is the md5() of whatever is going to be played. If that doesn’t exist,
; try to playback using macro-tts-sayXXXXX (where XXXXX is text/digits/etc, same as
; the macro below). If that macro exits with MACRO_OFFSET=100, then it’s done,
; otherwise, fallback to the default asterisk method.
;

;-------------------------------------------------------------------------------
; macro-saytext: [DEPRECATED]
;
; say text is purely for text-to-speech, there is no fallback
;
[macro-saytext]
exten => s,1,Noop(Trying custom SayText playback for “${ARG1}”)
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"=“SUCCESS”]?done)
; call tts-saytext. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-saytext,${ARG1},${ARG2},${ARG3})
exten => s,n,Noop(No text-to-speech handler for SayText, cannot say “${ARG1}”)
exten => s,n,Goto(done)
exten => s,tts+101,Noop(tts handled saytext)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-sayname: [DEPRECATED]
;
; say name is for saying names typically, but fallsback to using SayAlpha
; (saying the word letter-by-letter)
;
[macro-sayname]
exten => s,1,Noop(Trying custom SayName playback for “${ARG1}”)
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"=“SUCCESS”]?done)
; call tts-sayalpha. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-sayalpha,${ARG1},${ARG2},${ARG3})
exten => s,n,SayAlpha(${ARG1})
exten => s,n,Goto(done)
exten => s,tts+101,Noop(tts handled sayname)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-saynumber: [DEPRECATED]
;
; Say number is for saying numbers (eg “one thousand forty six”)
;
[macro-saynumber]
exten => s,1,Noop(Trying custom SayNumber playback for “${ARG1}”)
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"=“SUCCESS”]?done)
; call tts-saynumber. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-saynumber,${ARG1},${ARG2},${ARG3})
exten => s,n,SayNumber(${ARG1})
exten => s,n,Goto(done)
exten => s,tts+101,Noop(tts handled saynumber)
;-------------------------------------------------------------------------------

;-------------------------------------------------------------------------------
; macro-saydigits: [DEPRECATED]
;
; Say digits is for saying digits one-by-one (eg, “one zero four six”)
;
[macro-saydigits]
exten => s,1,Noop(Trying custom SayDigits playback for “${ARG1}”)
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"=“SUCCESS”]?done)
; call tts-saydigits. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-saydigits,${ARG1},${ARG2},${ARG3})
exten => s,n,SayDigits(${ARG1})
exten => s,n,Goto(done)
;------------------------------------------------------------------------------- [/quote]

and this is extension_additional.conf

[quote];--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make ;
; custom modifications, details at: freepbx.org/configuration_files ;
;--------------------------------------------------------------------------------;
;

[globals]
CAMPONTOGGLE = *84
INTERCOMCODE = *80
CALLFILENAME = ""
DIAL_OPTIONS = tr
TRUNK_OPTIONS =
DIAL_OUT = 9
FAX =
FAX_RX = system
FAX_RX_EMAIL = noreply@mydomain.tld
FAX_RX_FROM = noreply@mydomain.tld
INCOMING = group-all
NULL = ""
OPERATOR =
OPERATOR_XTN =
PARKNOTIFY = SIP/200
RECORDEXTEN = ""
RINGTIMER = 15
DIRECTORY = both
AFTER_INCOMING =
IN_OVERRIDE = forcereghours
REGTIME = 7:55-17:05
REGDAYS = mon-fri
DIRECTORY_OPTS =
DIALOUTIDS = 1
RECORDING_STATE = ENABLED
VM_PREFIX = *
VM_OPTS =
VM_GAIN =
VM_DDTYPE = u
TIMEFORMAT = kM
TONEZONE = it
ALLOW_SIP_ANON = yes
VMX_OPTS_TIMEOUT =
VMX_OPTS_LOOP =
VMX_OPTS_DOVM =
VMX_TIMEOUT = 2
VMX_REPEAT = 1
VMX_LOOPS = 1
TRANSFER_CONTEXT = from-internal-xfer
MIXMON_FORMAT = wav
ASTETCDIR = /etc/asterisk
ASTMODDIR = /usr/lib/asterisk/modules
ASTVARLIBDIR = /var/lib/asterisk
ASTAGIDIR = /var/lib/asterisk/agi-bin
ASTSPOOLDIR = /var/spool/asterisk
ASTRUNDIR = /var/run/asterisk
ASTLOGDIR = /var/log/asterisk
CWINUSEBUSY = true
AMPMGRUSER = admin
AMPMGRPASS = fGdkjoq8SwHp
AMPDBENGINE = mysql
AMPDBHOST = localhost
AMPDBNAME = asterisk
AMPDBUSER = freepbxuser
AMPDBPASS = wRp7GLIeEqmc
VMX_CONTEXT = from-internal
VMX_PRI = 1
VMX_TIMEDEST_CONTEXT =
VMX_TIMEDEST_EXT = dovm
VMX_TIMEDEST_PRI = 1
VMX_LOOPDEST_CONTEXT =
VMX_LOOPDEST_EXT = dovm
VMX_LOOPDEST_PRI = 1
MIXMON_DIR =
MIXMON_POST =
ASTVERSION = 1.8.4.4
ASTCHANDAHDI = 1
OUT_1 = SIP/Exchange
OUTCID_1 =
OUTMAXCHANS_1 =
OUTFAIL_1 =
OUTPREFIX_1 =
OUTDISABLE_1 = off
OUTKEEPCID_1 = off
FORCEDOUTCID_1 =
PREFIX_TRUNK_1 =
OUT_2 = SIP/TG_SIP_LW
OUTCID_2 =
OUTMAXCHANS_2 =
OUTFAIL_2 =
OUTPREFIX_2 =
OUTDISABLE_2 = off
OUTKEEPCID_2 = off
FORCEDOUTCID_2 =
PREFIX_TRUNK_2 =
OUT_3 = SIP/TG_SIP_LYNC
OUTCID_3 =
OUTMAXCHANS_3 =
OUTFAIL_3 =
OUTPREFIX_3 =
OUTDISABLE_3 = off
OUTKEEPCID_3 = off
FORCEDOUTCID_3 =
PREFIX_TRUNK_3 =
SIPLANG =
#include globals_custom.conf

;end of [globals]

[app-recordings]
include => app-recordings-custom
exten => *77,1,Macro(user-callerid,)
exten => *77,n,Wait(2)
exten => *77,n,Macro(systemrecording,dorecord)
exten => *99,1,Macro(user-callerid,)
exten => *99,n,Wait(2)
exten => *99,n,Macro(systemrecording,docheck)

; end of [app-recordings]

[ext-local]
include => ext-local-custom
exten => *843950,1,Goto(app-campon-toggle,*84,1)
exten => *843950,hint,ccss:SIP/3950
exten => *843951,1,Goto(app-campon-toggle,*84,1)
exten => *843951,hint,ccss:SIP/3951
exten => 3950,1,ExecIf($[${DB(AMPUSER/3950/ringtimer)} > 0]?Set(__RINGTIMER=${DB(AMPUSER/3950/ringtimer)}))
exten => 3950,n,Macro(exten-vm,3950,3950,0,0,0)
exten => 3950,n,Set(__PICKUPMARK=)
exten => 3950,n,Goto(vmret,1)
exten => 3950,hint,SIP/3950
exten => ${VM_PREFIX}3950,1,Macro(vm,3950,DIRECTDIAL,${IVR_RETVM})
exten => ${VM_PREFIX}3950,n,Goto(vmret,1)
exten => vmb3950,1,Macro(vm,3950,BUSY,${IVR_RETVM})
exten => vmb3950,n,Goto(vmret,1)
exten => vmu3950,1,Macro(vm,3950,NOANSWER,${IVR_RETVM})
exten => vmu3950,n,Goto(vmret,1)
exten => vms3950,1,Macro(vm,3950,NOMESSAGE,${IVR_RETVM})
exten => vms3950,n,Goto(vmret,1)
exten => 3951,1,ExecIf($[${DB(AMPUSER/3951/ringtimer)} > 0]?Set(__RINGTIMER=${DB(AMPUSER/3951/ringtimer)}))
exten => 3951,n,Macro(exten-vm,3951,3951,0,0,0)
exten => 3951,n,Set(__PICKUPMARK=)
exten => 3951,n,Goto(vmret,1)
exten => 3951,hint,SIP/3951
exten => ${VM_PREFIX}3951,1,Macro(vm,3951,DIRECTDIAL,${IVR_RETVM})
exten => ${VM_PREFIX}3951,n,Goto(vmret,1)
exten => vmb3951,1,Macro(vm,3951,BUSY,${IVR_RETVM})
exten => vmb3951,n,Goto(vmret,1)
exten => vmu3951,1,Macro(vm,3951,NOANSWER,${IVR_RETVM})
exten => vmu3951,n,Goto(vmret,1)
exten => vms3951,1,Macro(vm,3951,NOMESSAGE,${IVR_RETVM})
exten => vms3951,n,Goto(vmret,1)
exten => vmret,1,GotoIf($["${IVR_RETVM}" = “RETURN” & “${IVR_CONTEXT}” != “”]?playret)
exten => vmret,n,Hangup
exten => vmret,n(playret),Playback(exited-vm-will-be-transfered&silence/1)
exten => vmret,n,Goto(${IVR_CONTEXT},return,1)
exten => h,1,Macro(hangupcall,)

; end of [ext-local]

[ext-fax]
include => ext-fax-custom
exten => 3950,1,Noop(Receiving Fax for: Thomson 3950 (3950), From: ${CALLERID(all)})
exten => 3950,n,Set(FAX_RX_EMAIL=antonio.spirandelli@longwave.eu)
exten => 3950,n(receivefax),Goto(s,receivefax)
exten => s,1,Macro(user-callerid,)
exten => s,n,Noop(Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => s,n(receivefax),StopPlaytones
exten => s,n,ReceiveFAX(${ASTSPOOLDIR}/fax/${UNIQUEID}.tif,f)
exten => s,n,ExecIf($["${FAXSTATUS}"="" | “${FAXSTATUS}” = “FAILED” & “${FAXERROR}” = “INIT_ERROR”]?Set(FAXSTATUS=FAILED LICENSE MAY BE EXCEEDED check log errors))
exten => s,n,ExecIf($["${FAXSTATUS:0:6}"=“FAILED” && “${FAXERROR}”!=“INIT_ERROR”]?Set(FAXSTATUS=“FAILED: error: ${FAXERROR} statusstr: ${FAXOPT(statusstr)}”))
exten => s,n,Hangup
exten => h,1,GotoIf($[${STAT(e,${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)} = 0]?failed)
exten => h,n(process),GotoIf($[${LEN(${FAX_RX_EMAIL})} = 0]?noemail)
exten => h,n,System(${ASTVARLIBDIR}/bin/fax-process.pl --to “${FAX_RX_EMAIL}” --from "fax_asterisk@longwave.eu" --dest “${FROM_DID}” --subject “New fax from ${URIENCODE(${CALLERID(name)})} $
RIENCODE(<${CALLERID(number)}>)}” --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)
exten => h,n(end),Macro(hangupcall,)
exten => h,n(noemail),Noop(ERROR: No Email Address to send FAX: status: [${FAXSTATUS}], From: [${CALLERID(all)}])
exten => h,n,Macro(hangupcall,)
exten => h,process+101(failed),Noop(FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => h,n,Macro(hangupcall,)

; end of [ext-fax]

[app-fax]
include => app-fax-custom
exten => 666,1,Set(FAX_RX_EMAIL=antonio.spirandelli@longwave.eu)
exten => 666,n,Goto(ext-fax,s,1)
exten => h,1,Macro(hangupcall,)

; end of [app-fax]

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)})

; end of [ext-did-0001]

[ext-did-0002]
include => ext-did-0002-custom
exten => fax,1,Goto(${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)})
exten => 3900,1,Set(__FROM_DID=${EXTEN})
exten => 3900,n,Gosub(app-blacklist-check,s,1)
exten => 3900,n,ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 3900,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 3900,n,Set(CALLERPRES()=allowed_not_screened)
exten => 3900,n(dest-ext),Goto(custom-fax-iaxmodem,s,1)
exten => 3950,1,Set(__FROM_DID=${EXTEN})
exten => 3950,n,Gosub(app-blacklist-check,s,1)
exten => 3950,n,ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 3950,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 3950,n,Set(CALLERPRES()=allowed_not_screened)
exten => 3950,n,Set(FAX_DEST=from-did-direct^3950^1)
exten => 3950,n,Answer
exten => 3950,n,Wait(4)
exten => 3950,n(dest-ext),Goto(from-did-direct,3950,1)
exten => 3999,1,Set(__FROM_DID=${EXTEN})
exten => 3999,n,Gosub(app-blacklist-check,s,1)
exten => 3999,n,ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 3999,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 3999,n,Set(CALLERPRES()=allowed_not_screened)
exten => 3999,n(dest-ext),Goto(macro-bridge_oxe_vmexchange2010,s,1)

; end of [ext-did-0002]

[ext-did]
include => ext-did-custom
include => ext-did-0001
include => ext-did-0002
exten => foo,1,Noop(bar)

; end of [ext-did]

[ext-did-catchall]
include => ext-did-catchall-custom
exten => s,1,Noop(No DID or CID Match)
exten => s,n(a2),Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,SayAlpha(${FROM_DID})
exten => s,n,Hangup
exten => _.,1,Set(__FROM_DID=${EXTEN})
exten => _.,n,Noop(Received an unknown call with DID set to ${EXTEN})
exten => _.,n,Goto(s,a2)
exten => h,1,Hangup

; end of [ext-did-catchall]

[from-did-direct-ivr]
include => from-did-direct-ivr-custom
exten => 3950,1,Macro(blkvm-clr,)
exten => 3950,n,Set(__NODEST=)
exten => 3950,n,Goto(from-did-direct,3950,1)
exten => ${VM_PREFIX}3950,1,Macro(blkvm-clr,)
exten => ${VM_PREFIX}3950,n,Set(__NODEST=)
exten => ${VM_PREFIX}3950,n,Macro(vm,3950,DIRECTDIAL,${IVR_RETVM})
exten => ${VM_PREFIX}3950,n,GotoIf($["${IVR_RETVM}" = “RETURN” & “${IVR_CONTEXT}” != “”]?ext-local,vmret,playret)
exten => 3951,1,Macro(blkvm-clr,)
exten => 3951,n,Set(__NODEST=)
exten => 3951,n,Goto(from-did-direct,3951,1)
exten => ${VM_PREFIX}3951,1,Macro(blkvm-clr,)
exten => ${VM_PREFIX}3951,n,Set(__NODEST=)
exten => ${VM_PREFIX}3951,n,Macro(vm,3951,DIRECTDIAL,${IVR_RETVM})
exten => ${VM_PREFIX}3951,n,GotoIf($["${IVR_RETVM}" = “RETURN” & “${IVR_CONTEXT}” != “”]?ext-local,vmret,playret)

; end of [from-did-direct-ivr]

[from-trunk-sip-Exchange]
include => from-trunk-sip-Exchange-custom
exten => _.,1,Set(GROUP()=OUT_1)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-sip-Exchange]

[ext-trunk]
include => ext-trunk-custom
exten => 1,1,Set(TDIAL_STRING=SIP/Exchange)
exten => 1,n,Set(DIAL_TRUNK=1)
exten => 1,n,Goto(ext-trunk,tdial,1)
exten => 2,1,Set(TDIAL_STRING=SIP/TG_SIP_LW)
exten => 2,n,Set(DIAL_TRUNK=2)
exten => 2,n,Goto(ext-trunk,tdial,1)
exten => 3,1,Set(TDIAL_STRING=SIP/TG_SIP_LYNC)
exten => 3,n,Set(DIAL_TRUNK=3)
exten => 3,n,Goto(ext-trunk,tdial,1)
exten => tdial,1,Set(OUTBOUND_GROUP=OUT_${DIAL_TRUNK})
exten => tdial,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}" = “”]?nomax)
exten => tdial,n,GotoIf($[${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}}]?hangit)
exten => tdial,n(nomax),ExecIf($["${CALLINGPRES_SV}" != “”]?Set(CALLERPRES()=${CALLINGPRES_SV}))
exten => tdial,n,Set(DIAL_NUMBER=${FROM_DID})
exten => tdial,n,GosubIf($["${PREFIX_TRUNK_${DIAL_TRUNK}}" != “”]?sub-flp-${DIAL_TRUNK},s,1)
exten => tdial,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => tdial,n,Dial(${TDIAL_STRING}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => tdial,n,Set(CALLERID(number)=${CALLERID(number):0:40})
exten => tdial,n,Set(CALLERID(name)=${CALLERID(name):0:40})
exten => tdial,n(hangit),Hangup

; end of [ext-trunk]

[from-trunk-sip-TG_SIP_LW]
include => from-trunk-sip-TG_SIP_LW-custom
exten => _.,1,Set(GROUP()=OUT_2)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-sip-TG_SIP_LW]

[from-trunk-sip-TG_SIP_LYNC]
include => from-trunk-sip-TG_SIP_LYNC-custom
exten => _.,1,Set(GROUP()=OUT_3)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-sip-TG_SIP_LYNC]

[macro-record-enable]
include => macro-record-enable-custom
exten => s,1,GotoIf($["${BLINDTRANSFER}" = “”]?check)
exten => s,n,ResetCDR(w)
exten => s,n,StopMixMonitor()
exten => s,n(check),ExecIf($["${ARG1}"=""]?MacroExit())
exten => s,n,GotoIf($["${ARG2}"=“Group”]?Group:OUT)
exten => s,n(Group),Set(LOOPCNT=${FIELDQTY(ARG1,-)})
exten => s,n,Set(ITER=1)
exten => s,n(begin),GotoIf($["${CUT(DB(AMPUSER/${CUT(ARG1,-,${ITER})}/recording),=,3)}" != “Always”]?continue)
exten => s,n,Set(TEXTEN=${CUT(ARG1,-,${ITER})})
exten => s,n,Set(CALLFILENAME=g${TEXTEN}-${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => s,n,Goto(record)
exten => s,n(continue),Set(ITER=$[${ITER}+1])
exten => s,n,GotoIf($[${ITER}<=${LOOPCNT}]?begin)
exten => s,n(OUT),GotoIf($["${ARG2}"=“IN”]?IN)
exten => s,n,ExecIf($["${CUT(DB(AMPUSER/${ARG1}/recording),\|,1):4}" != “Always”]?MacroExit())
exten => s,n,Set(CALLFILENAME=OUT${ARG1}-${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => s,n,Goto(record)
exten => s,n(IN),ExecIf($["${CUT(DB(AMPUSER/${ARG1}/recording),\|,2):3}" != “Always”]?MacroExit())
exten => s,n,Set(CALLFILENAME=${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => s,n(record),MixMonitor(${MIXMON_DIR}${CALLFILENAME}.${MIXMON_FORMAT},${MIXMON_POST})
exten => s,n,MacroExit()

; end of [macro-record-enable]

[macro-prepend-cid]
include => macro-prepend-cid-custom
exten => s,1,GotoIf($["${RGPREFIX}" = “”]?REPCID)
exten => s,n,GotoIf($["${RGPREFIX}" != “${CALLERID(name):0:${LEN(${RGPREFIX})}}”]?REPCID)
exten => s,n,Set(CALLERID(name)=${CALLERID(name):${LEN(${RGPREFIX})}})
exten => s,n,Set(_RGPREFIX=)
exten => s,n(REPCID),Set(_RGPREFIX=${ARG1})
exten => s,n,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)})

; end of [macro-prepend-cid]

[outbound-allroutes]
include => outbound-allroutes-custom
include => outrt-1 ; Exchange_UM
include => outrt-2 ; Longwave_NODO1
include => outrt-3 ; Microsoft_LYNC
exten => foo,1,Noop(bar)

; end of [outbound-allroutes]

[outrt-1] ; Exchange_UM
include => outrt-1-custom
exten => 3998,1,Macro(user-callerid,LIMIT,)
exten => 3998,n,Set(INTRACOMPANYROUTE=YES)
exten => 3998,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => 3998,n,Set(_NODEST=)
exten => 3998,n,Macro(record-enable,${AMPUSER},OUT,)
exten => 3998,n,Macro(dialout-trunk,1,39${EXTEN:2},)
exten => 3998,n,Macro(outisbusy,)
exten => 3999,1,Macro(user-callerid,LIMIT,)
exten => 3999,n,Set(INTRACOMPANYROUTE=YES)
exten => 3999,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => 3999,n,Set(_NODEST=)
exten => 3999,n,Macro(record-enable,${AMPUSER},OUT,)
exten => 3999,n,Macro(dialout-trunk,1,39${EXTEN:2},)
exten => 3999,n,Macro(outisbusy,)

; end of [outrt-1]

[outrt-2] ; Longwave_NODO1
include => outrt-2-custom
exten => _0.,1,Macro(user-callerid,LIMIT,)
exten => _0.,n,Set(INTRACOMPANYROUTE=YES)
exten => _0.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _0.,n,Set(_NODEST=)
exten => _0.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _0.,n,Macro(dialout-trunk,2,0${EXTEN:1},)
exten => _0.,n,Macro(outisbusy,)
exten => _11.,1,Macro(user-callerid,LIMIT,)
exten => _11.,n,Set(INTRACOMPANYROUTE=YES)
exten => _11.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _11.,n,Set(_NODEST=)
exten => _11.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _11.,n,Macro(dialout-trunk,2,11${EXTEN:2},)
exten => _11.,n,Macro(outisbusy,)
exten => _15.,1,Macro(user-callerid,LIMIT,)
exten => _15.,n,Set(INTRACOMPANYROUTE=YES)
exten => _15.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _15.,n,Set(_NODEST=)
exten => _15.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _15.,n,Macro(dialout-trunk,2,15${EXTEN:2},)
exten => _15.,n,Macro(outisbusy,)
exten => _16.,1,Macro(user-callerid,LIMIT,)
exten => _16.,n,Set(INTRACOMPANYROUTE=YES)
exten => _16.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _16.,n,Set(_NODEST=)
exten => _16.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _16.,n,Macro(dialout-trunk,2,16${EXTEN:2},)
exten => _16.,n,Macro(outisbusy,)
exten => _22.,1,Macro(user-callerid,LIMIT,)
exten => _22.,n,Set(INTRACOMPANYROUTE=YES)
exten => _22.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _22.,n,Set(_NODEST=)
exten => _22.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _22.,n,Macro(dialout-trunk,2,22${EXTEN:2},)
exten => _22.,n,Macro(outisbusy,)
exten => _25.,1,Macro(user-callerid,LIMIT,)
exten => _25.,n,Set(INTRACOMPANYROUTE=YES)
exten => _25.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _25.,n,Set(_NODEST=)
exten => _25.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _25.,n,Macro(dialout-trunk,2,25${EXTEN:2},)
exten => _25.,n,Macro(outisbusy,)
exten => _33.,1,Macro(user-callerid,LIMIT,)
exten => _33.,n,Set(INTRACOMPANYROUTE=YES)
exten => _33.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _33.,n,Set(_NODEST=)
exten => _33.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _33.,n,Macro(dialout-trunk,2,33${EXTEN:2},)
exten => _33.,n,Macro(outisbusy,)

; end of [outrt-2]

[outrt-3] ; Microsoft_LYNC
include => outrt-3-custom
exten => _20.,1,Macro(user-callerid,LIMIT,)
exten => _20.,n,Set(INTRACOMPANYROUTE=YES)
exten => _20.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _20.,n,Set(_NODEST=)
exten => _20.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _20.,n,Macro(dialout-trunk,3,20${EXTEN:2},)
exten => _20.,n,Macro(outisbusy,)

; end of [outrt-3]

[app-blackhole]
include => app-blackhole-custom
exten => hangup,1,Noop(Blackhole Dest: Hangup)
exten => hangup,n,Hangup
exten => zapateller,1,Noop(Blackhole Dest: Play SIT Tone)
exten => zapateller,n,Answer
exten => zapateller,n,Zapateller()
exten => musiconhold,1,Noop(Blackhole Dest: Put caller on hold forever)
exten => musiconhold,n,Answer
exten => musiconhold,n,MusicOnHold()
exten => congestion,1,Noop(Blackhole Dest: Congestion)
exten => congestion,n,Answer
exten => congestion,n,Playtones(congestion)
exten => congestion,n,Congestion(20)
exten => congestion,n,Hangup
exten => busy,1,Noop(Blackhole Dest: Busy)
exten => busy,n,Busy(20)
exten => busy,n,Hangup
exten => ring,1,Noop(Blackhole Dest: Ring)
exten => ring,n,Answer
exten => ring,n,Playtones(ring)
exten => ring,n,Wait(300)
exten => ring,n,Hangup

; end of [app-blackhole]

[bad-number]
include => bad-number-custom
exten => _X.,1,ResetCDR()
exten => _X.,n,NoCDR()
exten => _X.,n,Progress
exten => _X.,n,Wait(1)
exten => _X.,n,Progress
exten => _X.,n,Playback(silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer)
exten => _X.,n,Wait(1)
exten => _X.,n,Congestion(20)
exten => _X.,n,Hangup

; end of [bad-number]

[macro-confirm]
include => macro-confirm-custom
exten => s,1,Set(LOOPCOUNT=0)
exten => s,n,Set(__MACRO_RESULT=ABORT)
exten => s,n,Set(MSG1=${IF($["${ARG1}${ALT_CONFIRM_MSG}"=""]?incoming-call-1-accept-2-decline:${IF($[${LEN(${ALT_CONFIRM_MSG})}>0]?${ALT_CONFIRM_MSG}:${ARG1})})})
exten => s,n(start),Background(${MSG1},m,${CHANNEL(language)},macro-confirm)
exten => s,n,Read(INPUT,1,4)
exten => s,n,GotoIf($[${LEN(${INPUT})} > 0]?${INPUT},1:t,1)
exten => 1,1,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"=“0” & “${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}”=""]?toolate,1)
exten => 1,n,Noop(Deleting: RG/${ARG3}/${UNIQCHAN} ${DB_DELETE(RG/${ARG3}/${UNIQCHAN})})
exten => 1,n,Macro(blkvm-clr,)
exten => 1,n,Set(SHARED(ANSWER_STATUS,${FORCE_CONFIRM})=)
exten => 1,n(skip),Set(__MACRO_RESULT=)
exten => 1,n,ExecIf($[("${MOHCLASS}"!=“default”) & ("${MOHCLASS}"!="")]?Set(CHANNEL(musicclass)=${MOHCLASS}))
exten => 1,n(exitopt1),MacroExit()
exten => 2,1,Goto(noanswer,1)
exten => 3,1,SayDigits(${CALLCONFIRMCID})
exten => 3,n,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"=“0” & “${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}”=""]?toolate,1:s,start)
exten => t,1,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"=“0” & “${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}”=""]?toolate,1)
exten => t,n,Set(LOOPCOUNT=$[ ${LOOPCOUNT} + 1 ])
exten => t,n,GotoIf($[ ${LOOPCOUNT} < 5 ]?s,start:noanswer,1)
exten => _X,1,Background(invalid,m,${CHANNEL(language)},macro-confirm)
exten => _X,n,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"=“0” | “${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}”=""]?toolate,1)
exten => _X,n,Set(LOOPCOUNT=$[ ${LOOPCOUNT} + 1 ])
exten => _X,n,GotoIf($[ ${LOOPCOUNT} < 5 ]?s,start:noanswer,1)
exten => noanswer,1,Set(__MACRO_RESULT=ABORT)
exten => noanswer,n(exitnoanswer),MacroExit()
exten => toolate,1,Set(MSG2=${IF($[“foo${ARG2}” != “foo”]?${ARG2}:“incoming-call-no-longer-avail”)})
exten => toolate,n,Playback(${MSG2})
exten => toolate,n,Set(__MACRO_RESULT=ABORT)
exten => toolate,n(exittoolate),MacroExit()
exten => h,1,Macro(hangupcall,)

; end of [macro-confirm]

[macro-auto-confirm]
include => macro-auto-confirm-custom
exten => s,1,Set(__MACRO_RESULT=)
exten => s,n,Macro(blkvm-clr,)
exten => s,n,Noop(Deleting: RG/${ARG1}/${UNIQCHAN} ${DB_DELETE(RG/${ARG1}/${UNIQCHAN})})
exten => s,n,Set(MASTER_CHANNEL(CONNECTEDLINE(num))=${DIALEDPEERNUMBER})
exten => s,n,Set(MASTER_CHANNEL(CONNECTEDLINE(name))=${DB(AMPUSER/${DIALEDPEERNUMBER}/cidname)})

; end of [macro-auto-confirm]

[macro-auto-blkvm]
include => macro-auto-blkvm-custom
exten => s,1,Set(__MACRO_RESULT=)
exten => s,n,Macro(blkvm-clr,)
exten => s,n,Set(MASTER_CHANNEL(CONNECTEDLINE(num))=${DIALEDPEERNUMBER})
exten => s,n,Set(MASTER_CHANNEL(CONNECTEDLINE(name))=${DB(AMPUSER/${DIALEDPEERNUMBER}/cidname)})

; end of [macro-auto-blkvm]

[sub-pincheck]
include => sub-pincheck-custom
exten => s,1,Authenticate(${ARG3},)
exten => s,n,ResetCDR()
exten => s,n,Return()

; end of [sub-pincheck]

[macro-dialout-trunk]
include => macro-dialout-trunk-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,GosubIf($[$["${ARG3}" != “”] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != “NOPASSWD”]]?sub-pincheck,s,1)
exten => s,n,GotoIf($[“x${OUTDISABLE_${DIAL_TRUNK}}” = “xon”]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(OUTBOUND_GROUP=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = “foo”]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = “YES”]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),GosubIf($["${PREFIX_TRUNK_${DIAL_TRUNK}}" != “”]?sub-flp-${DIAL_TRUNK},s,1)
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)})
exten => s,n,ExecIf($["${MOHCLASS}"!=“default” & “${MOHCLASS}”!="" & “${FORCE_CONFIRM}”="" ]?Set(DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS}))
exten => s,n,ExecIf($["${FORCE_CONFIRM}"!="" ]?Set(DIAL_TRUNK_OPTIONS=${DIAL_TRUNK_OPTIONS}M(confirm)))
exten => s,n(gocall),Macro(dialout-trunk-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = “BYPASS”]?bypass,1)
exten => s,n,GotoIf($["${custom}" = “AMP”]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Noop(Dial failed for some reason with DIALSTATUS = ${DIALSTATUS} and HANGUPCAUSE = ${HANGUPCAUSE})
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)})
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = “OUTNUM”]?outnum:skipoutnum)
exten => s,n(outnum),Set(the_num=${OUTNUM})
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Noop(Dial failed for some reason with DIALSTATUS = ${DIALSTATUS} and HANGUPCAUSE = ${HANGUPCAUSE})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)
exten => s-ANSWER,1,Noop(Call successfully answered - Hanging up now)
exten => s-ANSWER,n,Macro(hangupcall,)
exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Progress
exten => s-NOANSWER,n,Playback(number-not-answering,noanswer)
exten => s-NOANSWER,n,Congestion(20)
exten => s-INVALIDNMBR,1,Noop(Dial failed due to trunk reporting Address Incomplete - giving up)
exten => s-INVALIDNMBR,n,Progress
exten => s-INVALIDNMBR,n,Playback(ss-noservice,noanswer)
exten => s-INVALIDNMBR,n,Busy(20)
exten => s-CHANGED,1,Noop(Dial failed due to trunk reporting Number Changed - giving up)
exten => s-CHANGED,n,Playtones(busy)
exten => s-CHANGED,n,Busy(20)
exten => s-.,1,Set(RC=${IF($[${ISNULL(${HANGUPCAUSE})}]?0:${HANGUPCAUSE})})
exten => s-.,n,Goto(${RC},1)
exten => 17,1,Goto(s-BUSY,1)
exten => 18,1,Goto(s-NOANSWER,1)
exten => 22,1,Goto(s-CHANGED,1)
exten => 23,1,Goto(s-CHANGED,1)
exten => 28,1,Goto(s-INVALIDNMBR,1)
exten => X,1,Goto(continue,1)
exten => X.,1,Goto(continue,1)
exten => continue,1,GotoIf($["${OUTFAIL
${ARG1}}" = “”]?noreport)
exten => continue,n,AGI(${OUTFAIL
${ARG1}})
exten => continue,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} HANGUPCAUSE: ${HANGUPCAUSE} - failing through to other trunks)
exten => continue,n,Set(CALLERID(number)=${AMPUSER})
exten => disabletrunk,1,Noop(TRUNK: ${OUT
${DIAL_TRUNK}} DISABLED - falling through to next trunk)
exten => bypass,1,Noop(TRUNK: ${OUT
${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook)
exten => h,1,Macro(hangupcall,)

; end of [macro-dialout-trunk]

[macro-dialout-dundi]
include => macro-dialout-dundi-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,GosubIf($[$["${ARG3}" != “”] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != “NOPASSWD”]]?sub-pincheck,s,1)
exten => s,n,GotoIf($[“x${OUTDISABLE_${DIAL_TRUNK}}” = “xon”]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(OUTBOUND_GROUP=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = “foo”]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = “YES”]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),GosubIf($["${PREFIX_TRUNK_${DIAL_TRUNK}}" != “”]?sub-flp-${DIAL_TRUNK},s,1)
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,ExecIf($["${MOHCLASS}"!=“default” & “${MOHCLASS}”!="" & “${FORCE_CONFIRM}”="" ]?Set(DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS}))
exten => s,n,ExecIf($["${FORCE_CONFIRM}"!="" ]?Set(DIAL_TRUNK_OPTIONS=${DIAL_TRUNK_OPTIONS}M(confirm)))
exten => s,n(gocall),Macro(dialout-dundi-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = “BYPASS”]?bypass,1)
exten => s,n,Macro(dundi-${DIAL_TRUNK},${OUTNUM})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)
exten => s-ANSWER,1,Noop(Call successfully answered - Hanging up now)
exten => s-ANSWER,n,Macro(hangupcall,)
exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Progress
exten => s-NOANSWER,n,Playback(number-not-answering,noanswer)
exten => s-NOANSWER,n,Congestion(20)
exten => s-INVALIDNMBR,1,Noop(Dial failed due to trunk reporting Address Incomplete - giving up)
exten => s-INVALIDNMBR,n,Progress
exten => s-INVALIDNMBR,n,Playback(ss-noservice,noanswer)
exten => s-INVALIDNMBR,n,Busy(20)
exten => s-CHANGED,1,Noop(Dial failed due to trunk reporting Number Changed - giving up)
exten => s-CHANGED,n,Playtones(busy)
exten => s-CHANGED,n,Busy(20)
exten => s-.,1,Set(RC=${IF($[${ISNULL(${HANGUPCAUSE})}]?0:${HANGUPCAUSE})})
exten => s-.,n,Goto(${RC},1)
exten => 17,1,Goto(s-BUSY,1)
exten => 18,1,Goto(s-NOANSWER,1)
exten => 22,1,Goto(s-CHANGED,1)
exten => 23,1,Goto(s-CHANGED,1)
exten => 28,1,Goto(s-INVALIDNMBR,1)
exten => X,1,Goto(continue,1)
exten => X.,1,Goto(continue,1)
exten => continue,1,GotoIf($["${OUTFAIL
${ARG1}}" = “”]?noreport)
exten => continue,n,AGI(${OUTFAIL
${ARG1}})
exten => continue,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} HANGUPCAUSE: ${HANGUPCAUSE} - failing through to other trunks)
exten => continue,n,Set(CALLERID(number)=${AMPUSER})
exten => disabletrunk,1,Noop(TRUNK: ${OUT
${DIAL_TRUNK}} DISABLED - falling through to next trunk)
exten => bypass,1,Noop(TRUNK: ${OUT
${DIAL_TRUNK}} BYPASSING because dialout-dundi-predial-hook)
exten => h,1,Macro(hangupcall,)

[/quote]

In both extensions I deleated some contest that was not important for investigation.
Thanks again for your help

[quote]exten => 3950,n,Set(FAX_DEST=from-did-direct^[color=#FF0000]3950[/color]^1)
[/quote]

Asterisk is correctly executing the dialplan. As far as the dialplan is concerned, 3950 is the extension that has the fax machine for extension 3950 on it.

You have a configuration error, or maybe a bug in the GUI.

I really think is a bug in the GUI. If you know FreePBX, it gives you the possibility to setup on a extension the FAX feature so using same extension number you can have set phone and fax. All is configurable from GUI, just enable it and put email where faxes goes to.
So if I well understood, asterisk recognice the CNG tone of fax call and then it reroutes fax call to extension 3950 ( which has FAX enabled ). Right? So, why it doesn’t work? is there some specific trace that can show me why T38 session is not established? I am pretty sure that Fax for asterisk of Digium is correctly installed. I also have 1 T38 license, bought fro free on Digium site.

fax show capabilities

Registered FAX Technology Modules:

Type : DIGIUM
Description : Digium FAX Driver
Capabilities : SEND RECEIVE T.38 G.711 MULTI-DOC

1 registered modules

freepbx*CLI> fax show licenses
Fax Licensing Information

Free fax licenses: 1
Total licensed ports: 1

Licenses Found:
File: FFA-KHPAC22TTP4N.lic – Key: FFA-KHPAC22TTP4N – Product: RESFFA – Host-ID: ad:56:fb:f0:0d:1b:da:27:fc:96:bb:00:35:44:b4:f0:e7:ff:ae:48 – Ports: 1 (OK)

freepbx*CLI> fax show settings
FAX For Asterisk Settings:
ECM: Enabled
Status Events: Off
Minimum Bit Rate: 2400
Maximum Bit Rate: 14400
Modem Modulations Allowed: V17,V27,V29

FAX Technology Modules:

DIGIUM (Digium FAX Driver) Settings:
Maximum T.38 Packet Delay: 800
T.38 Session Packet Capture: Off
G.711 Session Audio Capture: Off

freepbx*CLI> fax show version
FAX For Asterisk Components:
Applications: 1.8.4.4
Digium FAX Driver: 1.8.0_1.3.0 (optimized for pentium3m_32)

I mean asterisk command. I already had investagated with wireshark and what i see is just T38 session does not start

[quote]-- SIP/3950-00000037 is ringing
– Nobody picked up in 24000 ms [/quote]

In other words, extension 3950 was rung, but never answered.