1 /* packet-dcerpc-lsa-ds.c
2 * Routines for SMB \PIPE\lsarpc packet disassembly
3 * Copyright 2002-2003, Tim Potter <tpot@samba.org>
4 * Copyright 2002, Jim McDonough <jmcd@samba.org>
6 * $Id: packet-dcerpc-lsa-ds.c,v 1.9 2003/02/14 06:14:27 tpot Exp $
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
35 #include "packet-dcerpc.h"
36 #include "packet-dcerpc-nt.h"
39 #define LSA_DS_DSROLEGETDOMINFO 0x0000
41 #define LSA_DS_DSROLE_BASIC_INFO 0x0001
42 #define LSA_DS_DSROLE_UPGRADE_STATUS 0x0002
43 #define LSA_DS_DSROLE_OP_STATUS 0x0003
45 static int proto_dcerpc_lsa_ds = -1;
47 static int hf_lsa_ds_opnum = -1;
48 static int hf_lsa_ds_dominfo_level = -1;
49 static int hf_lsa_ds_machine_role = -1;
50 static int hf_lsa_ds_dominfo_flags = -1;
51 static int hf_lsa_ds_dominfo_netb_name = -1;
52 static int hf_lsa_ds_dominfo_dns_name = -1;
53 static int hf_lsa_ds_dominfo_forest_name = -1;
54 static int hf_lsa_ds_upgrade_state = -1;
55 static int hf_lsa_ds_previous_role = -1;
56 static int hf_lsa_ds_op_status = -1;
57 static int hf_lsa_ds_rc = -1;
59 static gint ett_dcerpc_lsa_ds = -1;
60 static gint ett_lsa_ds_domain_info = -1;
61 static gint ett_lsa_ds_basic_domain_info = -1;
62 static gint ett_lsa_ds_upgrade_status = -1;
63 static gint ett_lsa_ds_op_status = -1;
66 lsa_ds_dissect_DSROLE_BASIC_INFO(tvbuff_t *tvb, int offset,
67 packet_info *pinfo, proto_tree *parent_tree, char *drep)
69 proto_item *item=NULL;
70 proto_tree *tree=NULL;
71 int old_offset=offset;
74 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
75 "DSROLE_BASIC_DOMAIN_INFO:");
76 tree = proto_item_add_subtree(item,
77 ett_lsa_ds_basic_domain_info);
82 offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
83 hf_lsa_ds_machine_role, 0);
86 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
87 hf_lsa_ds_dominfo_flags, 0);
89 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
90 NDR_POINTER_UNIQUE, "NetBIOS domain name pointer",
91 hf_lsa_ds_dominfo_netb_name, 0);
92 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
93 NDR_POINTER_UNIQUE, "DNS domain pointer",
94 hf_lsa_ds_dominfo_dns_name, 0);
95 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
96 NDR_POINTER_UNIQUE, "DNS forest name pointer",
97 hf_lsa_ds_dominfo_forest_name, 0);
100 offset = dissect_nt_GUID(tvb, offset, pinfo, tree, drep);
102 proto_item_set_len(item, offset-old_offset);
107 lsa_ds_dissect_DSROLE_UPGRADE_STATUS(tvbuff_t *tvb, int offset,
109 proto_tree *parent_tree, char *drep)
111 proto_item *item=NULL;
112 proto_tree *tree=NULL;
113 int old_offset=offset;
116 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
117 "DSROLE_UPGRADE_STATUS:");
118 tree = proto_item_add_subtree(item,
119 ett_lsa_ds_upgrade_status);
122 offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
123 hf_lsa_ds_upgrade_state, NULL);
124 offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
125 hf_lsa_ds_previous_role, NULL);
126 proto_item_set_len(item, offset-old_offset);
132 lsa_ds_dissect_DSROLE_OP_STATUS(tvbuff_t *tvb, int offset,
134 proto_tree *parent_tree, char *drep)
136 proto_item *item=NULL;
137 proto_tree *tree=NULL;
138 int old_offset=offset;
141 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
142 "DSROLE_OP_STATUS:");
143 tree = proto_item_add_subtree(item,
144 ett_lsa_ds_op_status);
146 offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
147 hf_lsa_ds_op_status, NULL);
148 proto_item_set_len(item, offset-old_offset);
154 lsa_ds_dissect_DS_DOMINFO_CTR(tvbuff_t *tvb, int offset,
155 packet_info *pinfo, proto_tree *parent_tree, char *drep)
157 proto_item *item=NULL;
158 proto_tree *tree=NULL;
159 int old_offset=offset;
163 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
165 tree = proto_item_add_subtree(item, ett_lsa_ds_domain_info);
168 offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
169 hf_lsa_ds_dominfo_level, &level);
172 case LSA_DS_DSROLE_BASIC_INFO:
173 offset = lsa_ds_dissect_DSROLE_BASIC_INFO(
174 tvb, offset, pinfo, tree, drep);
176 case LSA_DS_DSROLE_UPGRADE_STATUS:
177 offset = lsa_ds_dissect_DSROLE_UPGRADE_STATUS(
178 tvb, offset, pinfo, tree, drep);
180 case LSA_DS_DSROLE_OP_STATUS:
181 offset = lsa_ds_dissect_DSROLE_OP_STATUS(
182 tvb, offset, pinfo, tree, drep);
185 proto_item_set_len(item, offset-old_offset);
191 lsa_ds_dissect_role_get_dom_info_rqst(tvbuff_t *tvb, int offset,
192 packet_info *pinfo, proto_tree *tree, char *drep)
196 offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
197 hf_lsa_ds_dominfo_level, &level);
199 if (check_col(pinfo->cinfo, COL_INFO))
200 col_append_fstr(pinfo->cinfo, COL_INFO, ", level %d", level);
206 lsa_ds_dissect_role_get_dom_info_reply(tvbuff_t *tvb, int offset,
207 packet_info *pinfo, proto_tree *tree, char *drep)
209 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
210 lsa_ds_dissect_DS_DOMINFO_CTR, NDR_POINTER_UNIQUE,
211 "DOMAIN_INFORMATION pointer", -1);
213 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
220 static const value_string lsa_ds_opnum_vals[] = {
221 { LSA_DS_DSROLEGETDOMINFO, "DsRoleGetDomInfo" },
225 static const value_string lsa_ds_dominfo_levels[] = {
226 { LSA_DS_DSROLE_BASIC_INFO, "DsRoleBasicInfo"},
227 { LSA_DS_DSROLE_UPGRADE_STATUS, "DsRoleUpgradeStatus"},
228 { LSA_DS_DSROLE_OP_STATUS, "DsRoleOpStatus"},
232 static const value_string lsa_ds_role_vals[] = {
233 { 0, "Standalone Workstation" },
234 { 1, "Domain Member Workstation" },
235 { 2, "Standalone Server" },
236 { 3, "Domain Member Server" },
237 { 4, "Backup Domain Controller" },
238 { 5, "Primary Domain Controller" },
242 static const value_string lsa_ds_upgrade_vals[] = {
243 { 0, "Not currently upgrading"},
244 { 1, "Upgrade in progress"},
248 static const value_string lsa_ds_previous_roles[] = {
249 { 0, "Unknown state" },
255 static const value_string lsa_ds_op_states[] = {
258 { 2, "Needs reboot" },
263 proto_register_dcerpc_lsa_ds(void)
265 static hf_register_info hf[] = {
268 { "Operation", "ls_ads.opnum", FT_UINT16, BASE_DEC,
269 VALS(lsa_ds_opnum_vals), 0x0, "Operation", HFILL }},
271 { &hf_lsa_ds_dominfo_level,
272 { "Level", "lsa_ds.dominfo.level", FT_UINT16, BASE_DEC,
273 VALS(lsa_ds_dominfo_levels), 0x0,
274 "Information level of requested data", HFILL }},
276 { &hf_lsa_ds_machine_role,
277 { "Machine role", "lsa_ds.role", FT_UINT16, BASE_HEX,
278 VALS(lsa_ds_role_vals), 0x0, "Role of machine in domain", HFILL}},
280 { &hf_lsa_ds_dominfo_flags,
281 { "Flags", "lsa_ds.dominfo.flags", FT_UINT32, BASE_HEX,
282 NULL, 0x0, "Machine flags", HFILL }},
284 { &hf_lsa_ds_dominfo_netb_name,
285 { "Netbios name", "lsa_ds.dominfo.nbname", FT_STRING, BASE_NONE,
286 NULL, 0x0, "Netbios Domain Name", HFILL}},
288 { &hf_lsa_ds_dominfo_dns_name,
289 { "DNS name", "lsa_ds.dominfo.dnsname", FT_STRING, BASE_NONE,
290 NULL, 0x0, "DNS Domain Name", HFILL}},
292 { &hf_lsa_ds_dominfo_forest_name,
293 { "Forest name", "lsa_ds.dominfo.forest", FT_STRING, BASE_NONE,
294 NULL, 0x0, "DNS Forest Name", HFILL}},
296 { &hf_lsa_ds_upgrade_state,
297 { "Upgrading", "ls_ads.upgrading", FT_UINT32, BASE_DEC,
298 VALS(lsa_ds_upgrade_vals), 0x0, "Upgrade State", HFILL }},
300 { &hf_lsa_ds_previous_role,
301 { "Previous role", "ls_ads.upgrading", FT_UINT16, BASE_DEC,
302 VALS(lsa_ds_previous_roles), 0x0,
303 "Previous server role before upgrade", HFILL }},
305 { &hf_lsa_ds_op_status,
306 { "Operational status", "ls_ads.op_status", FT_UINT16, BASE_DEC,
307 VALS(lsa_ds_op_states), 0x0,
308 "Current operational status", HFILL }},
311 { "Return code", "lsa_ds.rc", FT_UINT32, BASE_HEX,
312 VALS (NT_errors), 0x0, "LSA_DS return status code", HFILL }},
315 static gint *ett[] = {
317 &ett_lsa_ds_domain_info,
318 &ett_lsa_ds_basic_domain_info,
319 &ett_lsa_ds_upgrade_status,
320 &ett_lsa_ds_op_status
323 proto_dcerpc_lsa_ds = proto_register_protocol(
324 "Microsoft Local Security Architecture (Directory Services)",
326 proto_register_field_array(proto_dcerpc_lsa_ds, hf, array_length(hf));
327 proto_register_subtree_array(ett, array_length(ett));
330 /* Protocol handoff */
332 static e_uuid_t uuid_dcerpc_lsa_ds = {
333 0x3919286a, 0xb10c, 0x11d0,
334 { 0x9b, 0xa8, 0x00, 0xc0, 0x4f, 0xd9, 0x2e, 0xf5}
337 static guint16 ver_dcerpc_lsa_ds = 0;
339 static dcerpc_sub_dissector lsa_ds_dissectors[] = {
340 { LSA_DS_DSROLEGETDOMINFO, "DsRoleGetDomInfo",
341 lsa_ds_dissect_role_get_dom_info_rqst,
342 lsa_ds_dissect_role_get_dom_info_reply },
343 { 0, NULL, NULL, NULL },
347 proto_reg_handoff_dcerpc_lsa_ds(void)
349 /* Register protocol as dcerpc */
351 dcerpc_init_uuid(proto_dcerpc_lsa_ds, ett_dcerpc_lsa_ds,
352 &uuid_dcerpc_lsa_ds, ver_dcerpc_lsa_ds,
353 lsa_ds_dissectors, -1);