2 * Routines for rquota dissection
3 * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
5 * $Id: packet-rquota.c,v 1.7 2002/04/03 13:24:13 girlich 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.
33 #ifdef HAVE_SYS_TYPES_H
34 #include <sys/types.h>
38 #include "packet-rpc.h"
39 #include "packet-rquota.h"
41 static int proto_rquota = -1;
42 static int hf_rquota_pathp = -1;
43 static int hf_rquota_uid = -1;
44 static int hf_rquota_status = -1;
45 static int hf_rquota_rquota = -1;
46 static int hf_rquota_bsize = -1;
47 static int hf_rquota_active = -1;
48 static int hf_rquota_bhardlimit = -1;
49 static int hf_rquota_bsoftlimit = -1;
50 static int hf_rquota_curblocks = -1;
51 static int hf_rquota_fhardlimit = -1;
52 static int hf_rquota_fsoftlimit = -1;
53 static int hf_rquota_curfiles = -1;
54 static int hf_rquota_btimeleft = -1;
55 static int hf_rquota_ftimeleft = -1;
57 static gint ett_rquota = -1;
58 static gint ett_rquota_rquota = -1;
60 static const value_string names_rquota_status[] =
65 { Q_NOQUOTA, "NOQUOTA" },
73 dissect_rquota(tvbuff_t *tvb, int offset, proto_tree *tree)
76 proto_item *lock_item = NULL;
77 proto_tree *lock_tree = NULL;
79 lock_item = proto_tree_add_item(tree, hf_rquota_rquota, tvb,
82 lock_tree = proto_item_add_subtree(lock_item, ett_rquota_rquota);
84 offset = dissect_rpc_uint32(tvb, lock_tree,
85 hf_rquota_bsize, offset);
87 offset = dissect_rpc_bool(tvb, lock_tree,
88 hf_rquota_active, offset);
90 offset = dissect_rpc_uint32(tvb, lock_tree,
91 hf_rquota_bhardlimit, offset);
93 offset = dissect_rpc_uint32(tvb, lock_tree,
94 hf_rquota_bsoftlimit, offset);
96 offset = dissect_rpc_uint32(tvb, lock_tree,
97 hf_rquota_curblocks, offset);
99 offset = dissect_rpc_uint32(tvb, lock_tree,
100 hf_rquota_fhardlimit, offset);
102 offset = dissect_rpc_uint32(tvb, lock_tree,
103 hf_rquota_fsoftlimit, offset);
105 offset = dissect_rpc_uint32(tvb, lock_tree,
106 hf_rquota_curfiles, offset);
108 offset = dissect_rpc_uint32(tvb, lock_tree,
109 hf_rquota_btimeleft, offset);
111 offset = dissect_rpc_uint32(tvb, lock_tree,
112 hf_rquota_ftimeleft, offset);
118 dissect_getquota_result(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
122 status = tvb_get_ntohl(tvb, offset);
124 offset = dissect_rpc_uint32(tvb, tree,
125 hf_rquota_status, offset);
128 offset = dissect_rquota(tvb, offset, tree);
135 dissect_getquota_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
137 offset = dissect_rpc_string(tvb, tree,
138 hf_rquota_pathp, offset, NULL);
140 offset = dissect_rpc_uint32(tvb, tree,
141 hf_rquota_uid, offset);
146 /* proc number, "proc name", dissect_request, dissect_reply */
147 /* NULL as function pointer means: type of arguments is "void". */
148 static const vsff rquota1_proc[] = {
149 { RQUOTAPROC_NULL, "NULL",
151 { RQUOTAPROC_GETQUOTA, "GETQUOTA",
152 dissect_getquota_call, dissect_getquota_result },
153 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA",
154 dissect_getquota_call, dissect_getquota_result },
158 /* end of RQUOTA version 1 */
161 proto_register_rquota(void)
163 static struct true_false_string tfs_active = { "Quota is ACTIVE", "Quota is NOT active" };
165 static hf_register_info hf[] = {
167 "uid", "rquota.uid", FT_UINT32, BASE_DEC,
168 NULL, 0, "User ID", HFILL }},
170 { &hf_rquota_pathp, {
171 "pathp", "rquota.pathp", FT_STRING, BASE_DEC,
172 NULL, 0, "Filesystem of interest", HFILL }},
174 { &hf_rquota_status, {
175 "status", "rquota.status", FT_UINT32, BASE_DEC,
176 VALS(names_rquota_status), 0, "Status code", HFILL }},
178 { &hf_rquota_rquota, {
179 "rquota", "rquota.rquota", FT_NONE, BASE_NONE,
180 NULL, 0, "Rquota structure", HFILL }},
182 { &hf_rquota_bsize, {
183 "bsize", "rquota.bsize", FT_UINT32, BASE_DEC,
184 NULL, 0, "Block size", HFILL }},
186 { &hf_rquota_active, {
187 "active", "rquota.active", FT_BOOLEAN, BASE_NONE,
188 &tfs_active, 0, "Indicates whether quota is active", HFILL }},
190 { &hf_rquota_bhardlimit, {
191 "bhardlimit", "rquota.bhardlimit", FT_UINT32, BASE_DEC,
192 NULL, 0, "Hard limit for blocks", HFILL }},
194 { &hf_rquota_bsoftlimit, {
195 "bsoftlimit", "rquota.bsoftlimit", FT_UINT32, BASE_DEC,
196 NULL, 0, "Soft limit for blocks", HFILL }},
198 { &hf_rquota_curblocks, {
199 "curblocks", "rquota.curblocks", FT_UINT32, BASE_DEC,
200 NULL, 0, "Current block count", HFILL }},
202 { &hf_rquota_fhardlimit, {
203 "fhardlimit", "rquota.fhardlimit", FT_UINT32, BASE_DEC,
204 NULL, 0, "Hard limit on allocated files", HFILL }},
206 { &hf_rquota_fsoftlimit, {
207 "fsoftlimit", "rquota.fsoftlimit", FT_UINT32, BASE_DEC,
208 NULL, 0, "Soft limit of allocated files", HFILL }},
210 { &hf_rquota_curfiles, {
211 "curfiles", "rquota.curfiles", FT_UINT32, BASE_DEC,
212 NULL, 0, "Current # allocated files", HFILL }},
214 { &hf_rquota_btimeleft, {
215 "btimeleft", "rquota.btimeleft", FT_UINT32, BASE_DEC,
216 NULL, 0, "Time left for excessive disk use", HFILL }},
218 { &hf_rquota_ftimeleft, {
219 "ftimeleft", "rquota.ftimeleft", FT_UINT32, BASE_DEC,
220 NULL, 0, "Time left for excessive files", HFILL }},
224 static gint *ett[] = {
229 proto_rquota = proto_register_protocol("Remote Quota",
232 proto_register_field_array(proto_rquota, hf, array_length(hf));
234 proto_register_subtree_array(ett, array_length(ett));
238 proto_reg_handoff_rquota(void)
240 /* Register the protocol as RPC */
241 rpc_init_prog(proto_rquota, RQUOTA_PROGRAM, ett_rquota);
242 /* Register the procedure tables */
243 rpc_init_proc_table(RQUOTA_PROGRAM, 1, rquota1_proc);