cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

324
Views
5
Helpful
1
Replies
Highlighted
Beginner

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?

Everyone's tags (2)
1 REPLY 1
Cisco Employee

Try below

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

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards