Skip to content

Commit a5e9ef8

Browse files
Parse DVRIP configuration messages on port 34571/UDP
1 parent 393693f commit a5e9ef8

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

dissector/dvripWireshark.lua

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ XM_proto.fields = {
135135
DVRIP_unused_field
136136
}
137137

138+
local function udp_get_len(tvb)
139+
return tvb(4, 2):uint()
140+
end
141+
142+
local function udp_dissect_one_pdu(tvb, pinfo, tree)
143+
local json_tvb
144+
local subtree = tree:add(XM_proto, tvb(), "DVRIP Configuration Message")
145+
146+
subtree:add(DVRIP_payload_JSON_RAW, tvb(0, tvb:len()))
147+
148+
-- Decode JSON object using built-in dissector
149+
json:call(tvb, pinfo, subtree)
150+
151+
pinfo.cols.protocol = "DVRIP/JSON"
152+
pinfo.cols.info = "DVRIP Configuration Message"
153+
154+
return tvb:len()
155+
end
156+
138157
local function dvrip_get_len(tvb, pinfo, offset)
139158
-- if header is truncated, get subsequent TCP packet
140159
if tvb:len() - offset < HEADER_LEN then
@@ -171,9 +190,9 @@ local function build_protocol_tree(tvb, pinfo, subtree, payload_length)
171190
json_tvb = tvb(HEADER_LEN, tvb:len() - HEADER_LEN)
172191
subtree:add(DVRIP_payload_JSON_RAW, json_tvb, "Incomplete JSON Payload")
173192
else
174-
if tvb(HEADER_LEN + payload_length - 2, 1):le_uint() == 0x7d then
193+
if tvb(HEADER_LEN + payload_length - 2, 1):uint() == 0x7d then
175194
json_tvb = tvb(HEADER_LEN, payload_length - 1) -- last byte is newline
176-
elseif tvb(HEADER_LEN + payload_length - 1, 1):le_uint() ~= 0x0a then
195+
elseif tvb(HEADER_LEN + payload_length - 1, 1):uint() ~= 0x0a then
177196
json_tvb = tvb(HEADER_LEN, payload_length - 2) -- last 2 bytes are newline
178197
else
179198
json_tvb = tvb(HEADER_LEN, payload_length)
@@ -496,14 +515,19 @@ function XM_proto.dissector(tvb, pinfo, tree)
496515
return
497516
end
498517

499-
dissect_tcp_pdus(tvb, tree, HEADER_LEN, dvrip_get_len, dvrip_dissect_one_pdu, true)
518+
if tvb(0, 1):uint() == JSON_OPEN_BRACE then
519+
dissect_tcp_pdus(tvb, tree, 0, udp_get_len, udp_dissect_one_pdu, true)
520+
else
521+
dissect_tcp_pdus(tvb, tree, HEADER_LEN, dvrip_get_len, dvrip_dissect_one_pdu, true)
522+
end
500523
end
501524

502525
-- assigning protocol to port
503526
local tcp_table = DissectorTable.get("tcp.port")
504527
tcp_table:add(34567, XM_proto)
505528
local udp_table = DissectorTable.get("udp.port")
506529
udp_table:add(34569, XM_proto)
530+
udp_table:add(34571, XM_proto)
507531

508532
-- Create the menu entry for saving DVRIP/Sofia media streams
509533
register_menu("DVRIP Save Streams", dialog_stream_save, MENU_TOOLS_UNSORTED)

0 commit comments

Comments
 (0)