[asterisk-dev] Learning Asterisk Internals

Moises Silva moises.silva at gmail.com
Tue Sep 12 14:34:53 MST 2006


> what's the best way to
> learn asterisk internals?

Read the source code.

   1. A SIP call usually starts in sipsock_read(), that is a callback
function executed when the SIP socket has stuff to be read.

   2 .When a valid SIP request is read, it continues to
handle_request(), wich will perform the requested method. In the case
of a new call, this is SIP_INVITE and then the call passes to
handle_request_invite(), where the call is attended and, if
authorized, will proceed to ast_pbx_start() from pbx.c

   3. In ast_pbx_start()  the channel starts execution in a brand new
thread and the call will start to advance thorugh extensions in
extensions.conf designed context. In the case it founds a Dial()
command, the call will proceed to dial_exec() and dial_exec_full() on
apps/app_dial.c

  4. Here app_dial will create a new channel in the same thread
according to the endpoint string specified in extensions.conf Dial()
command with a call to ast_request() in channel.c

  5. In the case that the endpoint is other SIP device, the call will
proceed to to create a new SIP technology channel with a call to
sip_request_call() from chan_sip.c again

  6. Just after leaving sip_request_call(), app_dial.c code will
execute a call to ast_call() in channel.c to place the outgoing SIP
call, wich maps to sip_call() in chan_sip.c for the SIP technology.

  7. When answered, app_dial.c code will make a call to
ast_bridge_call() in res/res_features.c to connect the 2 channels (the
incoming and the outgoing) and wait for features to be dialed.

   8. ast_bridge_call() will call core function ast_channel_bridge()
in channel.c that will transmit all audio frames from the caller to
the calle and viceversa.

   9. In case that native bridge exists,  the ast_rtp_bridge(), that
is the SIP technology interface for bridging,. will be called. The
code in app_dial.c will be blocked until something breaks the bridge,
for example, some party hangs up.

   10. In hangup case, app_dial.c code will call finally ast_hangup(),
code that will call the SIP technology interface for hangup,
sip_hangup() in chan_sip.c obviously.

   11. The original channel will return to PBX extensions execution in
extensions.conf, ready to execute other commands such as Playback() or
even other Dial()

Regards.

- Moises Silva
-- 
"Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org"


More information about the asterisk-dev mailing list