Summary:ASTERISK-15572: [patch] SIP call documentation - feel free to edit
Reporter:Moises Silva (moy)Labels:
Date Opened:2010-02-03 15:18:29.000-0600Date Closed:2017-02-13 16:34:40.000-0600
Versions:Frequency of
Environment:Attachments:( 0) sipdoc.txt
Description: 1. A SIP call usually starts in sipsock_read() in channels/chan_sip.c, 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_do(), 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() at main/pbx.c

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

 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 main/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() at channels/chan_sip.c again.

 6. Just after leaving sip_request_call(), apps/app_dial.c code will
execute a call to ast_call() at main/channel.c to place the outgoing SIP
call, which maps to sip_call() in channels/chan_sip.c for the SIP technology, which takes care of sending the INVITE to the other party.

 7. At this point the call has been placed and apps/app_dial.c will be in a loop calling ast_read() to read frames from the outgoing channel waiting for control frames to monitor the progress of the call, when answered (AST_CONTROL_ANSWER frame), apps/app_dial.c code will make a call to
ast_bridge_call() in main/features.c to connect the 2 channels (the
incoming and the outgoing).

  8. ast_bridge_call() will call core function ast_channel_bridge() which calls ast_generic_bridge() in main/channel.c that will transmit all audio frames from the caller to the callee and viceversa.

  9. In case that native bridge exists (ast_channel_bridge checks the tech->bridge function pointers of the 2 channels to see if native bridge can be done), then ast_rtp_instance_bridge() will be called for SIP/RTP native bridging, that is the SIP technology interface for bridging as defined in channels/chan_sip.c sip_tech structure. The code in app_dial.c will be blocked until something breaks the bridge (native or not), for example, some party hangs up.

  10. In the case where the originated channel hangs up, apps/app_dial.c code will call ast_hangup() in the outgoing channel, which in turns calls the SIP technology interface for hangup, sip_hangup() in channels/chan_sip.c obviously, that method takes care of sending the SIP BYE message.

  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().
Comments:By: Moises Silva (moy) 2010-02-04 08:58:43.000-0600

SIP documentation uploaded associated to my license agreement.

By: Olle Johansson (oej) 2010-02-04 09:07:07.000-0600

Thanks for going through the whole dance!

By: Leif Madsen (lmadsen) 2010-02-04 14:44:45.000-0600

This feels like it should go into doxygen.

By: Olle Johansson (oej) 2010-02-04 14:48:57.000-0600

Exactly what Russell and I have been discussing in e-mail. What an original suggestion from you :-)

By: Olle Johansson (oej) 2010-02-04 14:49:27.000-0600

I asked for this text to be submitted properly through the bug tracker so I could add it to doxygen in chan_sip.

By: Leif Madsen (lmadsen) 2010-02-04 14:51:11.000-0600

If it wasn't on the mailing list, then I couldn't have seen it. If it was, I haven't seen it as I didn't look at the mailing lists today.

By: Sean Bright (seanbright) 2017-02-13 16:07:47.261-0600

Is this still relevant? If so, I can create a doxygen patch and apply it. Otherwise, let me know so that I can close.

By: Moises Silva (moy) 2017-02-13 16:30:47.378-0600

Wow, traveling to the past. I'd imagine a significant part has changed, but no idea to what degree (particularly the bridging logic has probably changed now with bridge technologies). I submitted this here (I originally posted this to the mailing list) I think at the request from Olle, but I'd say if no one got it into doxygen in 6 years it's not important so you can close it :)

By: Sean Bright (seanbright) 2017-02-13 16:34:40.605-0600

Thanks Moises.

Olle, feel free to re-open if/when you have a patch for this issue.