Wireshark mailing list archives

Re: Lua embedded into C++


From: Kunal Thakrar <kunalthakrar () hotmail co uk>
Date: Wed, 1 Feb 2017 21:40:47 +0000

Hello,


My aim for my module is to create a web browser agnostic developer's tools, similar to Chrome and Firefox. When a user 
opens my module they will see all the current TCP conversations occurring on their system (this works in a similar way 
to the Conversation dialog). A user will be able to choose a conversation. From there I want to be able to use 
listeners to see all the packets to do with that conversation which they selected on a new GUI window, and hopefully be 
able to implement some sort of check whether there are HTTP or https packets etc.

I was going to do this all through using Lua scripts embedded into my GUI as it seems much easier to use WSLua as 
opposed to using C and C++ to create listeners (and or post dissectors).


Thanks to Pascal I was able to get this running, however, I did it in a slightly different way. Instead of using the 
WS_DLL_PUBLIC on the declare_wslua.h file (which compiled and built fine but did not register the functions to my Lua 
state). I instead used the same method of including ws_symbol_export.h in the wslua.h file and added WS_DLL_PUBLIC to 
the wslua_state() function which returned the state which Wireshark was using already (with all the Wireshark specific 
functions loaded into the state). This built and worked as expected - from here I should be able to use the Lua API to 
create the listeners etc.


Thank you two very much for taking the time out to reply!


Kind Regards,
Kunal Thakrar

________________________________
From: wireshark-dev-bounces () wireshark org <wireshark-dev-bounces () wireshark org> on behalf of Peter Wu <peter () 
lekensteyn nl>
Sent: 01 February 2017 18:48
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] Lua embedded into C++

On Wed, Feb 01, 2017 at 06:38:52PM +0100, Pascal Quantin wrote:
2017-02-01 18:18 GMT+01:00 Kunal Thakrar <kunalthakrar () hotmail co uk>:

Hi Pascal,


What I am trying to do is register the wslua functions in my Lua state in
order to create my own scripts which will be used internally as part of my
customised module. My module aims to use listeners and post dissectors to
show information similar to google chrome and firefox's developer's tools
and I feel more comfortable creating scripts using wslua as opposed to
going straight through C and C++.

 And as I explained, I cannot guarantee you that you have any chance to
have it working. We would need to get a feedback from the Wireshark
developers working on Lua.

The classes includeed with the WSLUA API are not designed to be
registered with multiple users. If you are lucky, it sometimes does not
work as expected (due to shared global variables, registrations to other
parts of the dissector APIs), if you are unlucky it will just crash.

If you are working in Lua, have you considered using the Lua API to
create menu items and use a tap listener to process packets? Docs:
https://www.wireshark.org/docs/wsdg_html_chunked/wsluarm_modules.html
Chapter 11. Wireshark’s Lua API Reference Manual<https://www.wireshark.org/docs/wsdg_html_chunked/wsluarm_modules.html>
www.wireshark.org
The classes/functions defined in this module are for using a Dumper object to make Wireshark save a capture file to 
disk. Dumper represents Wireshark’s built-in ...



https://www.wireshark.org/docs/wsdg_html_chunked/wslua_tap_example.html
10.3. Example of Listener written in Lua - Go 
Deep.<https://www.wireshark.org/docs/wsdg_html_chunked/wslua_tap_example.html>
www.wireshark.org
-- This program will register a menu that will open a window with a count of occurrences -- of every address in the 
capture local function menuable_tap() -- Declare ...




If these APIs are too limiting for your purpose, or if you still want to
invoke Lua from your scripts, perhaps you could try to clarify what you
are trying to do? Maybe there is another way.
--
Kind regards,
Peter Wu
https://lekensteyn.nl
Peter Wu "Lekensteyn"<https://lekensteyn.nl/>
lekensteyn.nl
About me. I am Peter Wu (a.k.a. Lekensteyn), CS student at the University of Technology in Eindhoven, programmer, 
Free/Libre Open Source Software enthusiast, Arch ...



___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Wireshark · Wireshark-dev Archives<https://www.wireshark.org/lists/wireshark-dev>
www.wireshark.org
For more information about the wireshark-dev mailing list see its list information page. For more information about all 
of the Wireshark mailing lists see the general ...



Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: