Dial() function if call fail

Hi Lads,

I`m using asterisk version 1.2.30.1.
I want to do trick when a call is getting disconected. Look for code:

exten => s,210,Set(__DIDNUMBER=${channel_didno}) exten => s,211,GotoIf($["foo${DIDNUMBER}" = "foo"]?10:6) exten => s,212,Dial(SIP/${DIDNUMBER}@${CCLIDEXT}${EXTMACRO},${OUTDIALOPT}${INDIALOPT}) exten => s,213,Macro(hangupcall) exten => s,214,AGI(dial,,${CCLIDEXT}${EXTMACRO},${MAXCALL},${OUTDIALOPT}${INDIALOPT}) ;finally we call the extension if we don't have a did exten => s,215,Macro(hangupcall)

Now, if the call with sending the ddi number in TO field of the SIP Packet will not get through I wish to call the same extension with the Extension number in TO field of SIP packet.

Is this possible on this version of asterisk?
Is this possible on any version of asterisk?