2 * Routines for Netdump dissection
3 * Copyright 2009, Neil Horman <nhorman@tuxdriver.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
16 void proto_register_netdump(void);
17 void proto_reg_handoff_netdump(void);
19 static dissector_handle_t netdump_handle
;
21 /* Initialize the protocol and registered fields */
22 static int proto_netdump
;
23 static int hf_netdump_magic_number
;
24 static int hf_netdump_seq_nr
;
25 static int hf_netdump_command
;
26 static int hf_netdump_from
;
27 static int hf_netdump_to
;
28 static int hf_netdump_payload
;
29 static int hf_netdump_code
;
30 static int hf_netdump_info
;
31 static int hf_netdump_version
;
33 /* Initialize the subtree pointers */
34 static int ett_netdump
;
36 static const value_string command_names
[] = {
38 { 1, "COMM_SEND_MEM" },
42 { 5, "COMM_GET_NR_PAGES" },
43 { 6, "COMM_GET_PAGE_SIZE" },
44 { 7, "COMM_START_NETDUMP_ACK" },
45 { 8, "COMM_GET_REGS" },
46 { 9, "COMM_SHOW_STATE" },
50 static const value_string reply_code_names
[] = {
55 { 4, "REPLY_RESERVED" },
57 { 6, "REPLY_NR_PAGES" },
58 { 7, "REPLY_PAGE_SIZE" },
59 { 8, "REPLY_START_NETDUMP" },
60 { 9, "REPLY_END_NETDUMP" },
62 { 11, "REPLY_MAGIC" },
63 { 12, "REPLY_SHOW_STATE" },
68 /* Code to actually dissect the packets */
70 dissect_netdump(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
72 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Netdump");
73 /* Clear out stuff in the info column */
74 col_clear(pinfo
->cinfo
, COL_INFO
);
76 if (tree
) { /* we are being asked for details */
77 proto_item
*ti
= NULL
;
78 proto_tree
*netdump_tree
= NULL
;
79 ti
= proto_tree_add_item(tree
, proto_netdump
, tvb
, 0, -1, ENC_NA
);
80 netdump_tree
= proto_item_add_subtree(ti
, ett_netdump
);
81 if (tvb_reported_length(tvb
) == 24) {
82 /* Its a request format packet */
83 proto_tree_add_item(netdump_tree
, hf_netdump_magic_number
, tvb
, 0, 8, ENC_BIG_ENDIAN
);
84 proto_tree_add_item(netdump_tree
, hf_netdump_seq_nr
, tvb
, 8, 4, ENC_BIG_ENDIAN
);
85 proto_tree_add_item(netdump_tree
, hf_netdump_command
, tvb
, 12, 4, ENC_BIG_ENDIAN
);
86 proto_tree_add_item(netdump_tree
, hf_netdump_from
, tvb
, 16, 4, ENC_BIG_ENDIAN
);
87 proto_tree_add_item(netdump_tree
, hf_netdump_to
, tvb
, 20, 4, ENC_BIG_ENDIAN
);
89 /* Its a reply packet */
90 proto_tree_add_item(netdump_tree
, hf_netdump_version
, tvb
, 0, 1, ENC_BIG_ENDIAN
);
91 proto_tree_add_item(netdump_tree
, hf_netdump_seq_nr
, tvb
, 1, 4, ENC_BIG_ENDIAN
);
92 proto_tree_add_item(netdump_tree
, hf_netdump_code
, tvb
, 5, 4, ENC_BIG_ENDIAN
);
93 proto_tree_add_item(netdump_tree
, hf_netdump_info
, tvb
, 9, 4, ENC_LITTLE_ENDIAN
);
94 proto_tree_add_item(netdump_tree
, hf_netdump_payload
, tvb
, 13, -1, ENC_NA
);
97 return tvb_captured_length(tvb
);
100 void proto_register_netdump(void)
102 /* Setup protocol subtree array */
103 static int *ett
[] = {
107 static hf_register_info hf
[] = {
108 { &hf_netdump_magic_number
,
109 { "Netdump Magic Number", "netdump.magic",
114 { &hf_netdump_seq_nr
,
115 {"Netdump seq number", "netdump.seq_nr",
120 { &hf_netdump_command
,
121 {"Netdump command", "netdump.command",
123 VALS(command_names
), 0x0,
127 {"Netdump from val", "netdump.from",
133 {"Netdump to val", "netdump.to",
139 {"Netdump code", "netdump.code",
141 VALS(reply_code_names
), 0x0,
145 {"Netdump info", "netdump.info",
150 { &hf_netdump_payload
,
151 {"Netdump payload", "netdump.payload",
156 { &hf_netdump_version
,
157 {"Netdump version", "netdump.version",
164 proto_netdump
= proto_register_protocol ("Netdump Protocol", "Netdump", "netdump" );
165 proto_register_field_array(proto_netdump
, hf
, array_length(hf
));
166 proto_register_subtree_array(ett
, array_length(ett
));
168 netdump_handle
= register_dissector("netdump", dissect_netdump
, proto_netdump
);
171 void proto_reg_handoff_netdump(void)
173 dissector_add_for_decode_as_with_preference("udp.port", netdump_handle
);
177 * Editor modelines - https://www.wireshark.org/tools/modelines.html
182 * indent-tabs-mode: t
185 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
186 * :indentSize=8:tabSize=8:noTabs=false: