Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wireshark Lua解剖器-如何使用水龙头?_Lua_Wireshark_Wireshark Dissector - Fatal编程技术网

Wireshark Lua解剖器-如何使用水龙头?

Wireshark Lua解剖器-如何使用水龙头?,lua,wireshark,wireshark-dissector,Lua,Wireshark,Wireshark Dissector,我想在通过lua解析器解析的自定义协议的基础上进行一些分析。所以我试着这样做 myproto_proto = Proto("myproto", "Myproto Protocol") m_dest = ProtoField.uint16("myproto.dest", "Destination", base.HEX) m_src = ProtoField.uint16("myproto.src", "Source", base.HEX) myproto_proto.fields = { sm_d

我想在通过lua解析器解析的自定义协议的基础上进行一些分析。所以我试着这样做

myproto_proto = Proto("myproto", "Myproto Protocol")
m_dest = ProtoField.uint16("myproto.dest", "Destination", base.HEX)
m_src = ProtoField.uint16("myproto.src", "Source", base.HEX)
myproto_proto.fields = { sm_dest, sm_src }

dofile(MYPROTO_PROTO_PATH.."parser.lua")

function myproto_proto.dissector(buffer, pinfo, tree)
   pinfo.cols.protocol = "MYPROTO"

   local subtree = tree:add(myproto_proto, buffer(), "Myproto Protocol Data")
   parse_msg(buffer, pinfo, subtree) -- does the actual parsing and sets the fields
end

udp_table = DissectorTable.get("udp.port")
udp_table:add(9000,myproto_proto)

-- LISTENER / TAP

f_test = Field.new("myproto.dest") -- fails because "field does not exist"
local function my_tap()
   local window = TextWindow.new("Myproto Tap")
   local tap = Listener.new(nil, "myproto")

   local counter = 0
   function remove()
      tap:remove()
   end

   window:set_atclose(remove)

   function tap.packet(pinfo, buffer)
      counter = counter + 1
   end

   function tap.draw(t)
      window:append("Counter: \t" .. counter .. "\n")
   end

   function tap.reset()
      window:clear()
      counter = 0
   end
   retap_packets()
end

register_menu("My Tap", my_tap, MENU_TOOLS_UNSORTED)
我的问题是,我无法使用字段提取器访问解析的数据。那么,我怎样才能在我的lua水龙头中获得解剖数据呢

提前感谢。

很遗憾,自定义Lua
字段
对象在OSX中不可用(它显然适用于Windows XP,但不适用于Windows 7)

有几种方法可以将数据从解剖器传递到水龙头


选项1:使用共享Lua表
  • 创建一个由数据包编号键入的全局字典(从剖析器和点击都可见的
    pinfo.number

  • 在点击中,从
    pinfo
    对象访问数据:

    print('dest', pinfo.private["dest"] ) 打印('dest',pinfo.private[“dest”])
  • XXX:只能存储字符串值


    选项3:重新分析缓冲区
  • 在tap中,调用解析器(即从
    parser.lua
    )来重新分析传递给tap的
    缓冲区中的数据
  • XXX:重复解剖器已经完成的工作(可以使X大捕获文件的处理时间加倍)

    dict[pinfo.number] = { dest = m_dest, src = m_src } print('dest', dict[pinfo.number].dest ) pinfo.private["src"] = tostring(m_src) pinfo.private["dest"] = tostring(m_dest) print('dest', pinfo.private["dest"] )