2 * Routines for rquota dissection
3 * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
5 * $Id: packet-rquota.c,v 1.3 2001/05/30 06:01:02 guy 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 const value_string names_rquota_status[] =
65 { Q_NOQUOTA, "NOQUOTA" },
72 dissect_rquota(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
75 proto_item *lock_item = NULL;
76 proto_tree *lock_tree = NULL;
78 lock_item = proto_tree_add_item(tree, hf_rquota_rquota, tvb,
79 offset, tvb_length_remaining(tvb, offset), FALSE);
81 lock_tree = proto_item_add_subtree(lock_item, ett_rquota_rquota);
83 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
84 hf_rquota_bsize, offset);
86 offset = dissect_rpc_bool(tvb, pinfo, lock_tree,
87 hf_rquota_active, offset);
89 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
90 hf_rquota_bhardlimit, offset);
92 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
93 hf_rquota_bsoftlimit, offset);
95 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
96 hf_rquota_curblocks, offset);
98 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
99 hf_rquota_fhardlimit, offset);
101 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
102 hf_rquota_fsoftlimit, offset);
104 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
105 hf_rquota_curfiles, offset);
107 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
108 hf_rquota_btimeleft, offset);
110 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
111 hf_rquota_ftimeleft, offset);
117 dissect_getquota_result(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
121 status = tvb_get_ntohl(tvb, offset);
123 offset = dissect_rpc_uint32(tvb, pinfo, tree,
124 hf_rquota_status, offset);
127 offset = dissect_rquota(tvb, offset, pinfo, tree);
134 dissect_getquota_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
136 offset = dissect_rpc_string(tvb, pinfo, tree,
137 hf_rquota_pathp, offset, NULL);
139 offset = dissect_rpc_uint32(tvb, pinfo, tree,
140 hf_rquota_uid, offset);
145 /* proc number, "proc name", dissect_request, dissect_reply */
146 /* NULL as function pointer means: type of arguments is "void". */
147 static const vsff rquota1_proc[] = {
148 { RQUOTAPROC_NULL, "NULL",
150 { RQUOTAPROC_GETQUOTA, "GETQUOTA",
151 dissect_getquota_call, dissect_getquota_result },
152 { RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA",
153 dissect_getquota_call, dissect_getquota_result },
157 /* end of RQUOTA version 1 */
160 proto_register_rquota(void)
162 static struct true_false_string tfs_active = { "Quota is ACTIVE", "Quota is NOT active" };
164 static hf_register_info hf[] = {
166 "uid", "rquota.uid", FT_UINT32, BASE_DEC,
167 NULL, 0, "User ID" }},
169 { &hf_rquota_pathp, {
170 "pathp", "rquota.pathp", FT_STRING, BASE_DEC,
171 NULL, 0, "Filesystem of interest" }},
173 { &hf_rquota_status, {
174 "status", "rquota.status", FT_UINT32, BASE_DEC,
175 VALS(names_rquota_status), 0, "Status code" }},
177 { &hf_rquota_rquota, {
178 "rquota", "rquota.rquota", FT_NONE, BASE_NONE,
179 NULL, 0, "Rquota structure" }},
181 { &hf_rquota_bsize, {
182 "bsize", "rquota.bsize", FT_UINT32, BASE_DEC,
183 NULL, 0, "Block size" }},
185 { &hf_rquota_active, {
186 "active", "rquota.active", FT_BOOLEAN, BASE_NONE,
187 &tfs_active, 0, "Indicates whether quota is active" }},
189 { &hf_rquota_bhardlimit, {
190 "bhardlimit", "rquota.bhardlimit", FT_UINT32, BASE_DEC,
191 NULL, 0, "Hard limit for blocks" }},
193 { &hf_rquota_bsoftlimit, {
194 "bsoftlimit", "rquota.bsoftlimit", FT_UINT32, BASE_DEC,
195 NULL, 0, "Soft limit for blocks" }},
197 { &hf_rquota_curblocks, {
198 "curblocks", "rquota.curblocks", FT_UINT32, BASE_DEC,
199 NULL, 0, "Current block count" }},
201 { &hf_rquota_fhardlimit, {
202 "fhardlimit", "rquota.fhardlimit", FT_UINT32, BASE_DEC,
203 NULL, 0, "Hard limit on allocated files" }},
205 { &hf_rquota_fsoftlimit, {
206 "fsoftlimit", "rquota.fsoftlimit", FT_UINT32, BASE_DEC,
207 NULL, 0, "Soft limit of allocated files" }},
209 { &hf_rquota_curfiles, {
210 "curfiles", "rquota.curfiles", FT_UINT32, BASE_DEC,
211 NULL, 0, "Current # allocated files" }},
213 { &hf_rquota_btimeleft, {
214 "btimeleft", "rquota.btimeleft", FT_UINT32, BASE_DEC,
215 NULL, 0, "Time left for excessive disk use" }},
217 { &hf_rquota_ftimeleft, {
218 "ftimeleft", "rquota.ftimeleft", FT_UINT32, BASE_DEC,
219 NULL, 0, "Time left for excessive files" }},
223 static gint *ett[] = {
228 proto_rquota = proto_register_protocol("Remote Quota",
231 proto_register_field_array(proto_rquota, hf, array_length(hf));
233 proto_register_subtree_array(ett, array_length(ett));
237 proto_reg_handoff_rquota(void)
239 /* Register the protocol as RPC */
240 rpc_init_prog(proto_rquota, RQUOTA_PROGRAM, ett_rquota);
241 /* Register the procedure tables */
242 rpc_init_proc_table(RQUOTA_PROGRAM, 1, rquota1_proc);