Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-rquota.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-rquota.c
2
 * Routines for rquota dissection
3
 * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * Copied from packet-ypxfr.c
10
 *
11
 * SPDX-License-Identifier: GPL-2.0-or-later
12
 */
13
14
#include "config.h"
15
16
#include <epan/packet.h>
17
#include <epan/tfs.h>
18
#include <wsutil/array.h>
19
#include "packet-rpc.h"
20
21
void proto_register_rquota(void);
22
void proto_reg_handoff_rquota(void);
23
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;
43
44
static int ett_rquota;
45
static int ett_rquota_rquota;
46
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
52
53
14
#define RQUOTA_PROGRAM 100011
54
55
static const value_string names_rquota_status[] =
56
{
57
0
#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 }
64
};
65
66
67
static int
68
dissect_rquota(tvbuff_t *tvb, int offset, proto_tree *tree)
69
0
{
70
71
0
  proto_item *lock_item = NULL;
72
0
  proto_tree *lock_tree = NULL;
73
74
0
  lock_item = proto_tree_add_item(tree, hf_rquota_rquota, tvb,
75
0
      offset, -1, ENC_NA);
76
77
0
  lock_tree = proto_item_add_subtree(lock_item, ett_rquota_rquota);
78
79
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
80
0
      hf_rquota_bsize, offset);
81
82
0
  offset = dissect_rpc_bool(tvb, lock_tree,
83
0
      hf_rquota_active, offset);
84
85
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
86
0
      hf_rquota_bhardlimit, offset);
87
88
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
89
0
      hf_rquota_bsoftlimit, offset);
90
91
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
92
0
      hf_rquota_curblocks, offset);
93
94
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
95
0
      hf_rquota_fhardlimit, offset);
96
97
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
98
0
      hf_rquota_fsoftlimit, offset);
99
100
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
101
0
      hf_rquota_curfiles, offset);
102
103
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
104
0
      hf_rquota_btimeleft, offset);
105
106
0
  offset = dissect_rpc_uint32(tvb, lock_tree,
107
0
      hf_rquota_ftimeleft, offset);
108
109
0
  return offset;
