2 * Routines for rquota dissection
3 * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
5 * $Id: packet-rquota.c,v 1.11 2002/11/01 00:48:38 sahlberg Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-ypxfr.c
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include "packet-rpc.h"
35 #include "packet-rquota.h"
37 static int proto_rquota = -1;
38 static int hf_rquota_procedure_v1 = -1;
39 static int hf_rquota_pathp = -1;
40 static int hf_rquota_uid = -1;
41 static int hf_rquota_status = -1;
42 static int hf_rquota_rquota = -1;
43 static int hf_rquota_bsize = -1;
44 static int hf_rquota_active = -1;
45 static int hf_rquota_bhardlimit = -1;
46 static int hf_rquota_bsoftlimit = -1;
47 static int hf_rquota_curblocks = -1;
48 static int hf_rquota_fhardlimit = -1;
49 static int hf_rquota_fsoftlimit = -1;
50 static int hf_rquota_curfiles = -1;
51 static int hf_rquota_btimeleft = -1;
52 static int hf_rquota_ftimeleft = -1;
54 static gint ett_rquota = -1;
55 static gint ett_rquota_rquota = -1;
57 static const value_string names_rquota_status[] =
62 { Q_NOQUOTA, "NOQUOTA" },
70 dissect_rquota(tvbuff_t *tvb, int offset, proto_tree *tree)
73 proto_item *lock_item = NULL;
74 proto_tree *lock_tree = NULL;
76 lock_item = proto_tree_add_item(tree, hf_rquota_rquota, tvb,
79 lock_tree = proto_item_add_subtree(lock_item, ett_rquota_rquota);
81 offset = dissect_rpc_uint32(tvb, lock_tree,
82 hf_rquota_bsize, offset);
84 offset = dissect_rpc_bool(tvb, lock_tree,
85 hf_rquota_active, offset);
87 offset = dissect_rpc_uint32(tvb, lock_tree,
88 hf_rquota_bhardlimit, offset);
90 offset = dissect_rpc_uint32(tvb, lock_tree,
91 hf_rquota_bsoftlimit, offset);
93 offset = dissect_rpc_uint32(tvb, lock_tree,
94 hf_rquota_curblocks, offset);
96 offset = dissect_rpc_uint32(tvb, lock_tree,
97 hf_rquota_fhardlimit, offset);
99 offset = dissect_rpc_uint32(tvb, lock_tree,
100 hf_rquota_fsoftlimit, offset);
102 offset = dissect_rpc_uint32(tvb, lock_tree,
103 hf_rquota_curfiles, offset);
105 offset = dissect_rpc_uint32(tvb, lock_tree,
106 hf_rquota_btimeleft, offset);
108 offset = dissect_rpc_uint32(tvb, lock_tree,
109 hf_rquota_ftimeleft, offset);
115 dissect_getquota_result(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
119 status = tvb_get_ntohl(tvb, offset);
121 offset = dissect_rpc_uint32(tvb, tree,
122 hf_rquota_status, offset);
125 offset = dissect_rquota(tvb, offset, tree);
132 dissect_getquota_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
134 offset = dissect_rpc_string(tvb, tree,
135 hf_rquota_pathp, offset, NULL);
137 offset = dissect_rpc_uint32(tvb, tree,
138 hf_rquota_uid, offset);
143 /* proc number, "proc name", dissect_request, dissect_reply */
144 /* NULL as function pointer means: type of arguments is "void". */
145 static const vsff rquota1_proc[] = {
146 { RQUOTAPROC_NULL, "NULL",
148 { RQUOTAPROC_GETQUOTA, "GETQUOTA",
149 dissect_getquota_call, dissect_getquota_result },
150 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA",
151 dissect_getquota_call, dissect_getquota_result },
155 static const value_string rquota1_proc_vals[] = {
156 { RQUOTAPROC_NULL, "NULL" },
157 { RQUOTAPROC_GETQUOTA, "GETQUOTA" },
158 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA" },
161 /* end of RQUOTA version 1 */
164 proto_register_rquota(void)
166 static struct true_false_string tfs_active = { "Quota is ACTIVE", "Quota is NOT active" };
168 static hf_register_info hf[] = {
169 { &hf_rquota_procedure_v1, {
170 "V1 Procedure", "rquota.procedure_v1", FT_UINT32, BASE_DEC,
171 VALS(rquota1_proc_vals), 0, "V1 Procedure", HFILL }},
173 "uid", "rquota.uid", FT_UINT32, BASE_DEC,
174 NULL, 0, "User ID", HFILL }},
176 { &hf_rquota_pathp, {
177 "pathp", "rquota.pathp", FT_STRING, BASE_DEC,
178 NULL, 0, "Filesystem of interest", HFILL }},
180 { &hf_rquota_status, {
181 "status", "rquota.status", FT_UINT32, BASE_DEC,
182 VALS(names_rquota_status), 0, "Status code", HFILL }},
184 { &hf_rquota_rquota, {
185 "rquota", "rquota.rquota", FT_NONE, BASE_NONE,
186 NULL, 0, "Rquota structure", HFILL }},
188 { &hf_rquota_bsize, {
189 "bsize", "rquota.bsize", FT_UINT32, BASE_DEC,
190 NULL, 0, "Block size", HFILL }},
192 { &hf_rquota_active, {
193 "active", "rquota.active", FT_BOOLEAN, BASE_NONE,
194 &tfs_active, 0, "Indicates whether quota is active", HFILL }},
196 { &hf_rquota_bhardlimit, {
197 "bhardlimit", "rquota.bhardlimit", FT_UINT32, BASE_DEC,
198 NULL, 0, "Hard limit for blocks", HFILL }},
200 { &hf_rquota_bsoftlimit, {
201 "bsoftlimit", "rquota.bsoftlimit", FT_UINT32, BASE_DEC,
202 NULL, 0, "Soft limit for blocks", HFILL }},
204 { &hf_rquota_curblocks, {
205 "curblocks", "rquota.curblocks", FT_UINT32, BASE_DEC,
206 NULL, 0, "Current block count", HFILL }},
208 { &hf_rquota_fhardlimit, {
209 "fhardlimit", "rquota.fhardlimit", FT_UINT32, BASE_DEC,
210 NULL, 0, "Hard limit on allocated files", HFILL }},
212 { &hf_rquota_fsoftlimit, {
213 "fsoftlimit", "rquota.fsoftlimit", FT_UINT32, BASE_DEC,
214 NULL, 0, "Soft limit of allocated files", HFILL }},
216 { &hf_rquota_curfiles, {
217 "curfiles", "rquota.curfiles", FT_UINT32, BASE_DEC,
218 NULL, 0, "Current # allocated files", HFILL }},
220 { &hf_rquota_btimeleft, {
221 "btimeleft", "rquota.btimeleft", FT_UINT32, BASE_DEC,
222 NULL, 0, "Time left for excessive disk use", HFILL }},
224 { &hf_rquota_ftimeleft, {
225 "ftimeleft", "rquota.ftimeleft", FT_UINT32, BASE_DEC,
226 NULL, 0, "Time left for excessive files", HFILL }},
230 static gint *ett[] = {
235 proto_rquota = proto_register_protocol("Remote Quota",
238 proto_register_field_array(proto_rquota, hf, array_length(hf));
240 proto_register_subtree_array(ett, array_length(ett));
244 proto_reg_handoff_rquota(void)
246 /* Register the protocol as RPC */
247 rpc_init_prog(proto_rquota, RQUOTA_PROGRAM, ett_rquota);
248 /* Register the procedure tables */
249 rpc_init_proc_table(RQUOTA_PROGRAM, 1, rquota1_proc, hf_rquota_procedure_v1);