1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
local proto = Proto("pl2303.bulk", "PL2303 Serial Data")
local ep_dir_f = Field.new("usb.endpoint_address.direction")
proto.fields.data_in = ProtoField.bytes("pl2303.bulk.data_in", "Data In")
proto.fields.data_out = ProtoField.bytes("pl2303.bulk.data_out", "Data Out")
pcall(DissectorTable.heuristic_new, "pl2303.serial_data", proto)
function proto.dissector(buffer, pinfo, tree)
if buffer:captured_len() < 1 then return end
local sub = tree:add(proto, buffer())
pinfo.cols.info:set("PL2303 Serial")
local ep_dir = ep_dir_f()() -- 0: h2d, 1: d2h
if ep_dir == 0 then
pinfo.cols.info:append(" out")
pinfo.p2p_dir = P2P_DIR_SENT
sub:add(proto.fields.data_out, buffer())
else
pinfo.cols.info:append(" in")
pinfo.p2p_dir = P2P_DIR_RECV
sub:add(proto.fields.data_in, buffer())
end
DissectorTable.try_heuristics("pl2303.serial_data", buffer, pinfo, tree)
end
function usb_protocol_key(class, subclass, protocol)
return bit.bor(
bit.lshift(1, 31),
bit.lshift(bit.band(class, 0xff), 16),
bit.lshift(bit.band(subclass, 0xff), 8),
bit.band(protocol, 0xff)
)
end
local bulk_table = DissectorTable.get("usb.bulk")
bulk_table:add(usb_protocol_key(0xff, 0x00, 0x00), proto)
bulk_table:add(0xffff, proto)
|