Asterisk 1.6.1.8 local channel ANSWER

I Have faced such behaviour asterisk.
I use local channel. In it there is a certain processing of a call and send it on SIP gateway.
When I call, through this channel, * at first does ANSWER, and only then sends it on SIP:

– Executing [111@test1:1] Dial(“SIP/2903-b7b27620”, “Local/1@call_local/111/n”) in new stack
– Called 1@call_local/111/n
– Executing [1@call_local:1] Dial(“Local/1@call_local-fbe6;2”, “SIP/91231234@cisco5350_1,45,gHh”) in new stack
– Local/1@call_local-fbe6;1 answered SIP/2903-b7b27620
– Called 91231234@cisco5350_1
– Local/1@call_local-fbe6;2 requested special control 20, passing it to SIP/cisco5350_1-09566570
– Local/1@call_local-fbe6;2 requested special control 20, passing it to SIP/cisco5350_1-09566570
– Local/1@call_local-fbe6;2 requested special control 20, passing it to SIP/cisco5350_1-09566570

Because of it asterisk2billing incorrectly considers the beginning of conversation and writes down wrong CDR.

I tested the same design with local channel on asterisk 1.4.26, there all Ok - ANSWER occurs, when comes 200 Ok on SIP:

– Executing [111@test1:1] Dial(“SIP/2903-b7d10518”, “Local/1@call_local/111/n”) in new stack
– Called 1@call_local/111/n
– Executing [1@call_local:1] Dial(“Local/1@call_local-98c3,2”, “SIP/91231234@cisco5350|45|gHh”) in new stack
– Called 91231234@cisco5350
– SIP/cisco5350-098512a0 is making progress passing it to Local/1@call_local-98c3,2
– Local/1@call_local-98c3,1 is making progress passing it to SIP/2903-b7d10518
– SIP/cisco5350-098512a0 answered Local/1@call_local-98c3,2
– Local/1@call_local-98c3,1 answered SIP/2903-b7d10518

How to change behaviour asterisk 1.6. that ASNWER in local channel occurred only after ANSWER will come on SIP?

Remove the “H” flag from the Dial. Dial has to answer in order for the caller to be able to send DTMF to disconnect the call before it is answered.

Or you could try nobbling this code:

if (ast_test_flag64(&opts, OPT_DTMF_EXIT) || ast_test_flag64(&opts, OPT_CALLER_HANGUP)) { __ast_answer(chan, 0, 0); }

Not analysed in depth, but seems to make sense.

Thank you very match.
Removing this flag help me.