Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-netdump.c
blob7931144854ba256bb046310e7c2ed3c3c1f05ea7
1 /* packet-netdump.c
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
12 #include "config.h"
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[] = {
37 { 0, "COMM_NONE" },
38 { 1, "COMM_SEND_MEM" },
39 { 2, "COMM_EXIT" },
40 { 3, "COMM_REBOOT" },
41 { 4, "COMM_HELLO" },
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" },
47 { 0, NULL }
50 static const value_string reply_code_names[] = {
51 { 0, "REPLY_NONE" },
52 { 1, "REPLY_ERROR" },
53 { 2, "REPLY_LOG" },
54 { 3, "REPLY_MEM" },
55 { 4, "REPLY_RESERVED" },
56 { 5, "REPLY_HELLO" },
57 { 6, "REPLY_NR_PAGES" },
58 { 7, "REPLY_PAGE_SIZE" },
59 { 8, "REPLY_START_NETDUMP" },
60 { 9, "REPLY_END_NETDUMP" },
61 { 10, "REPLY_REGS" },
62 { 11, "REPLY_MAGIC" },
63 { 12, "REPLY_SHOW_STATE" },
64 { 0, NULL }
68 /* Code to actually dissect the packets */
69 static int
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);
88 } else {
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[] = {
104 &ett_netdump
107 static hf_register_info hf[] = {
108 { &hf_netdump_magic_number,
109 { "Netdump Magic Number", "netdump.magic",
110 FT_UINT64, BASE_HEX,
111 NULL, 0x0,
112 NULL, HFILL }
114 { &hf_netdump_seq_nr,
115 {"Netdump seq number", "netdump.seq_nr",
116 FT_UINT32, BASE_HEX,
117 NULL, 0x0,
118 NULL, HFILL}
120 { &hf_netdump_command,
121 {"Netdump command", "netdump.command",
122 FT_UINT32, BASE_DEC,
123 VALS(command_names), 0x0,
124 NULL, HFILL}
126 { &hf_netdump_from,
127 {"Netdump from val", "netdump.from",
128 FT_UINT32, BASE_HEX,
129 NULL, 0x0,
130 NULL, HFILL}
132 { &hf_netdump_to,
133 {"Netdump to val", "netdump.to",
134 FT_UINT32, BASE_HEX,
135 NULL, 0x0,
136 NULL, HFILL}
138 { &hf_netdump_code,
139 {"Netdump code", "netdump.code",
140 FT_UINT32, BASE_DEC,
141 VALS(reply_code_names), 0x0,
142 NULL, HFILL}
144 { &hf_netdump_info,
145 {"Netdump info", "netdump.info",
146 FT_UINT32, BASE_HEX,
147 NULL, 0x0,
148 NULL, HFILL}
150 { &hf_netdump_payload,
151 {"Netdump payload", "netdump.payload",
152 FT_BYTES, BASE_NONE,
153 NULL, 0x0,
154 NULL, HFILL}
156 { &hf_netdump_version,
157 {"Netdump version", "netdump.version",
158 FT_UINT8, BASE_HEX,
159 NULL, 0x0,
160 NULL, HFILL}
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
179 * Local variables:
180 * c-basic-offset: 8
181 * tab-width: 8
182 * indent-tabs-mode: t
183 * End:
185 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
186 * :indentSize=8:tabSize=8:noTabs=false: