【问题标题】:Wireshark Dissector : IP Dissector does not recognize my protocolWireshark Dissector:IP Dissector 无法识别我的协议
【发布时间】:2015-06-05 09:03:21
【问题描述】:

我正在开发一个解析器/协议作为网络层之上的插件,以便 IP 解析器将解析所有 IP 标头并查看“协议”字段以将有效负载传递给我的协议。
假设协议号是“ 254 ”。

需要执行哪些步骤才能使 IP 解析器将有效负载传递给我的协议?

编辑:

我的 packet-temp.c 文件包含:

#include "config.h"

#include <epan/packet.h>


#define IP_PROTO_TEMP 254
static int proto_temp = -1;


static void dissect_temp(tvbuff_t *tvb, packet_info *pinfo, proto_tree     *tree)
{
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "TEMP");
    /* Clear out stuff in the info column */
    col_clear(pinfo->cinfo, COL_INFO);
 }

 void proto_register_temp(void)
 {
     proto_temp = proto_register_protocol (
               "TEMP Protocol", /* name       */
               "TEMP",      /* short name */
               "temp"       /* abbrev     */
               );
  }



 void proto_reg_handoff_temp(void)
{
     static dissector_handle_t temp_handle;

     temp_handle = create_dissector_handle(dissect_temp, proto_temp);
     dissector_add_uint("ip.proto", IP_PROTO_TEMP , temp_handle);
}

我在 >C:\Development\wireshark\plugins\temp 文件夹中有这个文件,因为我将它作为插件编写。

谢谢。

【问题讨论】:

    标签: wireshark wireshark-dissector


    【解决方案1】:

    让你的解析器在 "ip.proto" 解析器表中注册自己,以 254 作为键,例如:

    proto_my_protocol = proto_register_protocol("My Protocol", "MYP", "myp");
    my_handle = new_create_dissector_handle(dissect_my_protocol, proto_my_protocol);
    dissector_add_uint("ip.proto", 254, my_handle);
    

    (您可能已经在执行上述某些操作,例如proto_register_protocol() 调用)。如果您的解析器不是“新式”协议,采用额外的“数据”参数并返回int,请使用create_dissector_handle() 而不是new_create_dissector_handle()

    【讨论】:

    • 感谢@GuyHarris 的回复。我仍然无法注册协议。我看到了 ipproto.c 文件,但我在文件中看不到我的协议号(254)。当我将我的解剖器编写为插件时,它不会影响对吗?
    • 先生,我已在问题中附加了 packet-temp.c 文件。请看一下并建议我我哪里错了?谢谢。
    • 你错误地认为“ip.proto”拼写为“ip.port”。 :-) 修复该错误,即使用dissector_add_uint("ip.proto", IP_PROTO_TEMP , temp_handle); 而不是dissector_add_uint("ip.port", IP_PROTO_TEMP , temp_handle);
    • " 我看到了 ipproto.c 文件,但我在文件中看不到我的协议号 (254)。"它不必在那里。例如,Wireshark 允许您添加在 IP 上运行的新协议而无需修改 Wireshark 源本身。
    • 它不需要在那里,正如我所说的。添加它所要做的就是改变 IPv4 和 IPv6 解析器显示协议/下一个标头字段的方式。
    猜你喜欢
    • 2023-04-09
    • 1970-01-01
    • 2021-06-03
    • 1970-01-01
    • 2022-10-04
    • 2017-12-30
    • 2011-12-16
    • 2011-02-18
    相关资源
    最近更新 更多