Developer Guide for SIP Transparency and Normalization
Script Parameters API
Downloads: This chapterpdf (PDF - 327.0KB) The complete bookPDF (PDF - 1.86MB) | Feedback

Script Parameters API

Table Of Contents

Script Parameters API

getValue


Script Parameters API


Script parameters allows the script writer to obtain trunk specific configuration parameter values.

The scriptParameters library provides the following API:

getValue

getValue

getValue(parameter-name)

Given a parameter name, this function returns the value of the parameter. If a parameter with the specified name exists and has a value then its returns the same value.

If the name exists but there is no associated value, then blank string is return (i.e. "" without the double quotes). If there is no such parameter with the specified name, nil is returned.

Example: The CCA-ID parameter is configured against the SIP trunk using this script for outbound INVITEs.

Script

M = {}
local ccaid = scriptParameters.getValue("CCA-ID")
function M.outbound_INVITE(msg)
    if ccaid
    then
        local contact = msg:getHeader("Contact")
        local replace = string.format("%s;CCA-ID=%s>", "%1", ccaid)
        contact = string.gsub(contact, "(<sip:.*)>", replace)
        msg:modifyHeader("Contact", contact)
    end
end
return M

Message Before Normallization

INVITE sip:1234@10.10.10.58 SIP/2.0
. 
Contact: <sip:1000@10.10.10.1>
.

Message After Normallization
INVITE sip:1234@10.10.10.58 SIP/2.0
. 
Contact: <sip:1000@10.10.10.1;CCA-ID=LSCSUB.dsn.mil>
.