# &adminguide;

## Overview

Module for updating ISUP encapsulated in SIP (SIP-T/SIP-I)

The sipt module can be used to update various ss7 headers contained inside a message.

## Dependencies

The module depends on the following modules (in other words the listed modules must be loaded before this module):

- none

## Functions

### `sipt_destination(destination, hops, nai[, terminator=1])`

updates the IAM in the body if it exists, setting the called party number to destination with the nature address specified in nai and decrementing the hop counter value if present. If the hop counter header is missing it will be added with the value of hops. If terminator is set to 1, then F will be appended to digit string to indicate the number is complete (default).

#### `sipt_destination(destination, hops, nai)` usage

    ...
    # update the destination number to our current request uri,
    # setting nature of address to international
    $rU = "19495551234";
    sipt_destination($rU, 31, 4);
    ...

### `sipt_set_bci_1(charge_indicator, called_status, called_category, e2e_indicator)`

updates the first byte of the backward call indicator in the ACM or COT in the body if setting the Charge Indicator to charge_indicator, the Called party's status indicator in called_status, the Called party's category indicator in called_category and the End to End Method Indicator with the value of the value of e2e_indicator.

#### `sipt_destination(destination, hops, nai)` usage

    ...
    # set bci for charging, subscriber free, ordinary, no e2e available
    sipt_set_bci_1("2", "1", "1", "0");
    ...

### `sipt_set_calling(origin, nai, presentation, screening)`

updates the IAM in the body if it exists, setting (or adding) the calling party number to origin with the nature address specified in nai and setting the presentation and screening values to presentation and screening.

#### `sipt_set_calling(origin, nai, presentation, screening)` usage

    ...
    # update the calling party to the value in the from header
    sipt_set_calling($fU, 4, 0, 3);
    ...

### `sipt_forwarding(origin, nai)`

updates the IAM in the body if it exists, setting (or adding) the forwarding number to origin with the nature address specified in nai.

#### `sipt_set_calling(origin, nai)` usage

    ...
    # update the forwarding number to the value in the from header
    sipt_forwarding($avp(s:forwarding_number), 3);
    ...

### `sipt_has_isup_body()`

The function returns true if the SIP message has an ISUP body attached.

#### `sipt_has_isup_body()` usage

    ...
    if(sipt_has_isup_body())
    {
        # do interesting stuff here
    }
    ...

## Exported pseudo-variables

### `$sipt(calling_party_number.presentation) / $sipt_presentation`

Returns the value of the Address presentation restricted indicator contained in the Calling Party Number header of the IAM message if it exists. Returns -1 if there isn't a Calling Party Number header.

### Address Presentation Restricted Indicator Values

0 | presentation allowed
1 | presentation restricted
2 | address not avail (national use)
3 | spare

#### `sipt_presentation pseudo-variable` usage

    ...
    # add privacy header if restriction is requested
    if($sipt(calling_party_number.presentation) == 1)
    {
    	append_hf("Privacy: id\r\n");
    	$fn = "Anonymous";
    }

    ...

### `$sipt(calling_party_number.screening) / $sipt_screening`

Returns the value of the Screening Indicator contained in the Calling Party Number header of the IAM message if it exists. Returns -1 if there isn't a Calling Party Number header.

### Screening Indicator Values

0 | Reserved (user provided, not verified)
1 | User Provided, Verified and Passed
2 | Reserved (user provided, verified and failed)
3 | Network provided

#### `sipt_screening pseudo-variable` usage

    ...

    # remove P-Asserted-Identity header if the screening isn't verified
    # or network provided
    $avp(s:screening) = $sipt(calling_party_number.screening);
    if($avp(s:screening) != 1 && $avp(s:screening) != 3)
    {
    	remove_hf("P-Asserted-Id");
    }

    ...

### `$sipt(hop_counter) / $sipt_hop_counter`

Returns the value of the Hop Counter for the IAM message if it exists. Returns -1 if there isn't a hop counter.

#### `sipt_hop_counter pseudo-variable` usage

    ...
    # get the hop counter and update the Max-Forwards header if it exists
    $avp(s:hop) = $sipt(hop_counter);
    if($avp(s:hop) > 0)
    {
    	remove_hf("Max-Forwards");
    	append_hf("Max-Forwards: $avp(s:hop)\r\n");
    }

    ...

### `$sipt(calling_party_category) / $sipt(cpc) / $sipt_cpc`

Returns the value of the Calling Party Category for the IAM message. Returns -1 if there is a parsing error.

