Lua - 是否可以使用ProtoField定义结构体?

我正在尝试编写自己的解析器。

我阅读:

[1](http://csjark.readthedocs.org/en/latest/user/config.html#unknown-structs-handling):[http://www.lua.org/manual/5.1/](http://www.lua.org/manual/5.1/)和`CSjark`文档的[Unknown structs handling](http://csjark.readthedocs.org/en/latest/user/config.html#unknown-structs-handling)部分。

我没有找到使用结构的ProtoField的方法:

例如,我想为以下ICD编写解析器:

int32 syncWord
int16 size
int16 num_of_structs

strcut_1
strcut_2
....
struct_n

其中Struct具有以下成员:

int32 x
int32 y
int32 z

在构建消息时,我可以编写:

msg.syncWord= ProtoField.int32 ("myproto.syncWord", "syncWord")
msg.size= ProtoField.int16 ("myproto.size", "size")
msg.num_of_structs= ProtoField.int16 ("myproto.num_of_structs", "num_of_structs")

我的问题是如何添加结构体? 有方便的方法吗? (还是一遍又一遍地复制结构体字段?) 我找不到ProtoField的任何结构成员... 有什么建议?

点赞
用户4620646
用户4620646

在ask.wireshark.org上有一个类似的问题,并且有一个有用的回答:https://ask.wireshark.org/questions/28038/how-to-create-a-protofield-sub-array-in-lua

您可以阅读(第10章。Wireshark中的Lua支持)Wireshark解剖程序开发文档,可能会发现一些好的建议,访问:https://www.wireshark.org/docs/wsdg_html_chunked/wslua_dissector_example.html

2015-03-22 12:37:44