cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
8775
Views
0
Helpful
7
Replies

SIP Normalization Script to modify FROM header

Robert Craig
Level 3
Level 3

Hello. I'm looking to remove and replace the FROM header as the invite ingresses from Skype for Business into CUCM. Would the below script accomplish this? The invite currently just says "first.last@test.com:10.1.1.1". I'm looking to replace it with a phone number so its routable. Any help is appreciated.

Robert

M={}

function M.outbound_INVITE(msg)

    local from = msg:getHeader("FROM")  --Get FROM Header

    local b = string.gsub(from, "(<sip:.+@)", "<sip:5551112222")  --New FROM Header

    msg:modifyHeader("From", b)  --Replace FROM Header

end

return M

1 Accepted Solution

Accepted Solutions

Mark Stover
Cisco Employee
Cisco Employee

Hi Robert,

Since the SIP INVITE is being received by Unified CM from S4B, it is an "inbound_INVITE" from the perspective of SIP Normalization.

BTW, There's a couple other minor tweaks I would make to your above...

M={}

function M.outbound_INVITE(msg)

  local from = msg:getHeader("From")  --Get FROM Header

  local b = string.gsub(from, "<sip:.+@", "<sip:5551112222@")  --New FROM Header

  msg:modifyHeader("From", b)  --Replace FROM Header

end

return M


I always use header names using a format of "From" rather than "FROM".

Since you aren't trying to 'capture' what you matched, the () in your match string aren't needed.

View solution in original post

7 Replies 7

Geevarghese Cheria
Cisco Employee
Cisco Employee

Hi Robert,

  Have moved your question under UC Manager SIP community. Please refer this url for related information

https://communities.cisco.com/thread/73584?start=0&tstart=0

Thanks and Regards,

Geevarghese

Mark Stover
Cisco Employee
Cisco Employee

Hi Robert,

Since the SIP INVITE is being received by Unified CM from S4B, it is an "inbound_INVITE" from the perspective of SIP Normalization.

BTW, There's a couple other minor tweaks I would make to your above...

M={}

function M.outbound_INVITE(msg)

  local from = msg:getHeader("From")  --Get FROM Header

  local b = string.gsub(from, "<sip:.+@", "<sip:5551112222@")  --New FROM Header

  msg:modifyHeader("From", b)  --Replace FROM Header

end

return M


I always use header names using a format of "From" rather than "FROM".

Since you aren't trying to 'capture' what you matched, the () in your match string aren't needed.

OK, thank you very much!

Robert

Hi. Is there a way to modify this script to capture From header "unknown" or "anonymous" and change it to say +1234567890 under the same script?

Hi,

Do you want the script to change it on outbound direction or inbound direction? It's straightforward if you want to add an inbound section. You just need a corresponding:

M.inbound_INVITE(msg)

    ...

end

before the "return M"

HI. I know how to change directions. What I’m not sure is how to make the script change the From header based on multiple “From” header values like Unknown, anonymous and Restricted.

Hello Mark,

Can we have inbound and outbound in the same script, Inbound script is working but when it comes to outbound, it still displaying the messages, which we dont want. Outbound call is made by the CCB funtionality.

M = {}
function M.inbound_ANY(msg)
local from = msg:getHeader("Remote-Party-ID")
if (from ~= nil) then
from = string.gsub(from, "--CVP[_0-9]*", "")
msg:modifyHeader("Remote-Party-ID", from )
end
end
function M.outbound_ANY_ANY(msg)
local from = msg:getHeader("Remote-Party-ID")
if (from ~= nil) then
from = string.gsub(from, "--CVP[_0-9]*", "")
msg:modifyHeader("Remote-Party-ID", from )
end
end
return M

Can you let us know if that work ?