我正在遵循wireshark文档中给出的foo示例。
我能够构建foo代码插件。我正在使用wireshark 3.0.1版本。在workroot文件夹中,我在gryphon之前更新了目标-PLUGIN_SRC_DIRS-plugins/epan/foo。
我可以看到我的代码已构建,因为我遇到了一些编译错误,因此可以对其进行修复。
我的foo代码位于plugins/epan文件夹中。
我正在运行自定义的wireshark-sudo ./run/wireshark
令人惊讶的是,在运行的Wireshark中甚至看不到gryphon协议(protocol)字段。因此,为了测试这一点,我在该显示过滤器中输入foo或gryphon,它变成红色,并说foo既不是协议(protocol)也不是协议(protocol)字段。我正在使用Ubuntu 16.04 LTS进行构建。构建良好。
这是packet-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);
}
这是packet-foo.h
#define FOO_PORT 1234
CMakeLists.txt在这里,它实际上是狮ry的副本。
因此,我想知道是否无法识别狮ry,这意味着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-周围插入行号
插件/epan/foo
之后,执行
make
然后sudo make install
这是工作副本-
https://github.com/joshis1/WiresharkDissectorFoo
关于wireshark-dissector - 无法看到在自定义wireshark运行中编译的插件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56031487/