110
0
}
111
112
static int
113
dissect_getquota_result(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
114
0
{
115
0
  int32_t status;
116
0
  int offset = 0;
117
118
0
  status = tvb_get_ntohl(tvb, offset);
119
120
0
  offset = dissect_rpc_uint32(tvb, tree,
121
0
      hf_rquota_status, offset);
122
123
0
  if (status==Q_OK) {
124
0
    offset = dissect_rquota(tvb, offset, tree);
125
0
  }
126
127
0
  return offset;
128
0
}
129
130
static int
131
dissect_getquota_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
132
0
{
133
0
  int offset = 0;
134
135
0
  offset = dissect_rpc_string(tvb, tree,
136
0
      hf_rquota_pathp, offset, NULL);
137
138
0
  offset = dissect_rpc_uint32(tvb, tree,
139
0
      hf_rquota_uid, offset);
140
141
0
  return offset;
142
0
}
143
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 }
154
};
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 }
162
};
163
/* end of RQUOTA version 1 */
164
165
166
static int
167
dissect_getquota2_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
168
0
{
169
0
  int offset = 0;
170
171
0
  offset = dissect_rpc_string(tvb, tree,
172
0
      hf_rquota_pathp, offset, NULL);
173
174
0
  offset = dissect_rpc_uint32(tvb, tree,
175
0
      hf_rquota_type, offset);
176
177
0
  offset = dissect_rpc_uint32(tvb, tree,
178
0
      hf_rquota_id, offset);
179
180
0
  return offset;
181
0
}
182
183
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 }
193
};
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 }
201
};
202
/* end of RQUOTA version 2 */
203
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 },
207
};
208
209
void
210
proto_register_rquota(void)
211
14
{
212
14
  static struct true_false_string tfs_active = { "Quota is ACTIVE", "Quota is NOT active" };
213
214
14
  static hf_register_info hf[] = {
215
14
    { &hf_rquota_procedure_v1, {
216
14
      "V1 Procedure", "rquota.procedure_v1", FT_UINT32, BASE_DEC,
217
14
      VALS(rquota1_proc_vals), 0, NULL, HFILL }},
218
14
    { &hf_rquota_procedure_v2, {
219
14
      "V2 Procedure", "rquota.procedure_v2", FT_UINT32, BASE_DEC,
220
14
      VALS(rquota2_proc_vals), 0, NULL, HFILL }},
221
14
    { &hf_rquota_uid, {
222
14
      "uid", "rquota.uid", FT_UINT32, BASE_DEC,
223
14
      NULL, 0, "User ID", HFILL }},
224
14
    { &hf_rquota_type, {
225
14
      "type", "rquota.type", FT_UINT32, BASE_DEC,
226
14
      NULL, 0, NULL, HFILL }},
227
14
    { &hf_rquota_id, {
228
14
      "id", "rquota.id", FT_UINT32, BASE_DEC,
229
14
      NULL, 0, NULL, HFILL }},
230
231
14
    { &hf_rquota_pathp, {
232
14
      "pathp", "rquota.pathp", FT_STRING, BASE_NONE,
233
14
      NULL, 0, "Filesystem of interest", HFILL }},
234
235
14
    { &hf_rquota_status, {
236
14
      "status", "rquota.status", FT_UINT32, BASE_DEC,
237
14
      VALS(names_rquota_status), 0, "Status code", HFILL }},
238
239
14
    { &hf_rquota_rquota, {
240
14
      "rquota", "rquota.rquota", FT_NONE, BASE_NONE,
241
14
      NULL, 0, "Rquota structure", HFILL }},
242
243
14
    { &hf_rquota_bsize, {
244
14
      "bsize", "rquota.bsize", FT_UINT32, BASE_DEC,
245
14
      NULL, 0, "Block size", HFILL }},
246
247
14
    { &hf_rquota_active, {
248
14
      "active", "rquota.active", FT_BOOLEAN, BASE_NONE,
249
14
      TFS(&tfs_active), 0x0, "Indicates whether quota is active", HFILL }},
250
251
14
    { &hf_rquota_bhardlimit, {
252
14
      "bhardlimit", "rquota.bhardlimit", FT_UINT32, BASE_DEC,
253
14
      NULL, 0, "Hard limit for blocks", HFILL }},
254
255
14
    { &hf_rquota_bsoftlimit, {
256
14
      "bsoftlimit", "rquota.bsoftlimit", FT_UINT32, BASE_DEC,
257
14
      NULL, 0, "Soft limit for blocks", HFILL }},
258
259
14
    { &hf_rquota_curblocks, {
260
14
      "curblocks", "rquota.curblocks", FT_UINT32, BASE_DEC,
261
14
      NULL, 0, "Current block count", HFILL }},
262
263
14
    { &hf_rquota_fhardlimit, {
264
14
      "fhardlimit", "rquota.fhardlimit", FT_UINT32, BASE_DEC,
265
14
      NULL, 0, "Hard limit on allocated files", HFILL }},
266
267
14
    { &hf_rquota_fsoftlimit, {
268
14
      "fsoftlimit", "rquota.fsoftlimit", FT_UINT32, BASE_DEC,
269
14
      NULL, 0, "Soft limit of allocated files", HFILL }},
270
271
14
    { &hf_rquota_curfiles, {
272
14
      "curfiles", "rquota.curfiles", FT_UINT32, BASE_DEC,
273
14
      NULL, 0, "Current # allocated files", HFILL }},
274
275
14
    { &hf_rquota_btimeleft, {
276
14
      "btimeleft", "rquota.btimeleft", FT_UINT32, BASE_DEC,
277
14
      NULL, 0, "Time left for excessive disk use", HFILL }},
278
279
14
    { &hf_rquota_ftimeleft, {
280
14
      "ftimeleft", "rquota.ftimeleft", FT_UINT32, BASE_DEC,
281
14
      NULL, 0, "Time left for excessive files", HFILL }},
282
283
14
  };
284
285
14
  static int *ett[] = {
286
14
    &ett_rquota,
287
14
    &ett_rquota_rquota,
288
14
  };
289
290
14
  proto_rquota = proto_register_protocol("Remote Quota", "RQUOTA", "rquota");
291
292
14
  proto_register_field_array(proto_rquota, hf, array_length(hf));
293
294
14
  proto_register_subtree_array(ett, array_length(ett));
295
14
}
296
297
void
298
proto_reg_handoff_rquota(void)
299
14
{
300
  /* Register the protocol as RPC */
301
14
  rpc_init_prog(proto_rquota, RQUOTA_PROGRAM, ett_rquota,
302
14
      G_N_ELEMENTS(rquota_vers_info), rquota_vers_info);
303
14
}
304
305
/*
306
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
307
 *
308
 * Local variables:
309
 * c-basic-offset: 8
310
 * tab-width: 8
311
 * indent-tabs-mode: t
312
 * End:
313
 *
314
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
315
 * :indentSize=8:tabSize=8:noTabs=false:
316
 */