まず第一に、私はLuaにまったく慣れていません。これは、wiresharkディセクタを作成する最初の試みです。
私のプロトコルは単純です-2バイトの長さのフィールドの後にその長さの文字列が続きます。
Luaコンソールからコードを実行すると、すべてが期待どおりに機能します。
コードをWiresharkプラグインディレクトリに追加すると、エラーが発生します
Luaエラー:[string "C:\ Users ... \ AppData \ Roaming \ Wireshark ..."]:15:不正な自己に対して'add'を呼び出しています(予想される数、文字列を取得しました)
15行目は対応するt:add(f_text...
行です。
実行方法の違いを誰かが説明できますか?
do
local p_multi = Proto("aggregator","Aggregator");
local f_len = ProtoField.int16("aggregator.length","Length",base.DEC)
local f_text = ProtoField.string("aggregator.text","Text")
p_multi.fields = { f_len, f_text }
local data_dis = Dissector.get("data")
function p_multi.dissector(buf,pkt,root)
pkt.cols.protocol = "Aggregator"
local len = buf(0,2):int()
local t = root:add(p_multi,buf(0,len+2))
t:add(f_len,buf(0,2),"Length: " .. buf(0,2):int())
t:add(f_text,buf(2,len),"Text: " .. buf(2,len):string())
end
local tcp_encap_table = DissectorTable.get("tcp.port")
tcp_encap_table:add(4321,p_multi)
end