[asterisk-dev] Re: 'IAX2 call variable passing between servers '

Tony Mountifield tony at softins.clara.co.uk
Mon Aug 7 14:10:56 MST 2006


In article <645FEC31A18FE54A8721500CDD55A7B6035075E3 at mail.oneeighty.com>,
Douglas Garstang <dgarstang at oneeighty.com> wrote:
> 
> I'm having a little trouble understanding how a Polycom 601 phone that
> has no knowledge of IAX can receive an IAX call. It may make perfect
> sense to you, but it doesn't to me.
> 
> > However, you keep referring to these calls being 'flagged as 
> > IAX2 calls when they are SIP calls', which sounds like 
> > something that your AGI script (or something else) is doing, 
> > not Asterisk. Asterisk doesn't 'flag' calls as being any 
> > particular type, so unless you can provide an example of 
> > exactly what Asterisk is supposedly doing wrong, I don't 
> > think you have actually demonstrated any problem in Asterisk at all.
> 
> I am referring to the agi_type variable that Asterisk passes to an AGI
> script when it calls it. It is being set to IAX2, not SIP.

Doug, it occurs to me what you might be missing in the conceptual model of
Asterisk's call handling.

Every call that goes through Asterisk (rather than just calling an IVR or
something) has an incoming channel and an outgoing channel. Each channel
has a "type" that describes its technology.

When your Asterisk-2 receives a call from Asterisk-1 over IAX2, what
executes in the dialplan on Asterisk-2 is an IAX2 channel. If you just
play a message to the user, then that IAX2 channel is the only one on that
call. If your dialplan wants to send that call on to another UA (or even
another Asterisk box), it calls the Dial application.

The Dial application tells Asterisk to create a NEW channel on which to
place an outgoing call. The type of the new channel is governed by the
"SIP/", "IAX2/", "Zap/", etc. of the Dial target.

There are now TWO channels involved in the call. As the outgoing call
makes progress, Asterisk passes those indications back to the incoming
channel. When the outgoing call is answered, Asterisk bridges the audio
between those calls. There are still two channels. In your case an IAX2
channel on the incoming leg and a SIP channel on the outgoing leg. You
don't have an "IAX2 call" overall. SIP, IAX2, etc is not an attribute of a
whole call, just of the incoming or outgoing channel itself.

One way I found that helped this all to make sense was to watch the
channel events that show up on the Manager API, and study them to
understand what was happening. It's worth doing even if you don't intend
writing a Manager application. Just use the "script" command to capture
everything and then telnet into the Manager port, 5038:

# script manager.txt
Script started, file is manager.txt
# exec telnet localhost 5038
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
Asterisk Call Manager/1.0
Action: Login
Username: tony
Secret: password

Response: Success
Message: Authentication accepted

<call events>

Action: Logoff

Response: Goodbye
Message: Thanks for all the fish.

Connection closed by foreign host.
Script done, file is manager.txt
# 

Note the "exec" before telnet. That is to avoid forgetting to close
the script file.

Look for the Newchannel, Newstate, Newexten, Dial, Link, Unlink,
Rename and Hangup events.

Hope this helps
Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-dev mailing list