diff options
| author | s-ol <s+removethis@s-ol.nu> | 2024-02-18 19:17:25 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2024-02-18 19:17:25 +0000 |
| commit | eadeb98559ee1f4b896e016c598478fb0aebebcd (patch) | |
| tree | ed32f12740cd98b8a5ab40003b0156f7dac8ce5a /dissectors/pl2303.lua | |
| parent | improve wireshark dissectors (diff) | |
| download | t937-serial-eadeb98559ee1f4b896e016c598478fb0aebebcd.tar.gz t937-serial-eadeb98559ee1f4b896e016c598478fb0aebebcd.zip | |
clean up and add README
Diffstat (limited to 'dissectors/pl2303.lua')
| -rwxr-xr-x | dissectors/pl2303.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/dissectors/pl2303.lua b/dissectors/pl2303.lua new file mode 100755 index 0000000..6615166 --- /dev/null +++ b/dissectors/pl2303.lua @@ -0,0 +1,41 @@ +local proto = Proto("pl2303.bulk", "PL2303 Serial Data")
+
+local ep_dir_f = Field.new("usb.endpoint_address.direction")
+
+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")
+
+local serial_tbl = 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)
|
