I am using string.find api to find the location of a substring.
Looks worhen I take substring as "Forwards" it works.
function modify_content_length(msg, length)
local offset = 0
offset = string.find(msg, "Max-Forwards")
if(offset == nil) then
print("offset = " , offset)
else
print("offset = " , offset)
end
end
msg = [===["INVITE
sips:bob@biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.atlanta.example.com:5061;branch=z9hG4bK74bf9
Max-Forwards: 70
From: Alice <
sips:alice@atlanta.example.com>;tag=1234567
To: Bob <
sips:bob@biloxi.example.com>
Call-ID:
12345601@atlanta.example.comCSeq: 1 INVITE
Contact: <
sips:alice@client.atlanta.example.com>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
Supported: replaces
Content-Type: application/sdp
Content-Length:
v=0
o=alice 2890844526 2890844526 IN IP4
client.atlanta.example.com
s=
c=IN IP4
client.atlanta.example.comt=0 0
m=audio 40000 RTP/AVP 0
a=rtpmap:0 PCMU/8000
]===]
modify_content_length(msg, string.len(msg))