Internet Communications Using SIP : Delivering VoIP and Multimedia Services With Session Initiation Protocol {2Nd Ed.}

(Steven Felgate) #1
SIP CGI is an interface, not a programming language. It allows services to be
developed in familiar languages such as Perl, C, Tolol Command Language
(Tcl), and so on. Because of the similarities, SIP CGI can reuse most HTTP CGI
codes. Unlike HTTP CGI that deals exclusively with generating responses to
requests, SIP CGI can be used to generate responses and also can cause the
server to proxy requests to other locations. SIP CGI scripts are call-stateful, in
that they can correlate multiple requests corresponding to the same SIP ses-
sion. This allows a wide spectrum of SIP services to be developed using SIP
CGI. So that the server does not have to execute the script for every SIP
request, SIP CGI scripts allow the specification of a “default” action, and the
conditions under which this default action is executed.
RFC 3050 lists more than 20 metavariables that can be used by the CGI
script. In addition, the CGI script has complete access to the request SIP head-
ers and message bodies.
For example, an INVITErequest could generate the following SIP CGI
response to the SIP server:

CGI-PROXY-REQUEST sip:[email protected] SIP/2.0
Organization: MegaCarrier

SIP/2.0 100 Trying

CGI-SCRIPT-COOKIE hfkelwoeih SIP/2.0

The first line tells the server to proxy the request to the specified URI using
the metavariable CGI-PROXY-REQUEST. The second line tells the proxy to
insert the Organizationheader into the request. (The use of uppercase for
SIP CGI metavariables allows them to be easily distinguished from SIP head-
ers.) Note that the proxy knows to add a Viaheader and to do the normal
operations associated with proxying a SIP request—the script does not need to
tell the server this. The third line tells the proxy to send a 100 Trying
response back to the caller. The fourth line tells the SIP server to store a cookie
associated with this call at the SIP server using the CGI-SCRIPT-COOKIE
metavariable. If the script is reactivated for this call, this cookie would be
returned to the CGI program, allowing it to operate statelessly but still track
the progress of the session.

SIP Application Programming Interfaces


A number of SIP application programming interfaces (APIs) have been devel-
oped, including SIP servlets and JAIN. The use of APIs offers the possibility of
lower overhead than CPL and SIP CGI, since an external process does not need
to be spawned each time. API capabilities for storing state and timers are also
simpler than SIP CGI. However, a major disadvantage is that this approach is
language-dependent.

148 Chapter 7

Free download pdf