2001-02-27 19:40:58 +00:00
|
|
|
/* packet-rquota.c
|
|
|
|
* Routines for rquota dissection
|
|
|
|
* Copyright 2001, Mike Frisch <frisch@hummingbird.com>
|
|
|
|
*
|
2002-11-01 00:48:39 +00:00
|
|
|
* $Id: packet-rquota.c,v 1.11 2002/11/01 00:48:38 sahlberg Exp $
|
2001-02-27 19:40:58 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-05-30 06:01:02 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
2001-02-27 19:40:58 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Copied from packet-ypxfr.c
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "packet-rpc.h"
|
|
|
|
#include "packet-rquota.h"
|
|
|
|
|
|
|
|
static int proto_rquota = -1;
|
2002-11-01 00:48:39 +00:00
|
|
|
static int hf_rquota_procedure_v1 = -1;
|
2001-04-21 08:00:12 +00:00
|
|
|
static int hf_rquota_pathp = -1;
|
|
|
|
static int hf_rquota_uid = -1;
|
|
|
|
static int hf_rquota_status = -1;
|
|
|
|
static int hf_rquota_rquota = -1;
|
|
|
|
static int hf_rquota_bsize = -1;
|
|
|
|
static int hf_rquota_active = -1;
|
|
|
|
static int hf_rquota_bhardlimit = -1;
|
|
|
|
static int hf_rquota_bsoftlimit = -1;
|
|
|
|
static int hf_rquota_curblocks = -1;
|
|
|
|
static int hf_rquota_fhardlimit = -1;
|
|
|
|
static int hf_rquota_fsoftlimit = -1;
|
|
|
|
static int hf_rquota_curfiles = -1;
|
|
|
|
static int hf_rquota_btimeleft = -1;
|
|
|
|
static int hf_rquota_ftimeleft = -1;
|
2001-02-27 19:40:58 +00:00
|
|
|
|
|
|
|
static gint ett_rquota = -1;
|
2001-04-21 08:00:12 +00:00
|
|
|
static gint ett_rquota_rquota = -1;
|
|
|
|
|
2001-11-27 22:37:20 +00:00
|
|
|
static const value_string names_rquota_status[] =
|
2001-04-21 08:00:12 +00:00
|
|
|
{
|
|
|
|
#define Q_OK 1
|
|
|
|
{ Q_OK, "OK" },
|
|
|
|
#define Q_NOQUOTA 2
|
|
|
|
{ Q_NOQUOTA, "NOQUOTA" },
|
|
|
|
#define Q_EPERM 3
|
|
|
|
{ Q_EPERM, "EPERM" },
|
2001-11-27 22:37:20 +00:00
|
|
|
{ 0, NULL }
|
2001-04-21 08:00:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_rquota(tvbuff_t *tvb, int offset, proto_tree *tree)
|
2001-04-21 08:00:12 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
proto_item *lock_item = NULL;
|
|
|
|
proto_tree *lock_tree = NULL;
|
|
|
|
|
|
|
|
lock_item = proto_tree_add_item(tree, hf_rquota_rquota, tvb,
|
2002-01-24 09:20:54 +00:00
|
|
|
offset, -1, FALSE);
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
lock_tree = proto_item_add_subtree(lock_item, ett_rquota_rquota);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_bsize, offset);
|
|
|
|
|
2002-04-03 13:24:13 +00:00
|
|
|
offset = dissect_rpc_bool(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_active, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_bhardlimit, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_bsoftlimit, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_curblocks, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_fhardlimit, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_fsoftlimit, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_curfiles, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_btimeleft, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_ftimeleft, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_getquota_result(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
|
2001-04-21 08:00:12 +00:00
|
|
|
{
|
|
|
|
gint32 status;
|
|
|
|
|
|
|
|
status = tvb_get_ntohl(tvb, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_status, offset);
|
|
|
|
|
|
|
|
if (status==Q_OK) {
|
2002-04-03 13:24:13 +00:00
|
|
|
offset = dissect_rquota(tvb, offset, tree);
|
2001-04-21 08:00:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_getquota_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
|
2001-04-21 08:00:12 +00:00
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_string(tvb, tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_pathp, offset, NULL);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, tree,
|
2001-04-21 08:00:12 +00:00
|
|
|
hf_rquota_uid, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
2001-02-27 19:40:58 +00:00
|
|
|
|
|
|
|
/* proc number, "proc name", dissect_request, dissect_reply */
|
|
|
|
/* NULL as function pointer means: type of arguments is "void". */
|
|
|
|
static const vsff rquota1_proc[] = {
|
2002-08-28 21:04:11 +00:00
|
|
|
{ RQUOTAPROC_NULL, "NULL",
|
2001-04-21 08:00:12 +00:00
|
|
|
NULL, NULL },
|
|
|
|
{ RQUOTAPROC_GETQUOTA, "GETQUOTA",
|
|
|
|
dissect_getquota_call, dissect_getquota_result },
|
|
|
|
{ RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA",
|
|
|
|
dissect_getquota_call, dissect_getquota_result },
|
2002-08-28 21:04:11 +00:00
|
|
|
{ 0, NULL,
|
2001-04-21 08:00:12 +00:00
|
|
|
NULL, NULL }
|
2001-02-27 19:40:58 +00:00
|
|
|
};
|
2002-11-01 00:48:39 +00:00
|
|
|
static const value_string rquota1_proc_vals[] = {
|
|
|
|
{ RQUOTAPROC_NULL, "NULL" },
|
|
|
|
{ RQUOTAPROC_GETQUOTA, "GETQUOTA" },
|
|
|
|
{ RQUOTAPROC_GETACTIVEQUOTA, "GETACTIVEQUOTA" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2001-02-27 19:40:58 +00:00
|
|
|
/* end of RQUOTA version 1 */
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_rquota(void)
|
|
|
|
{
|
2001-04-21 08:00:12 +00:00
|
|
|
static struct true_false_string tfs_active = { "Quota is ACTIVE", "Quota is NOT active" };
|
|
|
|
|
|
|
|
static hf_register_info hf[] = {
|
2002-11-01 00:48:39 +00:00
|
|
|
{ &hf_rquota_procedure_v1, {
|
|
|
|
"V1 Procedure", "rquota.procedure_v1", FT_UINT32, BASE_DEC,
|
|
|
|
VALS(rquota1_proc_vals), 0, "V1 Procedure", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
{ &hf_rquota_uid, {
|
|
|
|
"uid", "rquota.uid", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "User ID", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_pathp, {
|
|
|
|
"pathp", "rquota.pathp", FT_STRING, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Filesystem of interest", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_status, {
|
|
|
|
"status", "rquota.status", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
VALS(names_rquota_status), 0, "Status code", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_rquota, {
|
|
|
|
"rquota", "rquota.rquota", FT_NONE, BASE_NONE,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Rquota structure", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_bsize, {
|
|
|
|
"bsize", "rquota.bsize", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Block size", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_active, {
|
|
|
|
"active", "rquota.active", FT_BOOLEAN, BASE_NONE,
|
2001-06-18 02:18:27 +00:00
|
|
|
&tfs_active, 0, "Indicates whether quota is active", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_bhardlimit, {
|
|
|
|
"bhardlimit", "rquota.bhardlimit", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Hard limit for blocks", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_bsoftlimit, {
|
|
|
|
"bsoftlimit", "rquota.bsoftlimit", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Soft limit for blocks", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_curblocks, {
|
|
|
|
"curblocks", "rquota.curblocks", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Current block count", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_fhardlimit, {
|
|
|
|
"fhardlimit", "rquota.fhardlimit", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Hard limit on allocated files", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_fsoftlimit, {
|
|
|
|
"fsoftlimit", "rquota.fsoftlimit", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Soft limit of allocated files", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_curfiles, {
|
|
|
|
"curfiles", "rquota.curfiles", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Current # allocated files", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_btimeleft, {
|
|
|
|
"btimeleft", "rquota.btimeleft", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Time left for excessive disk use", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_rquota_ftimeleft, {
|
|
|
|
"ftimeleft", "rquota.ftimeleft", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Time left for excessive files", HFILL }},
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2001-02-27 19:40:58 +00:00
|
|
|
static gint *ett[] = {
|
2001-04-21 08:00:12 +00:00
|
|
|
&ett_rquota,
|
|
|
|
&ett_rquota_rquota,
|
2001-02-27 19:40:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
proto_rquota = proto_register_protocol("Remote Quota",
|
|
|
|
"RQUOTA", "rquota");
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
proto_register_field_array(proto_rquota, hf, array_length(hf));
|
|
|
|
|
2001-02-27 19:40:58 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_rquota(void)
|
|
|
|
{
|
|
|
|
/* Register the protocol as RPC */
|
|
|
|
rpc_init_prog(proto_rquota, RQUOTA_PROGRAM, ett_rquota);
|
|
|
|
/* Register the procedure tables */
|
2002-11-01 00:48:39 +00:00
|
|
|
rpc_init_proc_table(RQUOTA_PROGRAM, 1, rquota1_proc, hf_rquota_procedure_v1);
|
2001-02-27 19:40:58 +00:00
|
|
|
}
|
2001-04-21 08:00:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|