07-04-2019 10:36 AM
Hi there,
I want to covert a SIP Profile to SIP Normalization Script using LUA scripting.
The SIP Profile is below:
!
voice class sip-profiles 10
response ANY sip-header P-Asserted-Identity modify "<sip:(.*)@.*>" "<sip:1234@name.local>"
request ANY sip-header P-Asserted-Identity modify "<sip:(.*)@.*>" "<sip:1234@name.local>"
!
Any help will be greatly appreciated.
Thanks & Regards,
Sam
Solved! Go to Solution.
08-04-2019 04:42 PM - edited 08-04-2019 04:48 PM
The first thing I should say is, that I didn't validate this. So, please give it a try and let me know if it does or doesn't work.
Second, you're using the grouping with parenthesis in there, but for no reason, so I omitted them.
Third, I'm making the assumption that you are applying this in the outbound direction.
M = {}
local function normalize_pai(msg)
local old_pai = msg:getHeader("P-Asserted-Identity")
local new_pai = string.gsub(old_pai, "<sip:.+>", "<sip:1234@name.local>")
msg:modifyHeader("P-Asserted-Identity", new_pai)
end
M.outbound_ANY = normalize_pai
M.outbound_ANY_ANY = normalize_pai
return M
Last, I should mention that there is a method called applyNumberMask, which allows you to manipulate the user portion of the URI just like how CUCM does Transformation masks. This might be useful if you didn't want to set every call to the same PAI value, but rather, transform it.
08-04-2019 04:42 PM - edited 08-04-2019 04:48 PM
The first thing I should say is, that I didn't validate this. So, please give it a try and let me know if it does or doesn't work.
Second, you're using the grouping with parenthesis in there, but for no reason, so I omitted them.
Third, I'm making the assumption that you are applying this in the outbound direction.
M = {}
local function normalize_pai(msg)
local old_pai = msg:getHeader("P-Asserted-Identity")
local new_pai = string.gsub(old_pai, "<sip:.+>", "<sip:1234@name.local>")
msg:modifyHeader("P-Asserted-Identity", new_pai)
end
M.outbound_ANY = normalize_pai
M.outbound_ANY_ANY = normalize_pai
return M
Last, I should mention that there is a method called applyNumberMask, which allows you to manipulate the user portion of the URI just like how CUCM does Transformation masks. This might be useful if you didn't want to set every call to the same PAI value, but rather, transform it.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide