cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
211
Views
10
Helpful
1
Replies

SIP Normalization Script assistance

Rajdeep Datta
Level 1
Level 1

Hi Everyone.

Hope you all are doing well.

I was just learning about SIP Normalization Script in my Lab Environment . I have two phone with extension 6001 and 6002 . I want to manipulate FROM header , where if i call from 6002  , it should show 60225588 . I wrote the below script and it worked.

 

M={}
function M.outbound_INVITE(msg)
local from = msg:getHeader("From") --Get FROM Header
local b = string.gsub(from, "02@", "225588@") --New FROM Header
msg:modifyHeader("From", b) --Replace FROM Header
end
return M

 

But instead of this I want that when any call comes from 60xx , it will remove xx will be replaced by a new value. So after post normalization the from number should be 60225588 only. How would I write the script ?

I know using transformation we can implement but just for learning I am looking into it.

Thanks in advance.

 

@cucmadmin 

1 Reply 1

davidn#
Cisco Employee
Cisco Employee

Hi Rajdeep,

Lua uses regex like any other scripting languages (Perl, Python). Just google for "Lua regex" for many examples.
You can use any Lua online interpreter to test your regex:
       https://replit.com/languages/lua

Hope that helps.

David

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: