cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5682
Views
1
Helpful
17
Replies

LUA Script to modify contact header

fgleanza
Level 1
Level 1

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

17 Replies 17

Jonathan Els
Level 5
Level 5

Can you confirm where you're getting q = 1?

Is that static or dependent on the reg-id value?

Hi Jonathan,

I need to add that value q=1 at the end of the string, is that possible? This value the constant

No problem, give me a few minutes

Excellent, thanks

Last question.. in what messages do you want this applied?

Invite?

Any?

Other?

And in outbound direction or inbound?

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

should work in a register message... do you want to only apply this to register?

Also, is this inbound to CUCM or outbound?

If only to register, and inbound to CUCM


Regards

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:

Developer Guide for SIP Transparency and Normalization - SIP Messages APIs [Cisco Unified Communications Manager (CallMa…

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?

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.

Also, just to confirm, you are applying this to a SIP Trunk?  Not sure what your REGISTER flow is through the trunk.

This script is associated with a sip profile that has a third-party device.

Attached the log

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.