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.12 2003/08/04 02:49:02 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_ntstatus(
214 tvb, offset, pinfo, tree, drep, hf_lsa_ds_rc, NULL);
219 static const value_string lsa_ds_dominfo_levels[] = {
220 { LSA_DS_DSROLE_BASIC_INFO, "DsRoleBasicInfo"},
221 { LSA_DS_DSROLE_UPGRADE_STATUS, "DsRoleUpgradeStatus"},
222 { LSA_DS_DSROLE_OP_STATUS, "DsRoleOpStatus"},
226 static const value_string lsa_ds_role_vals[] = {
227 { 0, "Standalone Workstation" },
228 { 1, "Domain Member Workstation" },
229 { 2, "Standalone Server" },
230 { 3, "Domain Member Server" },
231 { 4, "Backup Domain Controller" },
232 { 5, "Primary Domain Controller" },
236 static const value_string lsa_ds_upgrade_vals[] = {
237 { 0, "Not currently upgrading"},
238 { 1, "Upgrade in progress"},
242 static const value_string lsa_ds_previous_roles[] = {
243 { 0, "Unknown state" },
249 static const value_string lsa_ds_op_states[] = {
252 { 2, "Needs reboot" },
257 proto_register_dcerpc_lsa_ds(void)
259 static hf_register_info hf[] = {
262 { "Operation", "ls_ads.opnum", FT_UINT16, BASE_DEC,
263 NULL, 0x0, "Operation", HFILL }},
265 { &hf_lsa_ds_dominfo_level,
266 { "Level", "lsa_ds.dominfo.level", FT_UINT16, BASE_DEC,
267 VALS(lsa_ds_dominfo_levels), 0x0,
268 "Information level of requested data", HFILL }},
270 { &hf_lsa_ds_machine_role,
271 { "Machine role", "lsa_ds.role", FT_UINT16, BASE_HEX,
272 VALS(lsa_ds_role_vals), 0x0, "Role of machine in domain", HFILL}},
274 { &hf_lsa_ds_dominfo_flags,
275 { "Flags", "lsa_ds.dominfo.flags", FT_UINT32, BASE_HEX,
276 NULL, 0x0, "Machine flags", HFILL }},
278 { &hf_lsa_ds_dominfo_netb_name,
279 { "Netbios name", "lsa_ds.dominfo.nbname", FT_STRING, BASE_NONE,
280 NULL, 0x0, "Netbios Domain Name", HFILL}},
282 { &hf_lsa_ds_dominfo_dns_name,
283 { "DNS name", "lsa_ds.dominfo.dnsname", FT_STRING, BASE_NONE,
284 NULL, 0x0, "DNS Domain Name", HFILL}},
286 { &hf_lsa_ds_dominfo_forest_name,
287 { "Forest name", "lsa_ds.dominfo.forest", FT_STRING, BASE_NONE,
288 NULL, 0x0, "DNS Forest Name", HFILL}},
290 { &hf_lsa_ds_upgrade_state,
291 { "Upgrading", "ls_ads.upgrading", FT_UINT32, BASE_DEC,
292 VALS(lsa_ds_upgrade_vals), 0x0, "Upgrade State", HFILL }},
294 { &hf_lsa_ds_previous_role,
295 { "Previous role", "ls_ads.upgrading", FT_UINT16, BASE_DEC,
296 VALS(lsa_ds_previous_roles), 0x0,
297 "Previous server role before upgrade", HFILL }},
299 { &hf_lsa_ds_op_status,
300 { "Operational status", "ls_ads.op_status", FT_UINT16, BASE_DEC,
301 VALS(lsa_ds_op_states), 0x0,
302 "Current operational status", HFILL }},
305 { "Return code", "lsa_ds.rc", FT_UINT32, BASE_HEX,
306 VALS (NT_errors), 0x0, "LSA_DS return status code", HFILL }},
309 static gint *ett[] = {
311 &ett_lsa_ds_domain_info,
312 &ett_lsa_ds_basic_domain_info,
313 &ett_lsa_ds_upgrade_status,
314 &ett_lsa_ds_op_status
317 proto_dcerpc_lsa_ds = proto_register_protocol(
318 "Microsoft Local Security Architecture (Directory Services)",
320 proto_register_field_array(proto_dcerpc_lsa_ds, hf, array_length(hf));
321 proto_register_subtree_array(ett, array_length(ett));
324 /* Protocol handoff */
326 static e_uuid_t uuid_dcerpc_lsa_ds = {
327 0x3919286a, 0xb10c, 0x11d0,
328 { 0x9b, 0xa8, 0x00, 0xc0, 0x4f, 0xd9, 0x2e, 0xf5}
331 static guint16 ver_dcerpc_lsa_ds = 0;
333 static dcerpc_sub_dissector lsa_ds_dissectors[] = {
334 { LSA_DS_DSROLEGETDOMINFO, "DsRoleGetDomInfo",
335 lsa_ds_dissect_role_get_dom_info_rqst,
336 lsa_ds_dissect_role_get_dom_info_reply },
337 { 0, NULL, NULL, NULL },
341 proto_reg_handoff_dcerpc_lsa_ds(void)
343 /* Register protocol as dcerpc */
345 dcerpc_init_uuid(proto_dcerpc_lsa_ds, ett_dcerpc_lsa_ds,
346 &uuid_dcerpc_lsa_ds, ver_dcerpc_lsa_ds,
347 lsa_ds_dissectors, hf_lsa_ds_opnum);