我正在 Lua 中为自定义二进制协议编写解析器。我定义了三种字段类型:
f.field1= ProtoField.bytes("myproto.field1","Field 1",base.HEX)
f.field2= ProtoField.uint16("myproto.field2","Field 2",base.HEX)
f.field3= ProtoField.bytes("myproto.field3","Field 3",base.HEX)
这些字段被添加到树中,如下所示:
subtree:add(f.field1,buf(offset,4))
offset = offset +4
val2=buf(offset,2):uint()
-- some logic around populating f2_description omitted
offset=offset+2
subtree:add(f.field2,val2):append_text(" (" ..f2_description ..")")
subtree:add(f.field3,buf(offset,2))
现在,当我打开 Wireshark 并单击解剖数据包树中的 Field1 或 Field3 时,我看到所选数据在原始数据包十六进制视图(最底部面板)中突出显示:
,但 Field2 并非如此:
我究竟做错了什么?