Wireshark Developer’s Guide Version 3.7.0 --- README.plugins

0. Plugins

There are a multitude of plugin options available in Wireshark that allow to extend its functionality without changing the source code itself. Using the available APIs gives you the means to do this.
Wireshark中有许多插件选项,允许在不更改源代码的情况下扩展其功能。使用可用的API可以实现这一点。

Currently plugin APIs are available for dissectors (epan), capture file types (wiretap) and media decoders (codecs). This README focuses primarily on dissector plugins; most of the descriptions are applicable to the other plugin types as well.
目前插件API可用于dissectors(epan)、捕获文件类型(wiretap)和媒体解码器(codecs)。本README主要关注dissector插件;大多数描述也适用于其他插件类型。

1. Dissector plugins

Writing a "plugin" dissector is not very different from writing a standard one. In fact all of the functions described in README.dissector can be used in the plugins exactly as they are used in standard dissectors.
(Note, however, that not all OSes on which Wireshark runs can support plugins.)
编写插件与编写标准dissector并没有太大区别。事实上,文件中描述的所有函数都可以在插件中使用,就像在标准dissector中使用一样。
(但请注意,并非所有运行Wireshark的操作系统都支持插件。)

If you've chosen "foo" as the name of your plugin (typically, that would be a short name for your protocol, in all lower case), the following instructions tell you how to implement it as a plugin. All occurrences of "foo" below should be replaced by the name of your plugin.
如果您选择“foo”作为插件的名称(通常,它是协议的简称,小写),下面的说明将告诉您如何将其作为插件实现。下面出现的所有“foo”都应该替换为插件的名称。

  1. The directory for the plugin, and its files

The plugin should be placed in a new plugins/epan/foo directory which shouldcontain at least the following files:
插件应放在新的plugins/epan/foo目录中,该目录应至少包含以下文件:
CMakeLists.txt
README

The README can be brief but it should provide essential information relevant to developers and users. Optionally AUTHORS and ChangeLog files can be added.
Optionally you can add your own plugin.rc.in.
README可以很简短,但它应该提供与开发人员和用户相关的基本信息。可选添加AUTHORS和ChangeLog文件。
可选添加自己的plugin.rc.in。

And of course the source and header files for your dissector.
Examples of these files can be found in plugins/epan/gryphon.
当然还有dissector的源文件和头文件。
这些文件的示例可以在plugins/epan/gryphon中找到。

2.1 CMakeLists.txt
For your plugins/epan/foo/CMakeLists.txt file, see the corresponding file in plugins/epan/gryphon. Replace all occurrences of "gryphon" in those files with "foo" and add your source files to the DISSECTOR_SRC variable.
对于plugins/epan/foo/CMakeLists.txt文件,请参阅plugins/epan/gryphon中的相应文件。将这些文件中出现的所有“gryphon”替换为“foo”,并将源文件添加到DISSECTOR_SRC变量中。

2.2 plugin.rc.in
Your plugins/epan/foo/plugin.rc.in is the Windows resource template file used to add the plugin specific information as resources to the DLL.
If not provided the plugins/plugin.rc.in file will be used.
plugins/epan/foo/plugin.rc.in是Windows资源模板文件,用于将插件特定信息作为资源添加到DLL的。
如果没有提供,将使用plugins/plugin.rc.in文件。

  1. Changes to existing Wireshark files

There are two ways to add your plugin dissector to the build, as a custom extension or as a permanent addition. The custom extension is easy to configure, but won't be used for inclusion in the distribution if that's your goal. Setting up the permanent addition is somewhat more involved.
有两种方法可以将插件dissector添加到构建中,作为自定义扩展或永久添加。自定义扩展很容易配置,但如果这是您的目标,则不会包含在发行版中。设置永久性添加稍微复杂一些。

3.1 Custom extension
For CMake builds, either pass the custom plugin dir on the CMake generation step command line:
对于CMake构建,在CMake生成步骤命令行上传递自定义插件目录:
CMake ... -DCUSTOM_PLUGIN_SRC_DIR="plugins/epan/foo"

or copy the top-level file CMakeListsCustom.txt.example to CMakeListsCustom.txt (also in the top-level source dir) and edit so that CUSTOM_PLUGIN_SRC_DIR is set() to the relative path of your plugin, e.g.
或者复制顶级文件CMakeListsCustom.txt.example到CMakeListsCustom.txt(也在顶级源目录中)并进行编辑,以便将CUSTOM_PLUGIN_SRC_DIR设置set() 为插件的相对路径,例如:
set(CUSTOM_PLUGIN_SRC_DIR plugins/epan/foo)

and re-run the CMake generation step.
To build the plugin, run your normal Wireshark build step.
然后重新运行CMake生成步骤。
要构建插件,请运行正常的Wireshark构建步骤。

If you want to add the plugin to your own Windows installer add a text file named custom_plugins.txt to the packaging/nsis directory, with a "File" statement for NSIS:
如果要将插件添加到自己的Windows安装程序中,请添加一个名为custom_plugins.txt的文本文件到packaging/nsis目录,并带有NSIS的“File”语句:

File "${STAGING_DIR}\plugins\${VERSION_MAJOR}.${VERSION_MINOR}\epan\foo.dll"
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,753评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,668评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,090评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,010评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,054评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,806评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,484评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,380评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,873评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,021评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,158评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,838评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,499评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,044评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,159评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,449评论 3 374
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,136评论 2 356

推荐阅读更多精彩内容