SRISM Lua Service

Introduction

The SendRoutingInfoForSMLuaService is a service for initiating Lua scripts running within the LogicApp.

The SendRoutingInfoForSMLuaService receives a SendRoutingInfoForSM operation contained in a TCAP-RECV message from an instance of the SigtranApp which is configured to receive TCAP messages from an external client.

During the transaction, the SendRoutingInfoForSMLuaService communicates with the SigtranApp using the TCAP-SEND and TCAP-RECV messages. See the definition of the TCAP-… messages.

SRISM Scenario One (Result)

There are two typical use-cases for the SendRoutingInfoForSM Service. The first is the simple case where a request is received in TCAP BEGIN and the service completes the transaction by sending a SendRoutingInfoForSM ReturnResult in a TCAP END.

SRISM Scenario Two (Transfer/Proxy)

The second is a “Transfer” or “Proxy” scenario. In this case the service logic is not expected to know the subscriber’s current location within the network. Instead, the role of the service in this Transfer scenario is to look up a Mobile Number Portability database to determine the carrier/node responsible for this subscriber, and which can reply.

The service will transfer the SRISM request by requesting the SigtranApp to send a new TCAP BEGIN:

  1. The new TCAP BEGIN will contain an SRISM which may be identical to the original or may be modified.
  2. The new TCAP BEGIN will have a modified SCCP Called Party address (not the same as originally received).
  3. The new TCAP BEGIN will have an unmodified SCCP Calling Party address (identical as originally received).
  4. The SigtranApp will abandon the original inbound transaction.
  5. The SigtranApp will abandon the new outbound transaction.

At this point, the n2sns components are no longer involved in the transaction because:

Configuring SendRoutingInfoForSMLuaService

The SendRoutingInfoForSMLuaService is configured within a LogicApp.

    <?xml version="1.0" encoding="utf-8"?>
    <n2svcd>
      ...
      <applications>
        ...
        <application name="Logic" module="LogicApp">
          <include>
            <lib>../apps/logic/lib</lib>
          </include>
          <parameters>
            ...
          </parameters>
          <config>
            <services>
              <service module="SigtranApp::SendRoutingInfoForSMLuaService" libs="../../n2sns/apps/sigtran/lib" script_dir="../../n2sns/test/regression/set6-MAP/logic_app">
                <triggers>
                  <trigger script_key="srism_transfer"/>
                </triggers>
              </service>
            </services>
            <agents>
              ...
            </agents>
          </config>
        </application>
        ...
      </application>
      ...
    </n2svcd>

In addition to the Common LogicApp Service Configuration, note the following specific attribute notes, and service-specific attributes.

Under normal installation, the following service attributes apply:

Parameter Name Type XML Type Description
module String Attribute [Required] The module name containing the Lua Service code: SigtranApp::SendRoutingInfoForSMLuaService
libs String Element Location of the module for SendRoutingInfoForSMLuaService.
(Default: ../apps/sigtran/lib)
script_dir String Attribute [Required] The directory containing scripts used by this service.
.triggers Array Element Array of trigger elements specifying Lua scripts to run for SRISM Inbound Transactions.
.trigger Object Element Provisions a Lua script to run for a SRISM Inbound Transaction for received SendRoutingInfoForSM operations.

Script Trigger Rules

Each SRISM trigger rule defines the name of a script which is ready to handle an inbound SendRoutingInfoForSM Transaction.

Note that destination and origination addresses may contain hex digits A-F, and the matching is for destination_prefix and origination_prefix is case-insensitive.

Each trigger Object in the config.triggers Array is configured as follows.

Parameter Name Type XML Type Description
ssn 1-255 Attribute This trigger applies for only SendRoutingInfoForSM to this exact SCCP subsystem number.
(Default = Trigger applies to all SCCP subsystem numbers).
destination Hex Digits Attribute This trigger applies for only SendRoutingInfoForSM to this exact destination reference digits (in MAP Open).
(Default = Trigger applies to all SendRoutingInfoForSM).
destination_prefix Hex Digits Attribute This trigger applies for only SendRoutingInfoForSM to destination reference digits (in MAP Open) with this prefix.
(Default = Trigger applies to all SendRoutingInfoForSM).
origination Hex Digits Attribute This trigger applies for only SendRoutingInfoForSM from this exact origination reference digits (in MAP Open).
(Default = Trigger applies to all SendRoutingInfoForSM).
origination_prefix Integer Attribute This trigger applies for only SendRoutingInfoForSM from origination reference digits (in MAP Open) with this prefix.
(Default = Trigger applies to all SendRoutingInfoForSM).
script_key String Attribute The name for the Lua script to load (excluding the ".lua" or ".lc" suffix).
The script should reside in the configured script_dir directory.

