05-07-2018 07:35 AM
Dear, I need to make a script to modify the contact header field,
I need to remove the string "+ sip.instance =" <urn: uuid: 832028f41e6258c46e8de1e8dd3d6723360b5c74> "; reg-id = 1"
String before normalizing:
Contact: <sip: 3001@10.0.1.56: 50772>; + sip.instance = "<urn: uuid: 832028f41e6258c46e8de1e8dd3d6723360b5c74>"; reg-id = 1
String after normalizing
Contact: <sip: 3001@10.0.1.56: 50772>; q = 1
Could you help me put the script together?
Thank you very much
05-07-2018 07:57 AM
Can you confirm where you're getting q = 1?
Is that static or dependent on the reg-id value?
05-07-2018 08:01 AM
Hi Jonathan,
I need to add that value q=1 at the end of the string, is that possible? This value the constant
05-07-2018 08:04 AM
No problem, give me a few minutes
05-07-2018 08:05 AM
Excellent, thanks
05-07-2018 08:21 AM
Last question.. in what messages do you want this applied?
Invite?
Any?
Other?
And in outbound direction or inbound?
05-07-2018 08:24 AM
Hello,It is possible in the Register?
REGISTER sip:10.57.0.99 SIP/2.0
Via: SIP/2.0/UDP 10.0.1.56:50772;branch=z9hG4bK-524287-1---5987c626fa82397b;rport
Max-Forwards: 70
Contact: <sip:3001@10.0.1.56:50772>;+sip.instance="<urn:uuid:832028f41e6258c46e8de1e8dd3d6723360b5c74>";reg-id=1
Thanks
05-07-2018 08:29 AM
should work in a register message... do you want to only apply this to register?
Also, is this inbound to CUCM or outbound?
05-07-2018 08:31 AM
If only to register, and inbound to CUCM
Regards
05-07-2018 08:36 AM
ok, this should work for you:
M = {}
trace.disable()
function M.inbound_REGISTER(msg)
local contact = msg:getHeader("Contact")
if contact
then
local qval = "q = 1"
contact = contact:gsub("(.*<sip:.*>);.*", "%1" .. "; " .. qval)
trace.format("Found contact header... modifying to: %s", contact)
msg:modifyHeader ("Contact", contact)
end
end
return M
looks for contact header, if it finds it, it updates to strip out everything after <sip:.*>, and concatenates "; q = 1"
For your own knowledge, the relevant API guide for this is here:
05-07-2018 08:49 AM
Thanks, I tried it but the modification was not made.
REGISTER sip: 10.57.0.99 SIP / 2.0
Via: SIP / 2.0 / UDP 10.0.1.106:57477;branch = z9hG4bK-524287-1---f0fbbe4b26111c40;rport
Max-Forwards: 70
Contact: <sip: 3001@10.0.1.106: 57477>; + sip.instance = "<urn: uuid: 832028f41e6258c46e8de1e8dd3d6723360b5c74>"; reg-id = 1
To: "Fernando" <sip: 3001@10.57.0.99>
From: "Fernando" <sip: 3001@10.57.0.99>; tag = ae39740c
Call-ID: 75944M2YyMjNmMzIxMmE5ZTJlYTMzNGUxY2IyYzdiMDhlMDk
CSeq: 1 REGISTER
Expires: 3600
Allow: SUBSCRIBE, NOTIFY, INVITE, ACK, CANCEL, BYE, REFER, INFO, MESSAGE
Supported: outbound, path
User-Agent: X-Lite 4.8.0 75944-8638137a-W6.2
Content-Length: 0
because it can be?
05-07-2018 08:53 AM
Did you reset the SIP Trunk after applying the lua script??
Please share the SDL file. also, please enable tracing for the script on CUCM.
05-07-2018 09:15 AM
Also, just to confirm, you are applying this to a SIP Trunk? Not sure what your REGISTER flow is through the trunk.
05-07-2018 10:26 AM
05-07-2018 10:29 AM
This is what I thought. I'll have a look at the SDL trace to confirm, but I'm pretty sure that what you're trying to do is not supported. I think the Lua scripts are only available for SIP Trunks.
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