Wireshark Dissector:IP Dissector 无法识别我的协议

Wireshark Dissector : IP Dissector does not recognize my protocol

我正在开发一个 dissector/protocol 作为网络层之上的插件,这样 IP 解析器将解析所有 IP headers 并查看 "protocol" 字段以通过有效负载到我的协议。
假设协议号是“ 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 文件夹中有这个文件,因为我把它写成一个插件。

谢谢。

让您的解析器在 "ip.proto" 解析器 table 中注册自己,并以 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() 调用)。如果您的解析器不是 "new-style" 协议,采用额外的 "data" 参数并返回 int,请使用 create_dissector_handle() 而不是 new_create_dissector_handle()