开发者

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):

  1. Add a function named funnel_get_filter() in funnel_stat.c (see line 468 for example).
  2. Add get_filter to funnel_ops_t (funnel.h:80).
  3. Add funnel_get_filter to funnel_ops at funnel_stat.c:546 and at tap-funnel.c:90. Make sure you add it at the correct array index according to funnel_ops_t.
  4. 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. */
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