Will Lua allow me to "read in" the text from the Wireshark Filter text box?
I wish to write an app that reads whatever filte开发者_运维百科r criteria is in the Wireshark filter text box and then manipulate it using Lua. Does anyone know if that is possible? I would like to know if it is possible before I get to deep into learning Lua and using it with Wireshark.
Thanks! Joe
No, you can't read it, but you can set the filter and apply it to the current capture. See the GUI Support section in the Wireshark docs.
To set the text of the display filter textbox, use set_filter(text)
.
To apply the current text of the display filter (make it take effect), use apply_filter()
.
Avoid calling apply_filter()
from within a dissector (infinite loop can occur from re-invoking the dissector). The function is better suited in a menu action or a button action.
EDIT: To add your own get_filter()
Lua function to Wireshark's Lua API (untested):
- Add a function named
funnel_get_filter()
infunnel_stat.c
(see line 468 for example). - Add
get_filter
tofunnel_ops_t
(funnel.h:80
). - Add
funnel_get_filter
tofunnel_ops
atfunnel_stat.c:546
and attap-funnel.c:90
. Make sure you add it at the correct array index according tofunnel_ops_t
. - Copy the code below to
wslua_gui.c
and then compile:
/* TODO: Test me!! */
WSLUA_FUNCTION wslua_get_filter(lua_State* L) { /* Get the text of the display filter textbox */
const gchar* text;
text = ops->get_filter();
lua_pushstring(L,text);
WSLUA_RETURN(1); /* The display filter textbox's text. */
}
精彩评论