我正在为 C 中的 Wireshark 创建一个解析器,用于 UDP 之上的协议。由于我使用的是启发式剖析,但存在与我的相同端口具有标准剖析器的另一种协议,因此我的数据包被剖析为其他协议。为了让我的解析器工作,我需要启用“首先尝试启发式解析器”UDP 首选项,但我希望在注册插件时更改该属性(在代码中),因此用户不需要手动更改它。我注意到在 epan/prefs.h 上,函数prefs_set_pref存在!但是当我在我的插件上使用它时,Wireshark 在启动时崩溃并出现总线错误 10。我想做的事情可能/正确吗?
所以我试过这个:
G_MODULE_EXPORT void plugin_register(void){
prefs_set_pref("udp.try_heuristic_first:true");
// My proto_register goes here
}
由于 epan/prefs.h 有:
/*
* Given a string of the form "<pref name>:<pref value>", as might appear
* as an argument to a "-o" option, parse it and set the preference in
* question. Return an indication of whether it succeeded or failed
* in some fashion.
*
* XXX - should supply, for syntax errors, a detailed explanation of
* the syntax error.
*/
WS_DLL_PUBLIC prefs_set_pref_e prefs_set_pref(char *prefarg);
谢谢