Move the specific rights dissection function and name into a structure

instead of passing them around as separate parameters.  This is a
prelude to adding generic and standard mapping to the access mask
dissection.

svn path=/trunk/; revision=7591
This commit is contained in:
Tim Potter 2003-04-28 04:44:54 +00:00
parent b2f936ff24
commit e3dabb27e2
6 changed files with 87 additions and 52 deletions

View File

@ -3,7 +3,7 @@
* Copyright 2001,2003 Tim Potter <tpot@samba.org>
* 2002 Added LSA command dissectors Ronnie Sahlberg
*
* $Id: packet-dcerpc-lsa.c,v 1.75 2003/04/27 04:33:10 tpot Exp $
* $Id: packet-dcerpc-lsa.c,v 1.76 2003/04/28 04:44:53 tpot Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -346,6 +346,11 @@ lsa_specific_rights(tvbuff_t *tvb, gint offset, proto_tree *tree,
tree, hf_view_local_info, tvb, offset, 4, access);
}
struct access_mask_info lsa_access_mask_info = {
"LSA", /* Name of specific rights */
lsa_specific_rights /* Dissection function */
};
int
lsa_dissect_LSA_SECURITY_DESCRIPTOR_data(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree,
@ -364,8 +369,7 @@ lsa_dissect_LSA_SECURITY_DESCRIPTOR_data(tvbuff_t *tvb, int offset,
hf_lsa_sd_size, &len);
dissect_nt_sec_desc(
tvb, offset, pinfo, tree, drep, len, lsa_specific_rights,
"LSA");
tvb, offset, pinfo, tree, drep, len, &lsa_access_mask_info);
offset += len;
@ -445,7 +449,7 @@ lsa_dissect_ACCESS_MASK(tvbuff_t *tvb, int offset,
{
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_lsa_access_mask,
lsa_specific_rights, "LSA");
&lsa_access_mask_info);
return offset;
}

View File

@ -3,7 +3,7 @@
* Copyright 2001,2003 Tim Potter <tpot@samba.org>
* 2002 Added all command dissectors Ronnie Sahlberg
*
* $Id: packet-dcerpc-samr.c,v 1.84 2003/04/27 00:49:13 sahlberg Exp $
* $Id: packet-dcerpc-samr.c,v 1.85 2003/04/28 04:44:53 tpot Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -244,6 +244,11 @@ specific_rights_connect(tvbuff_t *tvb, gint offset, proto_tree *tree,
tvb, offset, 4, access);
}
struct access_mask_info samr_connect_access_mask_info = {
"SAMR connect",
specific_rights_connect
};
/* Dissect domain specific access rights */
static gint hf_access_domain_lookup_info1 = -1;
@ -307,6 +312,11 @@ specific_rights_domain(tvbuff_t *tvb, gint offset, proto_tree *tree,
tvb, offset, 4, access);
}
struct access_mask_info samr_domain_access_mask_info = {
"SAMR domain",
specific_rights_domain
};
/* Dissect user specific access rights */
static gint hf_access_user_get_name_etc = -1;
@ -370,6 +380,11 @@ specific_rights_user(tvbuff_t *tvb, gint offset, proto_tree *tree,
tvb, offset, 4, access);
}
struct access_mask_info samr_user_access_mask_info = {
"SAMR user",
specific_rights_user
};
/* Dissect alias specific access rights */
static gint hf_access_alias_add_member = -1;
@ -403,6 +418,11 @@ specific_rights_alias(tvbuff_t *tvb, gint offset, proto_tree *tree,
tvb, offset, 4, access);
}
struct access_mask_info samr_alias_access_mask_info = {
"SAMR alias",
specific_rights_alias
};
/* Dissect group specific access rights */
static gint hf_access_group_lookup_info = -1;
@ -436,6 +456,11 @@ specific_rights_group(tvbuff_t *tvb, gint offset, proto_tree *tree,
tvb, offset, 4, access);
}
struct access_mask_info samr_group_access_mask_info = {
"SAMR group",
specific_rights_group
};
int
dissect_ndr_nt_SID(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, char *drep)
@ -1140,7 +1165,7 @@ samr_dissect_connect2_rqst(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_connect, "SAMR connect");
&samr_connect_access_mask_info);
return offset;
}
@ -1161,7 +1186,7 @@ samr_dissect_connect4_rqst(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_connect, "SAMR connect");
&samr_connect_access_mask_info);
return offset;
}
@ -1350,7 +1375,7 @@ samr_dissect_open_domain_rqst(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_domain, "SAMR domain");
&samr_domain_access_mask_info);
offset = dissect_ndr_pointer_cb(
tvb, offset, pinfo, tree, drep, dissect_ndr_nt_SID,
@ -1470,7 +1495,7 @@ samr_dissect_create_alias_in_domain_rqst(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_alias, "SAMR alias");
&samr_alias_access_mask_info);
return offset;
}
@ -2011,7 +2036,7 @@ samr_dissect_create_user2_in_domain_rqst(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_user, "SAMR user");
&samr_user_access_mask_info);
return offset;
}
@ -2030,7 +2055,7 @@ samr_dissect_create_user2_in_domain_reply(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access_granted,
specific_rights_user, "SAMR user");
&samr_user_access_mask_info);
offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
hf_samr_rid, NULL);
@ -4518,7 +4543,7 @@ samr_dissect_open_group_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_group, "SAMR group");
&samr_group_access_mask_info);
offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
hf_samr_rid, &rid);
@ -4573,7 +4598,7 @@ samr_dissect_open_alias_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_alias, "SAMR alias");
&samr_alias_access_mask_info);
offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
hf_samr_rid, &rid);
@ -4657,7 +4682,7 @@ samr_dissect_create_group_in_domain_rqst(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_samr_access,
specific_rights_group, "SAMR group");
&samr_group_access_mask_info);
return offset;
}

