解決新版 Wireshark 解析 OMCI 失敗問題

這幾天電腦重灌,也把Wireshark重新安裝並升級到新版(1.12.5),嘗試掛上OMCI Wireshark Dissector後發現爬除出來的結果異常.之前就發現在新版的Wireshark上解析OMCI出現問題但卻沒有細究,直接掛回舊版的Wireshark解決.想說還是要來找一下RootCause.

如下圖的情況,直接回彈錯誤訊息.
BinDecHexFail

比對 omci-wireshark-dissector 建議的Wireshark版本是1.4.3而lua為5.1比對一下新版的Wireshark.

下圖看起來差異就在lua從5.1升級到了5.2了,大概是API的支援更替問題.
wireshark_version

果然是string.gfind這支到了5.2就被廢止了,用string.gmatch來取代.

http://lua-users.org/lists/lua-l/2013-04/msg00117.html
> Some code that worked in Lua 5.1 croaked in the following way in 5.2:

string.gfind was part of 5.0, deprecated in 5.1, and removed in 5.2.
More precisely, string.gfind was renamed to string.gmatch in 5.1 and
that's what it is in 5.2.

修改BinDecHex.lua string.gfind to string.gmatch

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
function Hex2Bin(s)
 
-- s    -> hexadecimal string
 
local ret = ""
local i = 0
 
 
        for i in string.gfind(s, ".") do                i = string.lower(i)
 
                ret = ret..hex2bin[i].." "
 
        end
 
        return ret
end

大功告成
omci_success

refer:
http://blog.codingnow.com/2012/09/lua_52_changes.html
http://lua-users.org/lists/lua-l/2013-04/msg00117.html

Facebook Comments
Scottj Written by:

史考特 喜歡3C 愛拍照