Chapter 12. Appendix The Call Processing Language (CPL)

The Call Processing Language (CPL) is a language designed to describe and control Internet telephony services and provide call processing functionality. It is designed for end user service creation and is purposely limited its capabilities. It works on top of SIP or H323 and is a safe language for non-experienced users as it can only access limited resources, cannot call external programs and does not provide loops or recursion. To highlight the applicability of this language, suggestions are given below regarding possible uses of CPL scripts, including call routing, screening and logging services:

  1. Call Forward on Busy/No Answer

  2. Call Screening and Rule Based Call Processing

  3. Intelligent User Location

  4. Administrator Service Definition

[Enables administrators to devise policies for site wide telephony use]

  1. Web Middleware

  2. Sequential Call Forking (Note the SER LCR and AVPOPS module can also be utilised)

Ser.cfg

Before CPL scripts can become operational on the SER server, the ser.cfg must be modified to interpret the scripts correctly.

The cpl-c module must first be loaded by ser:

loadmodule "/opt/ser/lib/ser/modules/cpl-c.so"

Next the modules must be configured:

modparam("cpl-c", "cpl_db", "mysql://root:password@localhost/ser")

In this case "username" and "password" represent the username and password for the mysql database named ser. The entry at "localhost" should match with the server name on which the mysql database is running. ser and heslo are the default username and password.

modparam("cpl-c", "cpl_table", "cpl")

This refers to the "cpl" table which is the default table for the cpl-scripts in the database.

modparam("cpl-c", "cpl_dtd_file", "/tmp/ser-0.9.0/modules/cpl-c/cpl-06.dtd")

Pointers to the location of the CPL XML DTD file must be given (the XML DTD is necessary for parsing CPL scripts and is described in further detail later in this section).

modparam("cpl-c", "lookup_domain", "location")

This parameter should be set to "location" to let the lookup-node work correctly.

All the above parameters are mandatory. Two more parameters exist which are optional: A debugging parameter pointing to the existence of a log file and a parameter that specifies the maximum of recursive executions in CPL.

If an invite is incoming and a cpl script exists for the recipient, the default call processing is forfeited in favour of the CPL script logic.

