Skip to content

Commit 369b503

Browse files
committed
tcp assembling
1 parent 5b13f7a commit 369b503

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Wireshark/plugins/v2gtp.lua

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ p_v2gtp.prefs["versioninfo"] = Pref.statictext("Version " .. v2gcommon.DS_V2GSHA
3030

3131
local V2GTP_HDR_LENGTH = 8
3232

33+
local function get_v2gtp_length(buf, pktinfo, offset)
34+
return buf(offset + 4,4):uint() + V2GTP_HDR_LENGTH
35+
end
36+
3337
local f_pv = ProtoField.uint8("v2gtp.protoversion", "Protocol Version", base.HEX)
3438
local f_ipv = ProtoField.uint8("v2gtp.inverseprotoversion", "Inverse Protocol Version", base.HEX)
3539
local f_pt = ProtoField.uint16("v2gtp.payloadtype", "Payload Type", base.HEX)
@@ -77,10 +81,6 @@ p_v2gtp.fields = {f_pv, f_ipv, f_pt, f_len}
7781

7882
-- PDU dissection function
7983
local function v2gtp_pdu_dissect(buf, pinfo, root)
80-
if tostring(buf(0, 2)) ~= "01fe" then
81-
return 0
82-
end
83-
8484
local p_type_num = buf(2, 2):uint()
8585
local prev_proto = tostring(pinfo.cols.protocol)
8686

@@ -171,7 +171,17 @@ end
171171

172172
-- main dissection function
173173
function p_v2gtp.dissector(buf, pinfo, root)
174-
return v2gtp_pdu_dissect(buf, pinfo, root)
174+
-- plausibility checks
175+
if buf:len() < V2GTP_HDR_LENGTH then return 0 end
176+
if tostring(buf(0, 2)) ~= "01fe" then return 0 end
177+
178+
-- if above TCP we need to assemble the PDU
179+
if pinfo.port_type == 2 then
180+
dissect_tcp_pdus(buf, root, V2GTP_HDR_LENGTH, get_v2gtp_length, v2gtp_pdu_dissect)
181+
return buf:len()
182+
else
183+
return v2gtp_pdu_dissect(buf, pinfo, root)
184+
end
175185
end
176186

177187
-- initialization routine

0 commit comments

Comments
 (0)