Appearance
Appearance
可以编写 wiretap 插件,即一种使 Wireshark 能够读取新文件格式的插件。如果你已修改 wiretap 以添加新的文件格式,并且想将其编译为插件,请在你的 wiretap 文件中添加以下部分:
#include "file_wrappers.h"/* wtap stuff */static int wf_myFileType = -1;int encap_myFileType = -1;/* Register with wtap */void wtap_register_myFileType(void) { static struct file_type_info fi = { "My File Type", "myFileType", "*.myfiletype", NULL, TRUE, NULL,NULL }; wtap_register_open_routine(myFileType_open,TRUE); // open routine in wiretap encap_myFileType = wtap_register_encap_type("My File Type","myFileType"); wf_myFileType = wtap_register_file_type(&fi); g_warning("Register");}然后在 dissector 文件中,dissector 应该注册到 wiretap 文件句柄
void proto_reg_handoff_myDissector(void){ gboolean init = FALSE; if (init == FALSE) { dissector_handle_t myDissector_handle; myDissector_handle = find_dissector("myDissector"); dissector_add("wtap_encap", encap_myFileType, myDissector_handle); init = TRUE; }}还必须修改你的插件的 Makefile.am,以允许将注册例程包含在 plugin.c 中。插件类型必须从 "plugin" 改为 "plugin_wtap",如下例所示。
plugin.c: $(DISSECTOR_SRC) $(top_srcdir)/tools/make-dissector-reg \ $(top_srcdir)/tools/make-dissector-reg.py @if test -n "$(PYTHON)"; then \ echo Making plugin.c with python ; \ $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \ plugin_wtap $(DISSECTOR_SRC) ; \ else \ echo Making plugin.c with shell script ; \ $(top_srcdir)/tools/make-dissector-reg $(srcdir) \ $(plugin_src) plugin_wtap $(DISSECTOR_SRC) ; \ fi此更改会在 plugin.c 中创建一个额外的 stanza:
G_MODULE_EXPORT voidregister_wtap_module(void){ {extern void wtap_register_myFileType (void); wtap_register_myFileType ();}}导入自 https://wiki.wireshark.org/wiretap plugin,时间为 2020-08-11 23:27:36 UTC