Script Selection (SRISM Transaction Request)

The Lua script selection to execute for a SendRoutingInfoForSM takes into consideration the received content of the inbound TCAP_BEGIN transaction and/or the MAP content and/or the SCCP addressing information.

The destination address for matching is:

The origination address for matching is:

The message fields, e.g. msisdn_digits, serviceCentreAddress_digits are not currently available for use in script selection.

The SRISM Lua Service will iterate the configured trigger entries in the sequence in which they are configured and find the first trigger which matches the parameters of the received message.

Refer to the LogicApp configuration for more information on directories, library paths, and script caching parameters.

Script Global Variables

Scripts run with this service have access to the Common LUA Service Global Variables.

There are no service-specific global variables.

Script Entry Parameters (SRISM Request)

The Lua script defines the service processing steps, such as the following:

local n2svcd = require "n2.n2svcd"
local srism_service = require "n2.n2svcd.srism_service"

local args = ... 

-- Get the MSISDN, error if it is not present.
n2svcd.debug_var (args)

local request = args.srism

local msisdn_digits = request.msisdn_digits
if (msisdn_digits == nil) then
    return srism_service.ERROR_DATA_MISSING
end

-- Our routing is based on the last three digits.
local suffix = string.sub (msisdn_digits, #msisdn_digits - 2)

-- 203: Success with carrier HOC 1427
if (suffix == '203') then 
    return {
        imsi_digits = 1427 .. "000000000000"
    }

-- 204: Deliberate script error
elseif (suffix == '204') then 
    error ("Script Fail")

-- ERROR_ABSENT_SUBSCRIBER_SM
else 
    return srism_service.ERROR_ABSENT_SUBSCRIBER_SM
end

The service script will be executed with an args entry parameter which is an object with the following attributes:

Attribute Type Description
.remote_sccp SCCP Address Object The far-end SCCP address, as per the TCAP-RECV Message.
.local_sccp SCCP Address Object The near-end SCCP address, as per the TCAP-RECV Message.
.srism Object The decoded attributes of the SendRoutingInfoForSM operation. Some of these attributes may be optional. Site-specific protocol variants may add additional parameters not documented here.
.msisdn Binary The MSISDN (raw bytes) encoded as MAP Address String.
.msisdn_digits HEX String The decoded digits of the MSISDN address.
.msisdn_noa Integer The decoded Nature Of Address of the MSISDN address.
.msisdn_npi Integer The decoded Numbering Plan Indicator of the MSISDN address.
.sm-RP-PRI 0 / 1 The sm-RP-PRI boolean flag represented as an integer value.
.serviceCentreAddress_digits HEX String The decoded digits of the serviceCentreAddress address.
.serviceCentreAddress_noa Integer The decoded Nature Of Address of the serviceCentreAddress address.
.serviceCentreAddress_npi Integer The decoded Numbering Plan Indicator of the serviceCentreAddress address.
.gprsSupportIndicator 1 The value 1 iff the gprsSupportIndicator flag was present in the request.
.sm-RP-MTI Integer The sm-RP-MTI integer value.
.sm-RP-SMEA Binary The sm-RP-SMEA (raw bytes) encoded according to GSM 03.40.
.sm-RP-SMEA_hex HEX String A hex representation of the sm-RP-SMEA value.

Script Return Parameters (SRISM Response)

The Lua script is responsible for determing the contents of the ReturnResult for the SendRoutingInfoForSM operation, which will be sent back to the HLR and conclude the transaction.

The simplest way to do this is by the return value given back to the service at the end of script execution.

For full control over the SRISM response, the script return value may be a response object with the following attributes:

Field Type Description
response Table Container for the SRISM response parameters we are to send.
.imsi Binary The encoded bytes for the returned MNP IMSI as TBCD-Encoded bytes.
In general, you will set the imsi_digits field, and the binary TBCD value will be constructed for you.
(Default = None)
.imsi_digits HEX String The digits for the returned MNP IMSI.
(Default = None)
.locationInfoWithLMSI Table Container for the returned Location Information with LMSI to send.
(Default = None)
.networkNode-Number_digits HEX String The digits for the returned Network Node Number address.
(Default = None)
.networkNode-Number_noa Integer The Nature Of Address to encode into the returned Network Node Number address.
(Default = 0)
.networkNode-Number_npi Integer The Numbering Plan Indicator to encode into the returned Network Node Number address.
(Default = 1)
.lmsi Binary The LMSI (raw bytes) encoded into four bytes.
.lmsi_hex HEX String An alternative mechanism for specifying the LMSI by specifying the bytes in HEX format as an 8 character string.
.gprsNodeIndicator 1 Set this to 1 to request that the GPRS Node Indicator flag be set on the outgoing result.
.sm-RP-MTI Table Container for the returned Location Information with SM RP MTI to send.
(Default = None)
.msc-number Binary The encoded bytes for the MSC Number.
In general, you will set the msc-number_digits field, and the binary MAP address string will be constructed for you.
(Default = None)
.msc-number_digits HEX String The digits for the returned MSC Number address.
(Default = None)
.msc-number_noa Integer The Nature Of Address to encode into the return MSC Number address.
(Default = 0)
.msc-number_npi Integer The Numbering Plan Indicator to encode into the MSC Number address.
(Default = 1)
.sgsn-number Binary The encoded bytes for the SGSN Number.
In general, you will set the sgsn-number_digits field, and the binary MAP address string will be constructed for you.
(Default = None)
.sgsn-number_digits HEX String The digits for the returned SGSN Number address.
(Default = None)
.sgsn-number_noa Integer The Nature Of Address to encode into the return SGSN Number address.
(Default = 0)
.sgsn-number_npi Integer The Numbering Plan Indicator to encode into the SGSN Number address.
(Default = 1)

Example (returning a Table SRISM Response):

local n2svcd = require "n2.n2svcd"

local args = ...

return ({ imsi_digits = "1444000000000000" })

Alternatively, a script may return a numeric scalar value which is treated as an Error Code to be returned in ReturnError in the same way as a call to the service’s .decline method.

Example (returning an SRISM Error Code):

local n2svcd = require "n2.n2svcd"

local args = ...

-- Check the Database is online.
if (n2svcd.agent_status ("DB") <= n2svcd.STATUS_OFFLINE) then
    srism_service.ERROR_SYSTEM_FAILURE
end

...

return

Alternatively, the script may return nil in which case the SRISM transaction will be closed by sending Empty TCAP END.

Example (returning nothing):

local n2svcd = require "n2.n2svcd"

local args = ...

return nil

In this case, the transaction will be closed with an empty TCAP END to the HLR. This may or may not be something which the HLR is expected to support.

The SendRoutingInfoForSMLuaService API

The SRISM Service API can be loaded as follows.

    local srism_service = require "n2.n2svcd.srism_service"

It is not necessary to load the SRISM Service API if you are only using the simple response mechanism described above. It is only required if you wish to use any of the extended features described below, or any of the constants.

.response [Synchronous]

When a Lua script needs to perform extended processing, it may wish to send an early SRISM response before the script completes. This can be done with the response method on the SRISM Service API.

This method will send a ReturnResult for the SendRoutingInfoForSM operation, within a TCAP_END. The SRISM transaction is over. Subsequent calls to response, decline, or transfer are not permitted, and will generate a runtime script error.

The response method takes a single response parameter.

Parameter Type Description
response Table or String A Lua table with the same structure as the returned object described under "Script Return Parameters".

After the response method, the SRISM transaction is no longer in progress.

The response method returns the following object structure:

Parameter Type Description
controlled false This field is always false to indicate that the transaction is no longer under control.
reason Response / Abandon Response - The ReturnResult request was successfully sent to the SigtranApp.
Abandon - The user abandoned with TCAP ABORT or TCAP Empty END prior to the response attempt.

[Fragment] Example Early Response specifying Language:

    ...
    srism_service.response ({
        imsi_digits = subscriber_imsi,
        locationInfoWithLMSI = {
            ['networkNode-Number_digits'] = nnn_digits,
            lmsi_hex = 'ffff0123'
        }
    })

    [post-processing logic after SRISM transaction is ended]
    ...

.decline [Synchronous]

If the Lua service logic script does not wish to handle the request, it can indicate error processing by sending a ReturnError for the SendRoutingInfoForSM operation, within a TCAP_END.

The SRISM transaction is over. Subsequent calls to response, decline, or transfer are not permitted, and will generate a runtime script error.

The decline method takes a single error_code parameter.

Parameter Type Description
error_code Integer An optional custom error code.
(Default = System Failure - Error Code 34)

After the decline method, the SRISM transaction is no longer in progress.

The decline method returns the following object structure:

Parameter Type Description
controlled false This field is always false to indicate that the transaction is no longer under control.
reason Decline / Abandon Decline - The ReturnError was successfully sent to the SigtranApp.
Abandon - The user abandoned with TCAP ABORT or TCAP Empty END prior to the decline attempt.

[Fragment] Decline request using custom error code:

    ...
    srism_service.decline (srism_service.ERROR_UNKNOWN_SUBSCRIBER)

    return nil

.transfer [Synchronous]

The transfer method instructs the SigtranApp to forward/proxy the received SendRoutingInfoForSM operation to a new SCCP Called Party Address, where the following attributes will be the same as the original:

The transaction treatments is as follows:

The transfer request is sent back to the same SigtranApp which is currently controlling the transaction. That SigtranApp will perform route selection using the same rules as for a new TCAP BEGIN.

To avoid loop scenarios, the SCCP destination address you specify must be strictly different from the original SCCP called party address. Specifically:

The transfer method takes the following parameters.

Parameter Type Description
sccp_dest_address Table [Required] The new far-end SCCP address, which must specify at least .dgt_digits or .dpc/.dssn.
.dri 0 / 1 SCCP Destination Routing Indicator
(Default = Automatically Determined).
.dpc Integer SCCP Destination Point Code
(Default = Does not route on PC/SSN).
.dssn Integer SCCP Destination Subsystem Number
(Default = Does not route on PC/SSN).
.dgt_digits String SCCP Destination Global Title Digits
(Default = Does not route on GT).
.dgt_noa Integer SCCP Destination Global Title Nature of Address
(Default = Varies).
.dgt_np Integer SCCP Destination Global Title Numbering Plan
(Default = Varies).
.dgt_tt Integer SCCP Destination Global Title Translation Type
(Default = Automatically Determined).

After the transfer method, the SRISM transaction is no longer in progress.

The transfer method returns the following object structure:

Parameter Type Description
controlled false This field is always false to indicate that the transaction is no longer under control.
reason Transfer / Abandon Transfer - The transfer request was successfully sent to the SigtranApp.
Abandon - The user abandoned with TCAP ABORT or TCAP Empty END prior to the decline attempt.

[Fragment] Transaction transfer to new Global Title:

    ...
    -- Specify destination global title digits.  All other values will be set automatically.
    srism_service.transfer ({ dgt_digits = "14449990000" })

    return nil

.close [Synchronous]

The service logic may use this method to conclude the TCAP transaction without sending back a final response message. This has the same effect as returning nil from the service script.

The close method takes no parameters.

The close method returns nil.

[Fragment] Example close transaction using empty TCAP END:

    ...
    -- We wish to close the transaction immediately.
    srism_service.close ()
    ...

Again, note that this behavior may not necessarily be acceptible to the HLR.

Constants

The following SRISM constants are defined on the returned srism object.

SRISM Reason Constants

The following constants are used to indicate the reason that a SRISM interaction succeed or failed.

-- SRISM Reason Constants.
srism_service.REASON_RESPONSE = 'Response'
srism_service.REASON_DECLINE = 'Decline'
srism_service.REASON_ABANDON = 'Abandon'
srism_service.REASON_TRANSFER = 'Transfer'

SRISM Error Constants

The following constants are error code values for ReturnError as passed into the decline method.

-- SRISM Error Constants.
srism_service.ERROR_SYSTEM_FAILURE = 34
srism_service.ERROR_SRISM_NOT_ALLOWED = 49
srism_service.ERROR_DATA_MISSING = 35
srism_service.ERROR_UNEXPECTED_DATA_VALUE = 36
srism_service.ERROR_UNKNOWN_SUBSCRIBER = 1