无法看到在自定义 wireshark 运行 中编译的插件?

Unable to see the plugin compiled in the custom wireshark run?

我正在按照 wireshark 文档中给出的 foo 示例进行操作。 我能够构建 foo 代码插件。我使用的是 wireshark 3.0.1 版本。在 workroot 文件夹中,我更新了目标 - PLUGIN_SRC_DIRS - plugins/epan/foo 就在 gryphon 之前。

我可以看到我的代码已构建,因为我遇到了一些我能够修复的编译错误。

我的 foo 代码位于 plugins/epan 文件夹中。 我是 运行 自定义 wireshark - sudo ./run/wireshark 令人惊讶的是,我在 运行 wireshark 中甚至看不到 gryphon 协议字段。因此,为了对此进行测试,我在该显示过滤器中键入 foo 或 gryphon,它变成红色,它说 foo 既不是协议也不是协议字段。我正在使用 Ubuntu 16.04 LTS 来构建它。构建顺利。

这里是数据包-foo.c

#include "config.h"
#include <epan/packet.h>
#include "packet-foo.h"


static int proto_foo = -1;

static int dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_);


void
proto_register_foo(void)
{
    proto_foo = proto_register_protocol (
        "FOO Protocol", /* name       */
        "FOO",      /* short name */
        "foo"       /* abbrev     */
        );
}

void
proto_reg_handoff_foo(void)
{
    static dissector_handle_t foo_handle;

    foo_handle = create_dissector_handle(dissect_foo, proto_foo);
    dissector_add_uint("udp.port", FOO_PORT, foo_handle);
}

static int
dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_)
{
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "FOO");
    /* Clear out stuff in the info column */
    col_clear(pinfo->cinfo,COL_INFO);

    return tvb_captured_length(tvb);
}

这是包裹-foo.h

#define FOO_PORT 1234

CMakeLists.txt来了,这其实是狮鹫的副本。 所以,我想知道 gryphon 是否未被识别,这意味着 foo 也不会被识别。所以,这个文件可能是问题的根源。

include(WiresharkPlugin)

# Plugin name and version info (major minor micro extra)
set_module_info(foo 0 0 4 0)

set(DISSECTOR_SRC
    packet-foo.c
)

set(PLUGIN_FILES
    plugin.c
    ${DISSECTOR_SRC}
)

set_source_files_properties(
    ${PLUGIN_FILES}
    PROPERTIES
    COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

register_plugin_files(plugin.c
    plugin
    ${DISSECTOR_SRC}
)

add_plugin_library(foo epan)

target_link_libraries(foo epan)

install_plugin(foo epan)

file(GLOB DISSECTOR_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h")
CHECKAPI(
    NAME
      foo
    SWITCHES
      -g abort -g termoutput -build
    SOURCES
      ${DISSECTOR_SRC}
      ${DISSECTOR_HEADERS}
)

仅仅改变插件是不够的。 您需要修改顶层 make 文件,以便实际安装 foo。

vim CMakeListsCustom.txt.example

首先,取消注释 - 第 16 行

 plugins/epan/foo

因为你的 foo 住在里面 plugins/epan/foo

现在,将此示例重命名为

mv CMakeListsCustom.txt.example CMakeListsCustom.txt

vim CMakeLists.txt

在1408左右插入一个行号- plugins/epan/foo

之后,做make 然后 sudo make install

这是工作副本 -

https://github.com/joshis1/WiresharkDissectorFoo