Next you will see some configuration section(s) with instructions on how to use the entries. The entries themselves are local string values that will be used later on in the script.
The 3 most typical ones are:
Message Direction - Determines whether it is ICP Side or Set Side; default will apply to both sides
Message Type - Determines whether it is a SIP Request or Response; default will apply to both types
Method Name - Determines what Method this applies to INVITE, ACK, REGISTRATION, UPDATE, etc... default will apply to all Methods.
The next portion of a typical script will create functions that utilize the entries for Message Direction, Message Type, and Method Name so you don't need to change them at all.
After that you can and will see 'other' functions, but there will be a line that states the following, "-- real work down here..." followed by the function runMain. Below that is where the real logic of what you want to change is made and therefore where you really need to check in order to figure out how to change what you want.
So to make the script I created for Century Link I referenced the following example scripts.
-replaceParemeterInHeader.lua
-addParameterInHeader.lua
-txPassThroughHostInToHeader.lua
In the replace and add Parameter In Header scripts I reused the first configuration section that doesn't normally show up in the other example scripts. This provided me a script that is easily adjustable to change the Host portion of any Header within any Method; very flexible.
Header Name - This is the Header name that you will want to change. For me it was P-Asserted-Identity
Parameter Name - This is the paramaters name that you want to change within the Header. For me it as PAI Host
Parameter Value - This is the parameter value that you want to change the existing to. For me it was voip.centurylink.com
I kept the programming for Message Direction, Message Type, and Method Name as that just makes it easier to configure the script for what I want in the future.
Obviously you want to keep the following functions within as well.
checkDirection
checkMsgType
checkMethod
So, I then went to the Transmit Passthrough Host in the To Header script and reused some of the logic there. Since I didn't care if it was a Paired Message or not I didn't reuse that part, but the remainder of the function I did since I was looking to replace the host portion of the P-Asserted-Identity. I made a few changes to how it is written to utilize the 3 configuration parameters [HeaderName, Parameter Name, and Parameter Value] that I got from the other script, but other than that the logic is the same.
Here is all the changes I made to that logic.
if string.len(cfg_parameterValue) > 0 then
if msg:existsHeader( cfg_headerName ) ~= true then
msg:log( "runMain: error, "..cfg_headerName.." not exist in msg" )
headerName = msg:getHeader( cfg_headerName )
oldhost, err = msg:getHostInUriHeader( cfg_headerName )
msg:log( "runMain: msg has no "..cfg_parameterName.." found:"..err )
newhost = string.gsub(headerName, oldhost, cfg_parameterValue)
err = msg:removeHeader( cfg_headerName )
msg:addHeader( cfg_headerName, newhost )
msg:log("runMain: "..cfg_parameterName.." changed from ("..headerName..") to (" .. msg:getHeader( cfg_headerName ) .. ").")
msg:log("runMain: remove "..cfg_parameterName.." failed in msg: "..err)
msg:log("runMain: "..cfg_parameterName.." is null in length.")
In your case you will create two of these same scripts and just change the Header Name on one of them to To and the other to From. Change the Parameter Name on the To to To Host Address and the From to From Host Address. Lastly change the Parameter Value to corpglobal.net to replace the one that the MiVO-250 puts in there.
Now, you could take a completely different route and instead of setting up the MiVO-250 Registrar FQDN as reg-gw.sip.global you could set it to corpglobal.net and then create a single script that just changes the registration method to change the Request URI to reg-gw.sip.global instead.
Thanks,
TE