no you totally misunderstood me.
In asterisk when you want to receive calls from a provider or another host you register. In sip you register and also specify a DID or extension to handle the call within the specified peer context.
register => user:password@hostname/exten
that what that means in that syntax. so when the call comes in it goes to the context that is specified in the host peer find that exten and handle the call.
Ok.
When you do the call out 127.0.0.1 it gets looped backed into the server's SIP and it looks like it is coming from the outside. That is why the SIP-external gets called. It uses the number you called as the exten and wants to pass it to somebody to be handled. But before it does that it checks to see if the person who called is 'known". In this case it is not know because the call was not made from a defined peer. So the flag in the code says if caller is unknown then play the congestion tone.
You fixed the problem by rewriting the SIP-external context to garb the exten and dial it.
The only probem with that is that the SIP-external plays a bigger role in freepbx than just dialing the exten. What it does is get calls from the outside and routes the call back in ... I don't rrmbr the name of the context but what happens here is that the call then gets handled as "incoming routes". So if you mess about with SIP-external you will miss out on using "inbound routes" which is a really cool feature and simplifies using and setting up freepbx.
My suggestion is that you go with the flow and use sip-external as it was designed and don't swim against the tide.
So to make it work as designed -- you would set up the "incoming route" to handle the call that is coming in to this DID (or SIP extension). You might say you have hundreds of SIP extensions and you don't wnat to set it up and in that case you might live with the change you made. understandable.
Re: making the caller known is all about creating a peer with the host= 127.0.0.1 and using that peer as the provider instead of the the ip address as the provider in the a2b trunk definition.
I know it's much to get in one gulp
so just read a little at a time.