cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2393
Views
2
Helpful
1
Replies

SIP Normalization Script to replace Anonymous ID and add Privacy field

Laszlo Olah
Level 1
Level 1

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

1 Reply 1

Mark Stover
Cisco Employee
Cisco Employee

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