美文网首页
Wireshark Developer’s Guide Vers

Wireshark Developer’s Guide Vers

作者: 无痕1024 | 来源:发表于2022-01-26 21:25 被阅读0次

    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"
    

    相关文章

      网友评论

          本文标题:Wireshark Developer’s Guide Vers

          本文链接:https://www.haomeiwen.com/subject/skqohrtx.html