Table Of Contents
Script Parameters API
getValue
Script Parameters API
Script parameters allows the script writer to obtain trunk specific or line specific configuration parameter values.
The scriptParameters library provides the following API:
•
getValue
getValue
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
local ccaid = scriptParameters.getValue("CCA-ID")
function M.outbound_INVITE(msg)
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)
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>