View File

@ -2,7 +2,7 @@
* Routines for SMB \PIPE\spoolss packet disassembly
* Copyright 2001-2003, Tim Potter <tpot@samba.org>
*
* $Id: packet-dcerpc-spoolss.c,v 1.96 2003/04/27 00:49:14 sahlberg Exp $
* $Id: packet-dcerpc-spoolss.c,v 1.97 2003/04/28 04:44:54 tpot Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -333,6 +333,11 @@ spoolss_specific_rights(tvbuff_t *tvb, gint offset, proto_tree *tree,
tree, hf_server_access_admin, tvb, offset, 4, access);
}
struct access_mask_info spoolss_access_mask_info = {
"SPOOLSS",
spoolss_specific_rights
};
/*
* Routines to dissect a spoolss BUFFER
*/
@ -2244,7 +2249,7 @@ static int dissect_PRINTER_INFO_2(tvbuff_t *tvb, int offset,
dissect_nt_sec_desc(
tvb, secdesc_offset, pinfo, tree, drep,
tvb_length_remaining(tvb, secdesc_offset),
spoolss_specific_rights, "SPOOLSS");
&spoolss_access_mask_info);
offset = dissect_printer_attributes(tvb, offset, pinfo, tree, drep);
@ -2293,8 +2298,7 @@ static int dissect_PRINTER_INFO_3(tvbuff_t *tvb, int offset,
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, drep,
tvb_length_remaining(tvb, offset),
spoolss_specific_rights, "SPOOLSS");
tvb_length_remaining(tvb, offset), &spoolss_access_mask_info);
return offset;
}
@ -2477,7 +2481,7 @@ static int SpoolssOpenPrinterEx_q(tvbuff_t *tvb, int offset,
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_access_required,
spoolss_specific_rights, "SPOOLSS");
&spoolss_access_mask_info);
offset = dissect_USER_LEVEL_CTR(tvb, offset, pinfo, tree, drep);
@ -3319,7 +3323,7 @@ dissect_SEC_DESC_BUF(tvbuff_t *tvb, int offset, packet_info *pinfo,
dissect_nt_sec_desc(
tvb, offset, pinfo, subtree, drep, len,
spoolss_specific_rights, "SPOOLSS");
&spoolss_access_mask_info);
offset += len;
@ -4465,7 +4469,7 @@ dissect_spoolss_JOB_INFO_2(tvbuff_t *tvb, int offset, packet_info *pinfo,
dissect_nt_sec_desc(
tvb, secdesc_offset, pinfo, subtree, drep,
tvb_length_remaining(tvb, secdesc_offset),
spoolss_specific_rights, "SPOOLSS");
&spoolss_access_mask_info);
offset = dissect_job_status(tvb, offset, pinfo, subtree, drep);