#### `sipt_cpc pseudo-variable` usage

    ...
    # get the Cpc code and set put it in a custom sip header
    append_hf("X-CPC: $sipt(cpc)\r\n");

    ...

### `$sipt(calling_party_number.nature_of_address) / $sipt.(calling_party_number.nai) / $sipt_calling_party_nai`

Returns the value of the Nature of Address Indicator of the Calling Party for the IAM message. Returns -1 if there is a parsing error or if the Calling Party Number is not present.

### Calling Nature of Address Values

0 | Spare
1 | Subscriber Number (national use)
2 | Unknown (national use)
3 | National (significant) number (national use)
4 | International use

#### `sipt_calling_party_nai pseudo-variable` usage

    ...
    # get the Calling Nai and add country code if national
    if($sipt(calling_party_number.nai) == 3)
    {
    	$fU = "32" + "$fU";
    }

    ...

### `$sipt(calling_party_number)`

Returns the value (Address signal) of the Calling Party for the IAM message. Returns -1 if there is a parsing error or if the Calling Party Number is not present.

### `$sipt(called_party_number.nature_of_address) / $sipt(called_party_number.nai) / $sipt_called_party_nai`

Returns the value of the Nature of Address Indicator of the Called Party for the IAM message. Returns -1 if there is a parsing error.

### Called Nature of Address Values

0 | Spare
1 | Subscriber Number (national use)
2 | Unknown (national use)
3 | National (significant) number
4 | International use
5 | Network-specific number (national use)

#### `sipt_called_party_nai pseudo-variable` usage

    ...
    # get the Called Nai and add country code if national
    if($sipt(called_party_number.nai) == 3)
    {
    	$rU = "32" + "$rU";
    }

    ...

### `$sipt(called_party_number)`

Returns the value (Address signal) of the Called Party for the IAM message. Returns -1 if there is a parsing error or if the Called Party Number is not present.

### `$sipt(event_info)`

Returns the value of the Event Info header of the CPG message. Returns -1 if there is a parsing error.

### Event Info Values

0 | Spare
1 | ALERTING
2 | PROGRESS
3 | In-band information or an appropriate pattern is now available
4 | Call forward on busy
5 | Call forward on no reply
6 | Call forward unconditional

### `$sipt(backward_call_indicator.charge_indicator)`

Returns the value of the charge indication of the backward call indicator header in the ACM or COT message. Returns -1 if there is a parsing error.

### Charge Indicator Values

0 | no indication
1 | no charge
2 | charge
3 | spare

### `$sipt(redirection_info) / $sipt_redirection_info`

Returns call diversion information header from ISUP Returns "Redirecting reason" or -1 if no call diversion information found.

### Redirecting reason Values

0 | Unknown
1 | User busy
2 | PROGRESS
3 | no reply
4 | deflection during alerting
5 | deflection immediate response
6 | mobile subscriber not reachable

### `$sipt(redirection_number) / $sipt_redirection_number`

Returns number to which redirection will triggered Returns -1 if there is a parsing error.

#### `sipt_redirection_number` usage

    ...
    # get the redirection number
    $avp(s:redir_num) = $sipt(redirection_number);

    ...

### `$sipt(redirection_number.nai) / $sipt_redirection_number_nai`

Returns NAI for redirection number from ISUP Returns NAI for redirection number or -1 if no info found.

### Redirecting number NAI Values

0 | Spare
1 | Subscriber Number (national use)
2 | Unknown (national use)
3 | National (significant) number (national use)
4 | International use

### `$sipt(redirection_information.reason)`

Returns redirection reason from Redirection information from ISUP or -1 if no Redirection information found.

### `$sipt(redirection_information.original_reason)`

Returns original redirection reason from Redirection information from ISUP or -1 if no Redirection information found.

### `$sipt(redirecting_number.nai)`

Returns NAI for redirecting number from ISUP or -1 if no redirecting number found.

### `$sipt(redirecting_number)`

Returns redirecting number from ISUP or -1 if no redirecting number found.

### `$sipt(original_called_number.nai)`

Returns NAI for original called number from ISUP or -1 if no original called number found.

### `$sipt(original_called_number)`

Returns original called number from ISUP or -1 if no original called number found.

### `$sipt(generic_number.nai)`

Returns NAI for generic number from ISUP or -1 if no generic number found.

### `$sipt(generic_number)`

Returns generic number from ISUP or -1 if no generic number found.