Location of code that converts SIP <-> IAX2 frames

Hi,

Customer is running 12.8.2 with SIP endpoints and an IAX2 trunk between the Asterisks. I am trying to find the code that modifies the SIP packet into an IAX2 frame so it can be sent to the other Asterisk and then the code that “recreates” the SIP packet from the data in the IAX2 frame. I have spent the last day reading the Asterisk 12 bridge documentation and looking through the bridge code (where it seems like it should be), but I am either overlooking it or the code lives elsewhere. Can anyone point me in the right direction?

Thanks, Wray

Bridges just exchange or mix frames. The protocol implementations are in chan_sip.c (or res_pjsip.c and other assorted files) and chan_iax2.c. They convert to Asterisk frames and operations, and vice versa.

I have spent a lot of time in chan_sip writing new functionality for the customer and haven’t seen any translation methods. Which makes me think I don’t understand how/when this translation takes place. For example there is no reference to anything iax2 in chan_sip.c The transmit_response method eventually calls down to sip_tcptls_write which writes the data to the socket. I expected, it seems incorrectly, to see something in the bridging code that says I have a SIP packet, but the trunk I have to go over is an IAX2 trunk therefore call SIP_to_IAX2 so something similar.

Thanks, Wray

That’s incorrect. Asterisk has its own ways of representing things which each channel driver implements. A channel driver does not do a direct mapping between two protocols.

Example:
When a 180 Ringing is received in chan_sip it queues an Asterisk frame called AST_CONTROL_RINGING. What reads this then forwards it to the calling channel. The calling channel takes this AST_CONTROL_RINGING frame and does what needs to be done in a protocol specific fashion. In the case of IAX2 this is add a thin wrapper and send it out. In the case of chan_sip this would be to construct a new 180 Ringing and send it out.

If you are talking media, SIP media is RTP and the modules that convert it to and from the internal format have rtp in their name.