cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
850
Views
0
Helpful
1
Replies

2 LUA scripts in SIP Normalization Script

Hi,

i ve got 2 scripts

script 1

M= {}
M.allowHeaders = {"x-inin-crn"}
function M.outbound_INVITE(msg)
local location = msg:getHeaderValueParameter("Call-info", "x-cisco-loc-name")
msg:addHeader("x-inin-crn", "2000")
msg:addHeaderValueParameter("x-inin-crn", "loc", location)
end
return M

script 2

M={}
function M.inbound_INVITE(msg)
    local from = msg:getHeader("From")
    local uri = string.match(from, "sip:4920000")
    
    if uri
    then
    
    local start = string.find (from, "\"") --find the 1st quote
    local finish = string.find (from, "\"", start+1) --find the last quote. start+1 to include the quote
    local target = string.sub (from, start, finish) --display the word we want to replace
    local targetPattern = string.gsub (target, "%-", "%%-")
    local newfrom = string.gsub(from, targetPattern, '"Global Service Desk"')
    
    msg:modifyHeader("From", newfrom)
    end
end
return M

i need to have both of them in one SIP Normalization Script.

would I do this ?

O= {}
O.allowHeaders = {"x-inin-crn"}
function O.outbound_INVITE(msg)
local location = msg:getHeaderValueParameter("Call-info", "x-cisco-loc-name")
msg:addHeader("x-inin-crn", "2000")
msg:addHeaderValueParameter("x-inin-crn", "loc", location)
end
return O

M={}
function M.inbound_INVITE(msg)
    local from = msg:getHeader("From")
    local uri = string.match(from, "sip:4920000")
    
    if uri
    then
    
    local start = string.find (from, "\"") --find the 1st quote
    local finish = string.find (from, "\"", start+1) --find the last quote. start+1 to include the quote
    local target = string.sub (from, start, finish) --display the word we want to replace
    local targetPattern = string.gsub (target, "%-", "%%-")
    local newfrom = string.gsub(from, targetPattern, '"Global Service Desk"')
    
    msg:modifyHeader("From", newfrom)
    end
end
return M

Thanks

1 Reply 1

RAVIKUMAR J K
Level 1
Level 1
Hi,
I have same kind of requirement, were you able to get through this?