Initial quota support, from Ronnie Sahlberg.

svn path=/trunk/; revision=4771
This commit is contained in:
Guy Harris 2002-02-22 00:05:02 +00:00
parent e80b68372c
commit 2f70b4df02
2 changed files with 122 additions and 3 deletions

View File

@ -572,10 +572,10 @@ Ronnie Sahlberg <sahlberg[AT]optushome.com.au> {
requiring compiler support for them, and updates to the
Diameter, L2TP, NFS, and NLM dissectors to use it and to the
ONC RPC dissector to allow ONC RPC subdissectors to use it
SMB tvbuffication
SMB tvbuffication and enhancement
NDMPv3 support
Add time between request and reply as a field to ONC RPC replies
File handle to file name resolution in NFS and realted protocols
File handle to file name resolution in NFS and related protocols
DCE RPC enhancements
SAMR updates
}

View File

@ -3,7 +3,7 @@
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
* 2001 Rewrite by Ronnie Sahlberg and Guy Harris
*
* $Id: packet-smb.c,v 1.210 2002/02/21 23:54:03 guy Exp $
* $Id: packet-smb.c,v 1.211 2002/02/22 00:05:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -538,6 +538,9 @@ static int hf_smb_fs_attr_fc = -1;
static int hf_smb_fs_attr_vq = -1;
static int hf_smb_fs_attr_dim = -1;
static int hf_smb_fs_attr_vic = -1;
static int hf_smb_quota_flags_deny_disk = -1;
static int hf_smb_quota_flags_log_limit = -1;
static int hf_smb_quota_flags_log_warning = -1;
static gint ett_smb = -1;
static gint ett_smb_hdr = -1;
@ -605,6 +608,7 @@ static gint ett_smb_acl = -1;
static gint ett_smb_ace = -1;
static gint ett_smb_ace_flags = -1;
static gint ett_smb_sec_desc_type = -1;
static gint ett_smb_quotaflags = -1;
proto_tree *top_tree=NULL; /* ugly */
@ -8196,6 +8200,7 @@ static const value_string trans2_cmd_vals[] = {
{ 0x01, "FIND_FIRST2" },
{ 0x02, "FIND_NEXT2" },
{ 0x03, "QUERY_FS_INFORMATION" },
{ 0x04, "QUOTAS" },
{ 0x05, "QUERY_PATH_INFORMATION" },
{ 0x06, "SET_PATH_INFORMATION" },
{ 0x07, "QUERY_FILE_INFORMATION" },
@ -8287,6 +8292,7 @@ static const value_string qfsi_vals[] = {
{ 0x0103, "Query FS Size Info"},
{ 0x0104, "Query FS Device Info"},
{ 0x0105, "Query FS Attribute Info"},
{ 1006, "Query FS Quota Info"},
{0, NULL}
};
@ -10860,6 +10866,66 @@ dissect_device_characteristics(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa
return offset;
}
/* dissect 4 bytes specifying the number of 256 byte blocks for a quota limit */
static void
dissect_quota_32bit(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
char *str)
{
guint32 quota;
int i;
char *prefix = "KMGTPE";
quota = tvb_get_letohl(tvb, offset);
/* divide by four to get number of KB*/
quota >>= 2;
/* divide by 1024 until the result is less than 1024 */
i=0;
while( quota>1023 ){
i++;
quota >>= 10;
}
proto_tree_add_text(tree, tvb, offset, 4,
"%s is %d%cB",str, quota, prefix[i]);
}
static const true_false_string tfs_quota_flags_deny_disk = {
"DENY DISK SPACE for users exceeding quota limit",
"Do NOT deny disk space for users exceeding quota limit"
};
static const true_false_string tfs_quota_flags_log_limit = {
"LOG EVENT when a user exceeds their QUOTA LIMIT",
"Do NOT log event when a user exceeds their quota limit"
};
static const true_false_string tfs_quota_flags_log_warning = {
"LOG EVENT when a user exceeds their WARNING LEVEL",
"Do NOT log event when a user exceeds their warning level"
};
static void
dissect_quota_flags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
{
guint8 mask;
proto_item *item = NULL;
proto_tree *tree = NULL;
mask = tvb_get_guint8(tvb, offset);
if(parent_tree){
item = proto_tree_add_text(parent_tree, tvb, offset, 1,
"Quota Flags: 0x%02x", mask);
tree = proto_item_add_subtree(item, ett_smb_quotaflags);
}
proto_tree_add_boolean(tree, hf_smb_quota_flags_log_limit,
tvb, offset, 1, mask);
proto_tree_add_boolean(tree, hf_smb_quota_flags_log_warning,
tvb, offset, 1, mask);
proto_tree_add_boolean(tree, hf_smb_quota_flags_deny_disk,
tvb, offset, 1, mask);
}
/*dissect the data block for TRANS2_QUERY_FS_INFORMATION*/
static int
@ -11014,6 +11080,46 @@ dissect_qfsi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
COUNT_BYTES_TRANS_SUBR(fn_len);
break;
case 1006: /* QUERY_FS_QUOTA_INFO */
/* first 25 bytes are unknown */
CHECK_BYTE_COUNT_TRANS_SUBR(25);
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 25, TRUE);
COUNT_BYTES_TRANS_SUBR(25);
/* This really calls for a separate routing, but this will do for testing */
/* number of 256byte blocks for WARNING LEVEL, 32bit integer */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
dissect_quota_32bit(tvb, pinfo, tree, offset, "Default (Soft) Quota Warning Level");
COUNT_BYTES_TRANS_SUBR(4);
/* these 4 bytes are unknown */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 4, TRUE);
COUNT_BYTES_TRANS_SUBR(4);
/* number of 256byte blocks for QUOTA LIMIT, 64bit integer */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
dissect_quota_32bit(tvb, pinfo, tree, offset, "Default (Hard) Quota Limit");
COUNT_BYTES_TRANS_SUBR(4);
/* these 3 bytes are unknown */
CHECK_BYTE_COUNT_TRANS_SUBR(3);
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 3, TRUE);
COUNT_BYTES_TRANS_SUBR(3);
/* one byte of quota flags */
CHECK_BYTE_COUNT_TRANS_SUBR(1);
dissect_quota_flags(tvb, pinfo, tree, offset);
COUNT_BYTES_TRANS_SUBR(1);
/* these 7 bytes are unknown */
CHECK_BYTE_COUNT_TRANS_SUBR(7);
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 7, TRUE);
COUNT_BYTES_TRANS_SUBR(7);
}
return offset;
@ -15928,6 +16034,18 @@ proto_register_smb(void)
{ "Self Relative", "smb.sec_desc.type.self_relative", FT_BOOLEAN, 16,
TFS(&tfs_sec_desc_type_self_relative), 0x8000, "Is this SecDesc self relative?", HFILL }},
{ &hf_smb_quota_flags_deny_disk,
{ "Deny Disk", "smb.quota.flags.deny_disk", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_deny_disk), 0x02, "Is the default quota limit enforced?", HFILL }},
{ &hf_smb_quota_flags_log_limit,
{ "Log Limit", "smb.quota.flags.log_limit", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_log_limit), 0x20, "Should the server log an event when the limit is exceeded?", HFILL }},
{ &hf_smb_quota_flags_log_warning,
{ "Log Warning", "smb.quota.flags.log_warning", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_log_warning), 0x10, "Should the server log an event when the warning level is exceeded?", HFILL }},
};
static gint *ett[] = {
&ett_smb,
@ -15996,6 +16114,7 @@ proto_register_smb(void)
&ett_smb_ace,
&ett_smb_ace_flags,
&ett_smb_sec_desc_type,
&ett_smb_quotaflags,
};
module_t *smb_module;