View File

@ -3,7 +3,7 @@
* Copyright 2003, Tim Potter <tpot@samba.org>
* Copyright 2003, Ronnie Sahlberg, added function dissectors
*
* $Id: packet-dcerpc-svcctl.c,v 1.6 2003/04/27 17:46:15 sharpe Exp $
* $Id: packet-dcerpc-svcctl.c,v 1.7 2003/04/28 04:44:54 tpot Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -95,6 +95,11 @@ svcctl_scm_specific_rights(tvbuff_t *tvb, gint offset, proto_tree *tree,
proto_tree_add_boolean(tree, hf_svcctl_scm_rights_connect, tvb, offset, 4, access);
}
struct access_mask_info svcctl_scm_access_mask_info = {
"SVCCTL",
svcctl_scm_specific_rights
};
/*
* IDL long OpenSCManager(
* IDL [in] [string] [unique] char *MachineName,
@ -125,7 +130,7 @@ svcctl_dissect_OpenSCManager_rqst(tvbuff_t *tvb, int offset,
/* access mask */
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_svcctl_access_mask,
svcctl_scm_specific_rights, "SVCCTL");
&svcctl_scm_access_mask_info);
return offset;
}

View File

@ -2,7 +2,7 @@
* Routines for SMB packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-smb-common.h,v 1.20 2003/04/03 05:43:59 tpot Exp $
* $Id: packet-smb-common.h,v 1.21 2003/04/28 04:44:54 tpot Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -58,20 +58,25 @@ int dissect_smb_64bit_time(tvbuff_t *tvb, proto_tree *tree, int offset, int hf_d
int dissect_nt_sid(tvbuff_t *tvb, int offset, proto_tree *parent_tree,
char *name, char **sid_str);
/* Stuff for dissecting NT access masks */
typedef void (nt_access_mask_fn_t)(tvbuff_t *tvb, gint offset,
proto_tree *tree, guint32 access);
struct access_mask_info {
char *specific_rights_name;
nt_access_mask_fn_t *specific_rights_fn;
};
int
dissect_nt_access_mask(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, char *drep, int hfindex,
nt_access_mask_fn_t *specific_rights_fn,
char *specific_rights_name);
struct access_mask_info *ami);
int
dissect_nt_sec_desc(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *parent_tree, char *drep, int len,
nt_access_mask_fn_t *specific_rights_fn,
char *specific_rights_name);
struct access_mask_info *ami);
extern const value_string share_type_vals[];

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.334 2003/04/27 23:52:11 guy Exp $
* $Id: packet-smb.c,v 1.335 2003/04/28 04:44:54 tpot Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -7239,8 +7239,7 @@ static int hf_access_specific_0 = -1;
int
dissect_nt_access_mask(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, char *drep, int hfindex,
nt_access_mask_fn_t *specific_rights_fn,
char *specific_rights_name)
struct access_mask_info *ami)
{
proto_item *item;
proto_tree *subtree, *generic, *standard, *specific;
@ -7338,10 +7337,10 @@ dissect_nt_access_mask(tvbuff_t *tvb, gint offset, packet_info *pinfo,
pointer if we have one, otherwise just display bits 0-15 in
boring fashion. */
if (specific_rights_name)
if (ami->specific_rights_name)
item = proto_tree_add_text(subtree, tvb, offset - 4, 4,
"%s specific rights: 0x%08x",
specific_rights_name,
ami->specific_rights_name,
access & SPECIFIC_RIGHTS_MASK);
else
item = proto_tree_add_text(subtree, tvb, offset - 4, 4,
@ -7350,8 +7349,8 @@ dissect_nt_access_mask(tvbuff_t *tvb, gint offset, packet_info *pinfo,
specific = proto_item_add_subtree(item, ett_nt_access_mask_specific);
if (specific_rights_fn) {
specific_rights_fn(tvb, offset - 4, specific, access);
if (ami->specific_rights_fn) {
ami->specific_rights_fn(tvb, offset - 4, specific, access);
return offset;
}
@ -7427,8 +7426,7 @@ static int hf_smb_access_mask = -1;
static int
dissect_nt_v2_ace(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *parent_tree, char *drep,
nt_access_mask_fn_t *specific_rights_fn,
char *specific_rights_name)
struct access_mask_info *ami)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
@ -7459,8 +7457,7 @@ dissect_nt_v2_ace(tvbuff_t *tvb, int offset, packet_info *pinfo,
/* access mask */
offset = dissect_nt_access_mask(
tvb, offset, pinfo, tree, drep, hf_smb_access_mask,
specific_rights_fn, specific_rights_name);
tvb, offset, pinfo, tree, drep, hf_smb_access_mask, ami);
/* SID */
offset = dissect_nt_sid(tvb, offset, tree, "ACE", &sid_str);
@ -7483,8 +7480,7 @@ dissect_nt_v2_ace(tvbuff_t *tvb, int offset, packet_info *pinfo,
static int
dissect_nt_acl(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *parent_tree, char *drep, char *name,
nt_access_mask_fn_t *specific_rights_fn,
char *specific_rights_name)
struct access_mask_info *ami)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
@ -7519,8 +7515,7 @@ dissect_nt_acl(tvbuff_t *tvb, int offset, packet_info *pinfo,
while(num_aces--){
offset=dissect_nt_v2_ace(
tvb, offset, pinfo, tree, drep, specific_rights_fn,
specific_rights_name);
tvb, offset, pinfo, tree, drep, ami);
}
}
@ -7631,8 +7626,7 @@ dissect_nt_sec_desc_type(tvbuff_t *tvb, int offset, proto_tree *parent_tree)
int
dissect_nt_sec_desc(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *parent_tree, char *drep, int len,
nt_access_mask_fn_t *specific_rights_fn,
char *specific_rights_name)
struct access_mask_info *ami)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
@ -7702,15 +7696,13 @@ dissect_nt_sec_desc(tvbuff_t *tvb, int offset, packet_info *pinfo,
/* sacl */
if(sacl_offset){
dissect_nt_acl(tvb, old_offset+sacl_offset, pinfo, tree,
drep, "System (SACL)", specific_rights_fn,
specific_rights_name);
drep, "System (SACL)", ami);
}
/* dacl */
if(dacl_offset){
dissect_nt_acl(tvb, old_offset+dacl_offset, pinfo, tree,
drep, "User (DACL)", specific_rights_fn,
specific_rights_name);
drep, "User (DACL)", ami);
}
}
@ -7797,7 +7789,7 @@ dissect_nt_trans_data_request(tvbuff_t *tvb, packet_info *pinfo, int offset, pro
if(ntd->sd_len){
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, NULL, ntd->sd_len,
NULL, NULL);
NULL);
}
/* extended attributes */
@ -7815,7 +7807,7 @@ dissect_nt_trans_data_request(tvbuff_t *tvb, packet_info *pinfo, int offset, pro
break;
case NT_TRANS_SSD:
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, NULL, bc, NULL, NULL);
tvb, offset, pinfo, tree, NULL, bc, NULL);
break;
case NT_TRANS_NOTIFY:
break;
@ -8317,7 +8309,7 @@ dissect_nt_trans_data_response(tvbuff_t *tvb, packet_info *pinfo,
* somewhere.
*/
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, NULL, len, NULL, NULL);
tvb, offset, pinfo, tree, NULL, len, NULL);
break;
}
case NT_TRANS_GET_USER_QUOTA: