cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
565
Views
5
Helpful
1
Replies

SIP Normalization Modify Header

I am trying to create a SIP Normalization Script to modify the From header if it contains sip:Anonymous@IP Address inbound over one SIP trunk.  I came up with the script below but the following error shows in the SDL log in CallManager "attempt to call method 'ModifyHeader' (a nil value)".

M = {}
function M.inbound_INVITE(msg)
    local from = msg:getHeader("From")
    local fromchange = string.gsub(from, "sip:Anonymous@", "sip:5555555555@") --Real phone number replaced for this example
    msg:ModifyHeader("From", fromchange)
end
return M

If I run the core part of the code through a LUA interpretor and print fromchange I am getting a valid value back.

Anyone have any ideas?

1 Reply 1

Mohammed Khan
Cisco Employee
Cisco Employee

Try below

M={}
function M.inbound_INVITE(msg)

changeNumber = "sip\:5555555555"
local from = msg:getHeader("From")

if string.find(string.lower(from), "sip\:anonymous")
then
local replaceHeader = string.gsub(string.lower(from), "sip\:anonymous", changeNumber)
msg:modifyHeader("From",replaceHeader)
end
end
return M