SIP Normalization Script to replace Anonymous ID and add Privacy field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 01:45 AM
Dear Colleagues,
After a CUCM implementation I have faced with a problem. The anonymous calls are not forwarded and the provider informed me that the outbound INVITE has to met for two requirements:
- The INVITE's PAI has to contain a supported phone number instead of anonymous ID
- The INVITE has to contain Privacy:ID line
I wrote a LUA script and I have added it to the SIP trunk, but it does not work, please be so kind to help me out.
M = {}
function M.outbound_INVITE(msg)
local header = msg:getHeader("From")
if string.find(header, "anonymous")
then
local oldPAI = msg:getHeader("P-Asserted-Identity")
local newPAI = string.gsub(oldPAI, "anonymous@", "+3611234567@")
msg:modifyHeader("P-Asserted-Identity", newPAI)
msg:addHeader("Privacy", "ID")
end
end
return M
Thanks in advance,
Laci
- Labels:
-
UC Manager SIP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2017 10:11 AM
I'm not sure why you have the extra step of checking the From: header. You can just grab the existing PAI if it exists, and just gsub directly. Two things:
1. you want a new header added that looks like: "Privacy: ID" ??
2. If there isn't a PAI, your script won't do anything.
Just be careful about cutting and pasting code from some text editors. Have you captured the headers before and after normalization?
M = {}
function M.outbound_INVITE(msg)
local oldPAI = msg:getHeader("P-Asserted-Identity")
if oldPAI
then
local newPAI = string.gsub(oldPAI, "anonymous@", "+3611234567@")
msg:modifyHeader("P-Asserted-Identity", newPAI)
end
msg:addHeader("Privacy", "ID")
end
return M
