Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-gluster_pmap.c
blob285e653436a9c3e4f3cd9ad8ca1937305ce22c99
1 /* packet-gluster_pmap.c
2 * Routines for Gluster Portmapper and Gluster DUMP dissection
3 * Copyright 2012, Niels de Vos <ndevos@redhat.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 * References to source files point in general to the glusterfs sources.
13 * There is currently no RFC or other document where the protocol is
14 * completely described. The glusterfs sources can be found at:
15 * - http://git.gluster.com/?p=glusterfs.git
16 * - https://github.com/gluster/glusterfs
18 * The coding-style is roughly the same as the one use in the Linux kernel,
19 * see http://www.kernel.org/doc/Documentation/CodingStyle.
22 #include "config.h"
24 #include <epan/packet.h>
26 #include "packet-rpc.h"
27 #include "packet-gluster.h"
29 void proto_register_gluster_pmap(void);
30 void proto_reg_handoff_gluster_pmap(void);
31 void proto_register_gluster_dump(void);
32 void proto_reg_handoff_gluster_dump(void);
34 /* Initialize the protocol and registered fields */
35 static int proto_gluster_pmap;
36 static int proto_gluster_dump;
38 /* programs and procedures */
39 static int hf_gluster_pmap_proc;
40 static int hf_gluster_dump_proc;
42 /* fields used by multiple programs/procedures */
43 static int hf_gluster_brick;
44 static int hf_gluster_brick_status;
45 static int hf_gluster_brick_port;
46 static int hf_gluster_gfsid;
47 static int hf_gluster_progname;
48 static int hf_gluster_prognum;
49 static int hf_gluster_progver;
51 /* Initialize the subtree pointers */
52 static int ett_gluster_pmap;
53 static int ett_gluster_dump;
54 static int ett_gluster_dump_detail;
56 /* PMAP PORTBYBRICK */
57 static int
58 gluster_pmap_portbybrick_reply(tvbuff_t *tvb, packet_info *pinfo,
59 proto_tree *tree, void* data)
61 int offset = 0;
62 offset = gluster_dissect_common_reply(tvb, offset, pinfo, tree, data);
63 offset = dissect_rpc_uint32(tvb, tree, hf_gluster_brick_status, offset);
64 offset = dissect_rpc_uint32(tvb, tree, hf_gluster_brick_port, offset);
66 return offset;
69 static int
70 gluster_pmap_portbybrick_call(tvbuff_t *tvb,
71 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
73 return dissect_rpc_string(tvb, tree, hf_gluster_brick, 0, NULL);
76 /* Based on rpc/rpc-lib/src/rpc-common.c, but xdr encoding/decoding is broken.
77 * The structure in rpc/rpc-lib/src/xdr-common.h lists 2x unit64_t, but to
78 * encode/decode, xdr_u_quad_t() is used (which is uint32_t).
80 static int
81 gluster_dump_reply_detail(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
82 proto_tree *tree, void* data _U_)
84 proto_item *detail_item;
85 proto_tree *detail_tree;
86 const char *progname = NULL;
88 detail_tree = proto_tree_add_subtree(tree, tvb, offset, -1,
89 ett_gluster_dump_detail, &detail_item, "Available Program: ");
91 /* progname */
92 offset = dissect_rpc_string(tvb, detail_tree, hf_gluster_progname,
93 offset, &progname);
94 proto_item_append_text(detail_item, "%s", progname);
96 /* prognumber (marked as uint64) */
97 offset = dissect_rpc_uint64(tvb, detail_tree, hf_gluster_prognum,
98 offset);
99 /* progversion (marked as uint64) */
100 offset = dissect_rpc_uint64(tvb, detail_tree, hf_gluster_progver,
101 offset);
103 return offset;
106 static int
107 gluster_dump_reply(tvbuff_t *tvb, packet_info *pinfo,
108 proto_tree *tree, void* data)
110 int offset = 0;
112 offset = dissect_rpc_uint64(tvb, tree, hf_gluster_gfsid, offset);
113 offset = gluster_dissect_common_reply(tvb, offset, pinfo, tree, data);
115 offset = dissect_rpc_list(tvb, pinfo, tree, offset,
116 gluster_dump_reply_detail, NULL);
118 return offset;
121 /* DUMP request */
122 static int
123 gluster_dump_call(tvbuff_t *tvb, packet_info *pinfo _U_,
124 proto_tree *tree, void* data _U_)
126 return dissect_rpc_uint64(tvb, tree, hf_gluster_gfsid, 0);
129 /* GLUSTER_PMAP_PROGRAM from xlators/mgmt/glusterd/src/glusterd-pmap.c */
130 static const vsff gluster_pmap_proc[] = {
132 GF_PMAP_NULL, "NULL",
133 dissect_rpc_void, dissect_rpc_void
136 GF_PMAP_PORTBYBRICK, "PORTBYBRICK",
137 gluster_pmap_portbybrick_call, gluster_pmap_portbybrick_reply
139 { GF_PMAP_BRICKBYPORT, "BRICKBYPORT", dissect_rpc_unknown, dissect_rpc_unknown },
140 { GF_PMAP_SIGNIN, "SIGNIN", dissect_rpc_unknown, dissect_rpc_unknown },
141 { GF_PMAP_SIGNOUT, "SIGNOUT", dissect_rpc_unknown, dissect_rpc_unknown },
142 { GF_PMAP_SIGNUP, "SIGNUP", dissect_rpc_unknown, dissect_rpc_unknown },
143 { 0, NULL, NULL, NULL }
145 static const value_string gluster_pmap_proc_vals[] = {
146 { GF_PMAP_NULL, "NULL" },
147 { GF_PMAP_PORTBYBRICK, "PORTBYBRICK" },
148 { GF_PMAP_BRICKBYPORT, "BRICKBYPORT" },
149 { GF_PMAP_SIGNIN, "SIGNIN" },
150 { GF_PMAP_SIGNOUT, "SIGNOUT" },
151 { GF_PMAP_SIGNUP, "SIGNUP" },
152 { 0, NULL }
154 static const rpc_prog_vers_info gluster_pmap_vers_info[] = {
155 { 1, gluster_pmap_proc, &hf_gluster_pmap_proc }
158 /* procedures for GLUSTER_DUMP_PROGRAM */
159 static const vsff gluster_dump_proc[] = {
160 { 0, "NULL", dissect_rpc_void, dissect_rpc_void },
161 { GF_DUMP_DUMP, "DUMP", gluster_dump_call, gluster_dump_reply },
162 { 0, NULL, NULL, NULL }
164 static const value_string gluster_dump_proc_vals[] = {
165 { 0, "NULL" },
166 { GF_DUMP_DUMP, "DUMP" },
167 { 0, NULL }
169 static const rpc_prog_vers_info gluster_dump_vers_info[] = {
170 { 1, gluster_dump_proc, &hf_gluster_dump_proc }
173 void
174 proto_register_gluster_pmap(void)
176 /* Setup list of header fields See Section 1.6.1 for details */
177 static hf_register_info hf[] = {
178 /* programs */
179 { &hf_gluster_pmap_proc,
180 { "Gluster Portmap", "gluster.pmap.proc", FT_UINT32,
181 BASE_DEC, VALS(gluster_pmap_proc_vals), 0,
182 NULL, HFILL }
184 { &hf_gluster_brick,
185 { "Brick", "gluster.brick", FT_STRINGZ, BASE_NONE,
186 NULL, 0, NULL, HFILL }
188 { &hf_gluster_brick_status,
189 { "Status", "gluster.brick.status", FT_INT32, BASE_DEC,
190 NULL, 0, NULL, HFILL }
192 { &hf_gluster_brick_port,
193 { "Port", "gluster.brick.port", FT_INT32, BASE_DEC,
194 NULL, 0, NULL, HFILL }
198 /* Setup protocol subtree array */
199 static int *ett[] = {
200 &ett_gluster_pmap
203 proto_gluster_pmap = proto_register_protocol("Gluster Portmap", "Gluster Portmap", "gluster.pmap");
204 proto_register_subtree_array(ett, array_length(ett));
205 proto_register_field_array(proto_gluster_pmap, hf, array_length(hf));
208 void
209 proto_reg_handoff_gluster_pmap(void)
211 rpc_init_prog(proto_gluster_pmap, GLUSTER_PMAP_PROGRAM,
212 ett_gluster_pmap,
213 G_N_ELEMENTS(gluster_pmap_vers_info), gluster_pmap_vers_info);
216 void
217 proto_register_gluster_dump(void)
219 /* Setup list of header fields See Section 1.6.1 for details */
220 static hf_register_info hf[] = {
221 /* programs */
222 { &hf_gluster_dump_proc,
223 { "Gluster DUMP", "gluster.dump.proc", FT_UINT32,
224 BASE_DEC, VALS(gluster_dump_proc_vals), 0,
225 NULL, HFILL }
227 { &hf_gluster_progname,
228 { "Program Name", "gluster.dump.progname", FT_STRING,
229 BASE_NONE, NULL, 0, NULL, HFILL }
231 { &hf_gluster_prognum,
232 { "Program Number", "gluster.dump.prognum",
233 FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL }
235 { &hf_gluster_progver,
236 { "Program Version", "gluster.dump.progver",
237 FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL }
239 { &hf_gluster_gfsid,
240 { "GFS ID", "gluster.gfsid", FT_UINT64, BASE_HEX, NULL,
241 0, NULL, HFILL }
245 /* Setup protocol subtree array */
246 static int *ett[] = {
247 &ett_gluster_dump,
248 &ett_gluster_dump_detail
251 proto_gluster_dump = proto_register_protocol("Gluster Dump",
252 "Gluster Dump", "gluster.dump");
253 proto_register_subtree_array(ett, array_length(ett));
254 proto_register_field_array(proto_gluster_dump, hf, array_length(hf));
257 void
258 proto_reg_handoff_gluster_dump(void)
260 rpc_init_prog(proto_gluster_dump, GLUSTER_DUMP_PROGRAM,
261 ett_gluster_dump,
262 G_N_ELEMENTS(gluster_dump_vers_info), gluster_dump_vers_info);
266 * Editor modelines - https://www.wireshark.org/tools/modelines.html
268 * Local variables:
269 * c-basic-offset: 8
270 * tab-width: 8
271 * indent-tabs-mode: t
272 * End:
274 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
275 * :indentSize=8:tabSize=8:noTabs=false: