cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1346
Views
15
Helpful
4
Replies

CUCM 12 LUA SIP Normalization Script incoming FROM modify

Jason Aarons
Level 6
Level 6

I have a CallManager 12.5 SIP Normalization script where I want to prepend OY to all inbound calls on the Calling Party Name;

so if it came in From: "Jason Aarons 55901" I want it to change to From: "OY Jason Aarons 55901"

 

M={}
trace.enable()
function M.inbound_INVITE(msg)
--Adding Shipcode to inbound Calling Party Name
local from = msg:getHeader("From") --Get FROM Header
if from then
local b = from:gsub("From: \", "From: \"OY ") --New FROM Header
trace.format("From header: BEFORE: \""..from.."\"; AFTER: \""..b.."\"")
msg:modifyHeader("From", b) --Replace FROM Header
else
trace.format("No SIP From header in message.")
end
end
return M

 

++++++++++++++++++++++++

Here is the CUCM trace file showing "no change"

78017633.002 |11:57:33.032 |AppInfo |//SIP/SIPUdp/wait_SdlDataInd: Incoming SIP UDP message size 1602 from 10.169.8.10:[59854]:
[71946528,NET]
INVITE sip:19045554444@192.168.180.161:5060 SIP/2.0
Via: SIP/2.0/UDP 10.169.8.10:5060;branch=z9hG4bK18878C4
Remote-Party-ID: "Jason Aarons 55901" <sip:1016955901@10.169.8.10>;party=calling;screen=yes;privacy=off
From: "Jason Aarons 55901" <sip:1016955901@10.169.8.10>;tag=870055F-236C
To: <sip:19045554444@192.168.180.161>


78017635.000 |11:57:33.033 |SdlSig |SIPNormalizeReq |wait |SIPNormalization(2,100,184,1) |SIPHandler(2,100,183,1) |2,100,255,1.26630753^10.169.8.10^* |*TraceFlagOverrode
78017635.001 |11:57:33.033 |AppInfo |//SIP/SIPNormalization/trace_sip_message: After inbound (no change) SIP Normalization msg is:
[71946528,INT]
INVITE sip:19045554444@192.168.180.161:5060 SIP/2.0
Via: SIP/2.0/UDP 10.169.8.10:5060;branch=z9hG4bK18878C4
Remote-Party-ID: "Jason Aarons 55901" <sip:1016955901@10.169.8.10>;party=calling;screen=yes;privacy=off
From: "Jason Aarons 55901" <sip:1016955901@10.169.8.10>;tag=870055F-236C
To: <sip:19045554444@192.168.180.161>

4 Replies 4

Jason Aarons
Level 6
Level 6

If I want to change what the PSTN see for Calling Party Name should I be modifying From or Remote-Party-ID or both?

Abdurrahman
Level 1
Level 1

local b = from:gsub("From: \", "From: \"OY ") --- Double quotes is missing in this line.
local b = from:gsub("From: \"", "From: \"OY ")

still failing, updated below;

 

M={}
trace.enable()
function M.inbound_INVITE(msg)
--Adding Shipcode to inbound Calling Party Name
local from = msg:getHeader("From") --Get FROM Header

 

if from then
local b = from:gsub("From: \"", "From: \"OY ") --New FROM Header
trace.format("From header: BEFORE: \""..from.."\"; AFTER: \""..b.."\"")
msg:modifyHeader("From", b) --Replace FROM Header
else
trace.format("No SIP From header in message.")
end
end
return M

Abdurrahman
Level 1
Level 1

This line:

local b = from:gsub("From: \"", "From: \"OY ") --New FROM Header

should be:

local b = from:gsub("\"", "\"OY ",1) --New FROM Header

 

As the from variable value from msg:getHeader("From") is ""Jason Aarons 55901" <sip:1016955901@10.169.8.10>;tag=870055F-236C"

so there is no "from" in the string to match with.

 

in this line: local b = from:gsub("\"", "\"OY ",1) --it matches with the first double quotes only and replace it with the prefix you want.

 

if this helps, please rate.