Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-rquota.c
blob1fc99d4cd67ba84ffbce19abae7a3b9a74de6e4f
1 /* packet-rquota.c
2 * Routines for rquota dissection
3 * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Copied from packet-ypxfr.c
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
16 #include <epan/packet.h>
17 #include <epan/tfs.h>
18 #include <wsutil/array.h>
19 #include "packet-rpc.h"
21 void proto_register_rquota(void);
22 void proto_reg_handoff_rquota(void);
24 static int proto_rquota;
25 static int hf_rquota_procedure_v1;
26 static int hf_rquota_procedure_v2;
27 static int hf_rquota_pathp;
28 static int hf_rquota_uid;
29 static int hf_rquota_type;
30 static int hf_rquota_id;
31 static int hf_rquota_status;
32 static int hf_rquota_rquota;
33 static int hf_rquota_bsize;
34 static int hf_rquota_active;
35 static int hf_rquota_bhardlimit;
36 static int hf_rquota_bsoftlimit;
37 static int hf_rquota_curblocks;
38 static int hf_rquota_fhardlimit;
39 static int hf_rquota_fsoftlimit;
40 static int hf_rquota_curfiles;
41 static int hf_rquota_btimeleft;
42 static int hf_rquota_ftimeleft;
44 static int ett_rquota;
45 static int ett_rquota_rquota;
47 #define RQUOTAPROC_NULL 0
48 #define RQUOTAPROC_GETQUOTA 1
49 #define RQUOTAPROC_GETACTIVEQUOTA 2
50 #define RQUOTAPROC_SETQUOTA 3
51 #define RQUOTAPROC_SETACTIVEQUOTA 4
53 #define RQUOTA_PROGRAM 100011
55 static const value_string names_rquota_status[] =
57 #define Q_OK 1
58 { Q_OK, "OK" },
59 #define Q_NOQUOTA 2
60 { Q_NOQUOTA, "NOQUOTA" },
61 #define Q_EPERM 3
62 { Q_EPERM, "EPERM" },
63 { 0, NULL }
67 static int
68 dissect_rquota(tvbuff_t *tvb, int offset, proto_tree *tree)
71 proto_item *lock_item = NULL;
72 proto_tree *lock_tree = NULL;
74 lock_item = proto_tree_add_item(tree, hf_rquota_rquota, tvb,
75 offset, -1, ENC_NA);
77 lock_tree = proto_item_add_subtree(lock_item, ett_rquota_rquota);
79 offset = dissect_rpc_uint32(tvb, lock_tree,
80 hf_rquota_bsize, offset);
82 offset = dissect_rpc_bool(tvb, lock_tree,
83 hf_rquota_active, offset);
85 offset = dissect_rpc_uint32(tvb, lock_tree,
86 hf_rquota_bhardlimit, offset);
88 offset = dissect_rpc_uint32(tvb, lock_tree,
89 hf_rquota_bsoftlimit, offset);
91 offset = dissect_rpc_uint32(tvb, lock_tree,
92 hf_rquota_curblocks, offset);
94 offset = dissect_rpc_uint32(tvb, lock_tree,
95 hf_rquota_fhardlimit, offset);
97 offset = dissect_rpc_uint32(tvb, lock_tree,
98 hf_rquota_fsoftlimit, offset);
100 offset = dissect_rpc_uint32(tvb, lock_tree,
101 hf_rquota_curfiles, offset);
103 offset = dissect_rpc_uint32(tvb, lock_tree,
104 hf_rquota_btimeleft, offset);
106 offset = dissect_rpc_uint32(tvb, lock_tree,
107 hf_rquota_ftimeleft, offset);
109 return offset;
112 static int
113 dissect_getquota_result(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
115 int32_t status;
116 int offset = 0;
118 status = tvb_get_ntohl(tvb, offset);
120 offset = dissect_rpc_uint32(tvb, tree,
121 hf_rquota_status, offset);
123 if (status==Q_OK) {
124 offset = dissect_rquota(tvb, offset, tree);
127 return offset;
130 static int
131 dissect_getquota_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
133 int offset = 0;
135 offset = dissect_rpc_string(tvb, tree,
136 hf_rquota_pathp, offset, NULL);
138 offset = dissect_rpc_uint32(tvb, tree,
139 hf_rquota_uid, offset);
141 return offset;
144 /* proc number, "proc name", dissect_request, dissect_reply */
145 static const vsff rquota1_proc[] = {
146 { RQUOTAPROC_NULL, "NULL",
147 dissect_rpc_void, dissect_rpc_void },
148 { RQUOTAPROC_GETQUOTA, "GETQUOTA",
149 dissect_getquota_call, dissect_getquota_result },
150 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA",
151 dissect_getquota_call, dissect_getquota_result },
152 { 0, NULL,
153 NULL, NULL }
155 static const value_string rquota1_proc_vals[] = {
156 { RQUOTAPROC_NULL, "NULL" },
157 { RQUOTAPROC_GETQUOTA, "GETQUOTA" },
158 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA" },
159 { RQUOTAPROC_SETQUOTA, "SETQUOTA" },
160 { RQUOTAPROC_SETACTIVEQUOTA, "SETACTIVEQUOTA" },
161 { 0, NULL }
163 /* end of RQUOTA version 1 */
166 static int
167 dissect_getquota2_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
169 int offset = 0;
171 offset = dissect_rpc_string(tvb, tree,
172 hf_rquota_pathp, offset, NULL);
174 offset = dissect_rpc_uint32(tvb, tree,
175 hf_rquota_type, offset);
177 offset = dissect_rpc_uint32(tvb, tree,
178 hf_rquota_id, offset);
180 return offset;
184 static const vsff rquota2_proc[] = {
185 { RQUOTAPROC_NULL, "NULL",
186 dissect_rpc_void, dissect_rpc_void },
187 { RQUOTAPROC_GETQUOTA, "GETQUOTA",
188 dissect_getquota2_call, dissect_getquota_result },
189 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA",
190 dissect_getquota2_call, dissect_getquota_result },
191 { 0, NULL,
192 NULL, NULL }
194 static const value_string rquota2_proc_vals[] = {
195 { RQUOTAPROC_NULL, "NULL" },
196 { RQUOTAPROC_GETQUOTA, "GETQUOTA" },
197 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA" },
198 { RQUOTAPROC_SETQUOTA, "SETQUOTA" },
199 { RQUOTAPROC_SETACTIVEQUOTA, "SETACTIVEQUOTA" },
200 { 0, NULL }
202 /* end of RQUOTA version 2 */
204 static const rpc_prog_vers_info rquota_vers_info[] = {
205 { 1, rquota1_proc, &hf_rquota_procedure_v1 },
206 { 2, rquota2_proc, &hf_rquota_procedure_v2 },
209 void
210 proto_register_rquota(void)
212 static struct true_false_string tfs_active = { "Quota is ACTIVE", "Quota is NOT active" };
214 static hf_register_info hf[] = {
215 { &hf_rquota_procedure_v1, {
216 "V1 Procedure", "rquota.procedure_v1", FT_UINT32, BASE_DEC,
217 VALS(rquota1_proc_vals), 0, NULL, HFILL }},
218 { &hf_rquota_procedure_v2, {
219 "V2 Procedure", "rquota.procedure_v2", FT_UINT32, BASE_DEC,
220 VALS(rquota2_proc_vals), 0, NULL, HFILL }},
221 { &hf_rquota_uid, {
222 "uid", "rquota.uid", FT_UINT32, BASE_DEC,
223 NULL, 0, "User ID", HFILL }},
224 { &hf_rquota_type, {
225 "type", "rquota.type", FT_UINT32, BASE_DEC,
226 NULL, 0, NULL, HFILL }},
227 { &hf_rquota_id, {
228 "id", "rquota.id", FT_UINT32, BASE_DEC,
229 NULL, 0, NULL, HFILL }},
231 { &hf_rquota_pathp, {
232 "pathp", "rquota.pathp", FT_STRING, BASE_NONE,
233 NULL, 0, "Filesystem of interest", HFILL }},
235 { &hf_rquota_status, {
236 "status", "rquota.status", FT_UINT32, BASE_DEC,
237 VALS(names_rquota_status), 0, "Status code", HFILL }},
239 { &hf_rquota_rquota, {
240 "rquota", "rquota.rquota", FT_NONE, BASE_NONE,
241 NULL, 0, "Rquota structure", HFILL }},
243 { &hf_rquota_bsize, {
244 "bsize", "rquota.bsize", FT_UINT32, BASE_DEC,
245 NULL, 0, "Block size", HFILL }},
247 { &hf_rquota_active, {
248 "active", "rquota.active", FT_BOOLEAN, BASE_NONE,
249 TFS(&tfs_active), 0x0, "Indicates whether quota is active", HFILL }},
251 { &hf_rquota_bhardlimit, {
252 "bhardlimit", "rquota.bhardlimit", FT_UINT32, BASE_DEC,
253 NULL, 0, "Hard limit for blocks", HFILL }},
255 { &hf_rquota_bsoftlimit, {
256 "bsoftlimit", "rquota.bsoftlimit", FT_UINT32, BASE_DEC,
257 NULL, 0, "Soft limit for blocks", HFILL }},
259 { &hf_rquota_curblocks, {
260 "curblocks", "rquota.curblocks", FT_UINT32, BASE_DEC,
261 NULL, 0, "Current block count", HFILL }},
263 { &hf_rquota_fhardlimit, {
264 "fhardlimit", "rquota.fhardlimit", FT_UINT32, BASE_DEC,
265 NULL, 0, "Hard limit on allocated files", HFILL }},
267 { &hf_rquota_fsoftlimit, {
268 "fsoftlimit", "rquota.fsoftlimit", FT_UINT32, BASE_DEC,
269 NULL, 0, "Soft limit of allocated files", HFILL }},
271 { &hf_rquota_curfiles, {
272 "curfiles", "rquota.curfiles", FT_UINT32, BASE_DEC,
273 NULL, 0, "Current # allocated files", HFILL }},
275 { &hf_rquota_btimeleft, {
276 "btimeleft", "rquota.btimeleft", FT_UINT32, BASE_DEC,
277 NULL, 0, "Time left for excessive disk use", HFILL }},
279 { &hf_rquota_ftimeleft, {
280 "ftimeleft", "rquota.ftimeleft", FT_UINT32, BASE_DEC,
281 NULL, 0, "Time left for excessive files", HFILL }},
285 static int *ett[] = {
286 &ett_rquota,
287 &ett_rquota_rquota,
290 proto_rquota = proto_register_protocol("Remote Quota", "RQUOTA", "rquota");
292 proto_register_field_array(proto_rquota, hf, array_length(hf));
294 proto_register_subtree_array(ett, array_length(ett));
297 void
298 proto_reg_handoff_rquota(void)
300 /* Register the protocol as RPC */
301 rpc_init_prog(proto_rquota, RQUOTA_PROGRAM, ett_rquota,
302 G_N_ELEMENTS(rquota_vers_info), rquota_vers_info);
306 * Editor modelines - https://www.wireshark.org/tools/modelines.html
308 * Local variables:
309 * c-basic-offset: 8
310 * tab-width: 8
311 * indent-tabs-mode: t
312 * End:
314 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
315 * :indentSize=8:tabSize=8:noTabs=false: