Wireshark-bugs: [Wireshark-bugs] [Bug 5575] Patch to fix memory leaks/errors in Lua plugin
Date: Fri, 14 Jan 2011 12:23:06 -0800 (PST)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5575

Robert G. Jakabosky <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #5732|                            |review_for_checkin?
               Flag|                            |

--- Comment #3 from Robert G. Jakabosky <[email protected]> 2011-01-14 12:23:04 PST ---
Created an attachment (id=5732)
 --> (https://bugs.wireshark.org/bugzilla/attachment.cgi?id=5732)
Fix memory errors, Lua call-stack unwinding, and Lua tap data support. v3

I have added support for attaching a lua value (like a table) to a packet that
can be accessing in a tap.

Now a lua dissector can pass info about a dissected packet to any tap listening
for that packet.  This patch added a tap type "lua" which has this structure
for data:

struct _wslua_tap_data {
  lua_State *L;
  int data_ref;
};
typedef struct _wslua_tap_data* TapData;

The "data_ref" field is a lua reference that can be accessed with:
TapData tap_data = (TapData)p;
lua_rawgeti(tap_data->L, LUA_REGISTRYINDEX, tap_data->packet_ref);

Lua tap listeners will receive the tap_data as the forth parameter to the
"packet" callback function.  Also I add the "proto_tree" value as the third
parameter to the "packet" callback.
So the Lua tap listener's "packet" callback now receive 4 parameters:
tap.packet(pinfo, tvb, tree, tapdata)
end

A Lua dissector set the tap_data on a packet with:
pinfo.tap_data = {} -- any lua value is valid here.

The tap data can also be read:
local data = pinfo.tap_data

When registering a tap listener you need to request tap_type "lua" to receive
any value from the Lua dissector.

The reason I added support for tap_data is that I couldn't find simple way to
get information from the proto_tree that my Lua dissector had added.

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.