diff options
| author | s-ol <s+removethis@s-ol.nu> | 2024-02-18 19:06:51 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2024-02-18 19:06:51 +0000 |
| commit | e6d5342c2049f03a3397c7390257169310edd843 (patch) | |
| tree | aaa0ab9ae72b47939d6d58b84e884f48459413a2 /pl2303.lua | |
| parent | initial commit (diff) | |
| download | t937-serial-e6d5342c2049f03a3397c7390257169310edd843.tar.gz t937-serial-e6d5342c2049f03a3397c7390257169310edd843.zip | |
improve wireshark dissectors
Diffstat (limited to 'pl2303.lua')
| -rwxr-xr-x | pl2303.lua | 43 |
1 files changed, 19 insertions, 24 deletions
@@ -1,35 +1,30 @@ -local pl2303_bulk = Proto("pl2303.bulk", "PL2303 Serial Data")
+local proto = Proto("pl2303.bulk", "PL2303 Serial Data")
local ep_dir_f = Field.new("usb.endpoint_address.direction")
-local data_in_F = ProtoField.bytes("pl2303.bulk.data_in", "Data In")
-local data_out_F = ProtoField.bytes("pl2303.bulk.data_out", "Data Out")
+proto.fields.data_in_F = ProtoField.bytes("pl2303.bulk.data_in", "Data In")
+proto.fields.data_out_F = ProtoField.bytes("pl2303.bulk.data_out", "Data Out")
-pl2303_bulk.fields = {
- data_in_F,
- data_out_F,
-}
+local serial_tbl = DissectorTable.heuristic_new("pl2303.serial_data", proto)
-local serial_tbl = DissectorTable.heuristic_new("pl2303.serial_data", pl2303_bulk)
-
-function pl2303_bulk.dissector(buffer, pinfo, tree)
+function proto.dissector(buffer, pinfo, tree)
if buffer:captured_len() < 1 then return end
- local sub = tree:add(pl2303_bulk, buffer())
- pinfo.cols.info:set("PL2303 Serial")
+ 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(data_out_F, buffer())
+ 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(data_in_F, buffer())
- end
+ 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)
+ DissectorTable.try_heuristics("pl2303.serial_data", buffer, pinfo, tree)
end
function usb_protocol_key(class, subclass, protocol)
@@ -42,5 +37,5 @@ function usb_protocol_key(class, subclass, protocol) end
local bulk_table = DissectorTable.get("usb.bulk")
-bulk_table:add(usb_protocol_key(0xff, 0x00, 0x00), pl2303_bulk)
-bulk_table:add(0xffff, pl2303_bulk)
+bulk_table:add(usb_protocol_key(0xff, 0x00, 0x00), proto)
+bulk_table:add(0xffff, proto)
|
