This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Help with field extractor - bad argument #1 to ‘new’

1

Hi,

I am new to lua and trying to create a tap to extract data from my dissector and do some basic stats. However I get the following error reported when I start wireshark...

Lua: Error during loading:
...\PortableWireshark_1.4.4\App\Wireshark\foo_tap.lua:2: 
bad argument #1 to 'new' (Field_new: a field with this name must exist)

Here is my code...

"init.lua"

dofile("foo_dissector.lua")
dofile("foo_tap.lua")

"foo_dissector.lua"

do
    local p_foo = Proto("foo", "p_foo")
    function p_foo.init()
    end
    local f = p_foo.fields
    f.bar = ProtoField.uint8("p_foo.bar","Foo Bar", base.DEC)
    function p_foo.dissector(tvb, pinfo, tree)
         --doing my disection stuff here
    end
    local tcp_table = DissectorTable.get("tcp.port")
    tcp_table:add(9999, p_foo)
end

"foo_tap.lua"

do
    local foobar_extractor = Field.new("p_foo.bar")
    local function foo_tap()
        local foo_tap = Listener.new(nil,"p_foo");
        local tw = TextWindow.new("FooBar Tap")
        local function remove()
            foo_tap:remove()
        end
        tw:set_atclose(remove)
        function foo_tap.packet(pinfo,tvb)
             --doing some measuring stuff here
        end
        function foo_tap.draw()
            --drawing some stuff here
        end
        function foo_tap.reset()
        end
    end  
    register_menu("FOOBAR", foo_tap, MENU_TOOLS_UNSORTED)
end

I am using wireshark portable Version 1.4.4 (SVN Rev 36110 from /trunk-1.4) Running on Windows XP Service Pack 3, build 2600

I thought all the init.lua scripts will be run before packets are read, at the end of the dissector registration process. So i expected that so long as foo_dissector.lua was loaded before foo_tap.lua then field p_foo.bar exists and should be useable as a field extractor?

asked 24 Jun '11, 02:47

mrb's gravatar image

mrb
16337
accept rate: 0%

retagged 24 Jun '11, 18:30

helloworld's gravatar image

helloworld
3.1k42041


One Answer:

1

This is a bug others have seen before. You should sign into Bugzilla to vote for its fix (I just did).

answered 24 Jun '11, 18:28

helloworld's gravatar image

helloworld
3.1k42041
accept rate: 28%