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

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


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

permanent link

answered 24 Jun '11, 18:28

helloworld's gravatar image

helloworld
3.1k42041
accept rate: 28%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×637
×431
×40
×33
×16

question asked: 24 Jun '11, 02:47

question was seen: 4,512 times

last updated: 24 Jun '11, 18:30

p​o​w​e​r​e​d by O​S​Q​A