在 USB 协议上添加解析器

Add a dissector on USB protocol

我目前正在研究自制的 USB 协议,以了解 wireshark 中的解析器。

我已经用 Lua 编写了我的解析器并将其添加到 wireshark 但我并不真正了解解析器 table 尤其是如何应用我自制的协议。 这是我的代码:

rssi_protocol = Proto("RSSI", "RSSI protocol")
header = ProtoField.ubytes("rssi.header", "Header", base.NONE)
Rx = ProtoField.uint8("rssi.rx", "Reception time", base.HEX)
Tx = ProtoField.uint8("rssi.tx", "Transmission time", base.HEX)
Power = ProtoField.uint8("rssi.power", "Power Attenuation", base.HEX)
RSSI1 = ProtoField.uint8("rssi.1", "First RSSI", base.HEX)
RSSI2 = ProtoField.uint8("rssi.2", "Second RSSI", base.HEX)
RSSI3 = ProtoField.uint8("rssi.3", "Third RSSI", base.HEX)
rssi_protocol.fields = {header, Rx, Tx, Power, RSSI1, RSSI2, RSSI3}

function rssi_protocol.dissector(buffer, pinfo, tree)
    length = buffer:len()
    if length == 0 then return end

    pinfo.cols.protocol = rssi_protocol.name

    local subtree = tree:add(rssi_protocol, buffer(), "RSSI Protocol Data")

    subtree.add(header, buffer(0, 19))
    subtree.add(Rx, buffer(19, 1))
    subtree.add(Tx, buffer(20,1))
    subtree.add(Power, buffer(21,1))
    subtree.add(RSSI1, buffer(22, 1))
    subtree.add(RSSI2, buffer(23,1))
    subtree.add(RSSI3, buffer(24,1))

    end

DissectorTable.get(<TABLE>)add(<VALUE>, rssi_protocol) 

还有wireshark

我希望我的协议能够解释红色选择。而且我不知道应该使用哪个 DissectorTable 来计算该部分。有什么想法吗?

这可能是相关的,我在虚拟机上工作并跟踪 usbmon2 以获取我的数据。

干杯。

好的,我知道我做错了什么。 我认为解析器 table 与我们在选择字段时可以在页脚中看到的信息相关,例如 usb.bus_id 或 usb.unused_setup_header。不是。

我终于在新的 wireshark 版本中找到了菜单 View -> Internal -> Dissector table,它为我们提供了所有可用的 dissector。