Using The SDK To Create A Tsm Tunnel

The following steps provide an outline on integrating a SIP client (in this example tsc_sip_client) with the TSM SDK. Please refer to the file tsc_sip_client.c (located at sdk/apps/tsc_sip/tsc_sip_client) which contains working code references on establishing a TSM tunnel and making a SIP/RTP based call.

Initialize the TSCF-Client side API

Use the TSCF Server IP address, port, transport type, wireshark tracing and certificate parameters (if using TLS/DTLS) to initialize the client. Populate the required information in a tsc_tunnel_params type structure.

Search for "tsc_ctrl_init()" in the reference file for actual code implementation.

Initialize the TSCF-Client side API

Create a TSM Tunnel

Once initialized, create a TSM tunnel between the TSCF client and server, register for callbacks and obtain the SIP server IP address.

Search for the text "Create a tunnel" in the reference file for actual code implementation.

Create a TSM Tunnel

Create a SIP Socket within the TSM Tunnel

With the TSM tunnel established, create a SIP socket and bind the local address assigned by the TSCF server to it.

Search for the text "SIP SOCKET CREATION" in the reference file for actual code implementation.

Create a SIP Socket within the TSM Tunnel

Send SIP messages over the TSM Tunnel

You can now send SIP messages over the TSM tunnel. Based on the kind of SIP applications, you may need to send a REGISTER message or directly initiate a peer-to-peer call through an INVITE message.

You can find examples of both messages being sent by looking for the following text. Since this is only sample code, please use the same as reference for sending and receiving SIP messages via the TSM tunnel.

REGISTER TRANSACTION: Constructs and sends a REGISTER message to the tsc_sip_server. The code currently doesn’t check for a 200 OK message.

INVITE TRANSACTION: Constructs and sends an INVITE message and handles a 200 OK.

Build and send ACK (to INVITE transaction) : This code builds and sends an ACK to the INVITE received.

Send SIP messages over the TSM Tunnel

Send RTP message over the TSM Tunnel

As part of the call, there is also sample code to send and receive RTP packets over the TSM tunnel. Search for the text "RTP EXCHANGE" within the reference file for a code implementation.

The code builds RTP packets purely for the purpose of simulation.

At this point you should be able to make calls through the TSM tunnel.

Send RTP message over the TSM Tunnel

Terminate a SIP call over the TSM Tunnel

After you are done with the call, you may terminate it using sample code in the reference file. Search for the text "BYE TRANSACTION".

Terminate a TSM Tunnel

If your application has determined that it doesn’t require the use of a TSM tunnel, you may terminate the tunnel using the sample code. Search for "Finished, Socket, Tunnel Cleanup".