#--------------------Call Type Processing Section---------------------#
  # if the request is for other domain use UsrLoc
  # (in case, it does not work, use the following command
  # with proper names and addresses in it)
  if (uri==myself) {

    if (method == "INVITE"){
      if(!cpl_run_script("incoming", "is_stateless"))
      {
        # script execution failed
        t_reply("500", "CPL script execution failed");
      };
      route(3);
      break;
    } else if (method == "REGISTER"){
      #handle REGISTER messages with CPL script
      cpl_process_register();
      route(2);
      break;
    };

Once the ser.cfg has been modified and SER has been restarted, issue the pstree command and two child processes should be observed:

e.g

|---rtpproxy

|---ser-+-25&[ser]

---2*[ser---ser]

Uploading a CPL Script

A CPL script can be uploaded onto SER using either the SIP REGISTER message or manually via SERs FIFO facility.

SIP REGISTER Message

A SIP REGISTER message (the message used by SIP to register a user on the network) contains the CPL script in the body/payload. When the REGISTER message reaches SER, the CPL script is retrieved from the payload and stored in the cpl table of the ser database. Thus, the CPL script resides in the SER database and will be executed when a call arrives addressed to that user. Then the script will drive the action to be taken with that call according to the requirements specified by the user in the script

CPLED, a free graphical tool, can be used for the above purpose. It includes a script transport feature whereby scripts can be downloaded, uploaded or removed via http or the SIP REGISTER method (authentication supported). For more information refer to http://www.iptel.org/products/cpled/.

Serctl FIFO Interface

To use the FIFO interface, a command similar to the following can be used:

serctl fifo LOAD_CPL user@domain /path/to/cpl/script

e.g.

serctl fifo LOAD_CPL 2000@server /opt/ser/etc/ser/cplscript.cpl.xml

Removing a CPL Script

If a user wishes to remove a particular CPL script, this can also be done using SERs FIFO facility.

serctl fifo REMOVE_CPL user@domain

What, Where, Which & How?

What does a CPL script do? - A CPL script runs in a signaling server (not protocol specific, can be SIP or H323) and controls that systems proxy, redirect or rejection actions for the set-up of a particular call. More specifically it replaces the user location functionality of a signaling server. It takes the registration information, the specifics of the call request and other external information and chooses the signaling actions to perform.

Where are CPL scripts located? - Users can have CPL scripts on any network server which their call establishment requests pass through and with which they have a trust relationship. CPL scripts can reside on SIP/H323 servers, application servers or intelligent agents.

Which party generates CPL scripts? - CPL scripts are extremely generic in their ability to be adapted to the requirements of all parties involved in a call transaction. In the most direct approach, end users can utilise CPL for describing their services. Third parties can also utilise CPL to create and/or customize services for clients, running on either servers owned by the user or the users service provider. Service administrators can also use CPL to define server service policies and it can also act as a back end for a web interface whereby service creation and customization is provided transparently to the user.

CPL scripts are usually associated with a particular Internet telephony address. Each SER user can only have one CPL script. If a new script is loaded, the previous one is overwritten. If different services are required by the same user e.g. time based routing, call screening, forward on busy etc, then these must be mixed in the same script during provisioning.

How? - Methods for CPL Script Generation

Manually

CPL scripts can be easily created by hand due to its uncomplicated syntax and similarity with HTML. Examples of such scripts are included at the end of this document.

Automated

As previously described, web middleware could be utilised to transparently provision the CPL syntax.

Graphical Tools

Graphical User Interface (GUI) tools are also available for provisioning CPL scripts. These provide inexperienced users with powerful access to CPLs functionality through a simple interface.

An example of this is CPLED, a free graphical CPL editor which was mentioned earlier in the section. It is written in JAVA and can be used as a standalone application or JAVA applet.

The XML DTD for CPL

Syntactically, CPL scripts are represented by XML documents. This is advantageous in that it makes parsing easy and parsing tools are publicly available. It is simple to understand and like HTML consists of a hierarchical structure of tags. A complete Document Type Declaration (DTD) describing the XML syntax of the CPL can be found in the /ser-0.9.0/modules/cpl-c directory and also should be called from the ser.cfg as shown earlier. It should be consulted if syntax errors are experienced uploading CPL scripts and all CPL scripts should comply with this document. The XML DTD is also provided in Appendix X.

CPL Script Examples

Call Screening a Particular Contact

This script demonstrates CPLs call screening abilities and rejects all calls received from extension 2000.

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <incoming>
    <address-switch field=”origin” subfield=”user>
     <address is=2000>
       <reject status=reject reason=I don’t take calls from extension 2000 />
      </address>
    </address-switch>
  </incoming>
</cpl>

Time-Based Switch

This script illustrates a time-based CPL script. Incoming calls received between Monday Friday and 9 a.m to 5 p.m. are proxied as normal. However if a call presents at the server outside those hours, it is directed to the users voicemail.

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <time-switch>
    <time dtstart=9 dtend=5 wkst=MO|TU|WE|TH|FR>
      <lookup source=registration>
        <success>
          <proxy />
        </success>
      </lookup>
    </time>
    <otherwise>
      <location url=sip:2000@voicemail.server.com>
        <proxy />
      </location>
    </otherwise>
  </time-switch>
</cpl>

Forward on No Answer or Busy

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <subaction id=voicemail>
  <location url=sip:2000@voicemail.server.com>
    <proxy />
  </location>
  </subaction>

  <incoming>
    <location url=sip:2000@pc.server.com>
      <proxy timeout=8>
        <busy>
          <sub ref=voicemail/>
        </busy>
        <noanswer>
          <sub ref=voicemail/>
        </noanswer>
      </proxy>
    </location>
  </incoming>
</cpl>

The above script could perhaps be modified for serial forking along the lines of the following:

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <subaction id=pda>
    <location url=sip:2000@pda.server.com>
      <proxy />
    </location>
  </subaction>

  <incoming>
    <location url=sip:2000@pc.server.com>
      <proxy timeout=8>
        <noanswer>
          <sub ref=pda/>
        </noanswer>
      </proxy>
    </location>
  </incoming>
</cpl>

Outgoing Call Screening [*]

This script illustrates how to filter outgoing calls. This script blocks an outgoing calls to premium rate numbers.

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <subaction id=pda>
    <location url=sip:2000@pda.server.com>
      <proxy />
    </location>
  </subaction>

  <incoming>
    <location url=sip:2000@pc.server.com>
      <proxy timeout=8>
        <noanswer>
          <sub ref=pda/>
        </noanswer>
      </proxy>
    </location>
  </incoming>
</cpl>

Priority and Language Routing [*]

The following example illustrates a service based a calls priority value and language settings. If the call request has a priority of urgent or higher, the default script behavior is performed. Otherwise the language field is checked for the language (Spanish) and if it is present the call is proxied to a Spanish-speaking operator, otherwise to an English-speaking operator.

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <incoming>
    <priority-switch>
      <priority greater=urgent />
      <otherwise>
        <language-switch>
          <language matches=es>
            <location url=sip:Spanish@operator.server.com>
              < proxy />
            </location>
          </language>
          <location url=sip:English@operator.server.com>
            < proxy />
          </location>
        </language-switch>
      </otherwise>
    </priority-switch>
  </incoming>
</cpl>

A More Complex Example [not verified]

In this scenario a user wants all calls directed to the terminal at his desk. If he does not answer after a certain period of time, calls from this boss are forwarded to his pda and all others are directed to his voicemail.

<?xml version=1.0 ?>
<!DOCTYPE cpl SYSTEM cpl.dtd>
<cpl>
  <location url=sip:2000@deskphone.server.com>
    <proxy timeout=8s>
      <busy>
        <location url=sip:2000@voicemail.server.com merge=clear>
          <redirect />
        </location>
      </busy>
      <noanswer>
        <string-switch field=from>
          <string matches=boss@*server.com>
            <location url=sip:2000@pda.server.com merge=clear>
              <proxy />
            </location>
          </string>
          <otherwise>
            <location url=sip:2000@voicemail.server.com merge=clear>
              <redirect />
          </otherwise>
        </string-switch>
      </noanswer>
    </proxy>
  </location>
</cpl>

References

The following documents have been referenced throughout this document and can be used as a source of further information regarding CPL.

http://www.faqs.org/rfcs/rfc2824.html

http://www1.cs.columbia.edu/~lennox/draft-ietf-iptel-cpl-00.pdf

http://www1.cs.columbia.edu/~lennox/thesis.pdf

http://lotos.site.uottawa.ca/ftp/pub/Lotos/Theses/dj_msc.pdf

http://www.denic.de/media/pdf/enum/veranstaltungen/Goertz.pdf

http://mia.ece.uic.edu/~papers/WWW/MultimediaStandards/cpl_xml.pdf