1 /* packet-dcerpc-lsa-ds.c
2 * Routines for SMB \PIPE\lsarpc packet disassembly
3 * Copyright 2002, Tim Potter <tpot@samba.org>
4 * Copyright 2002, Jim McDonough <jmcd@samba.org>
6 * $Id: packet-dcerpc-lsa-ds.c,v 1.5 2002/11/19 05:28:16 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);
81 offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
82 hf_lsa_ds_machine_role, 0);
85 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
86 hf_lsa_ds_dominfo_flags, 0);
88 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
89 dissect_ndr_nt_UNICODE_STRING_str, NDR_POINTER_UNIQUE,
90 "NetBIOS domain name pointer", hf_lsa_ds_dominfo_netb_name, 0);
91 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
92 dissect_ndr_nt_UNICODE_STRING_str, NDR_POINTER_UNIQUE,
93 "DNS domain pointer", hf_lsa_ds_dominfo_dns_name, 0);
94 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
95 dissect_ndr_nt_UNICODE_STRING_str, NDR_POINTER_UNIQUE,
96 "DNS forest name pointer", hf_lsa_ds_dominfo_forest_name, 0);
99 offset = dissect_nt_GUID(tvb, offset, pinfo, tree, drep);
101 proto_item_set_len(item, offset-old_offset);
106 lsa_ds_dissect_DSROLE_UPGRADE_STATUS(tvbuff_t *tvb, int offset,
108 proto_tree *parent_tree, char *drep)
110 proto_item *item=NULL;
111 proto_tree *tree=NULL;
112 int old_offset=offset;
115 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
116 "DSROLE_UPGRADE_STATUS:");
117 tree = proto_item_add_subtree(item,
118 ett_lsa_ds_upgrade_status);
121 offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
122 hf_lsa_ds_upgrade_state, NULL);
123 offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
124 hf_lsa_ds_previous_role, NULL);
125 proto_item_set_len(item, offset-old_offset);
131 lsa_ds_dissect_DSROLE_OP_STATUS(tvbuff_t *tvb, int offset,
133 proto_tree *parent_tree, char *drep)
135 proto_item *item=NULL;
136 proto_tree *tree=NULL;
137 int old_offset=offset;
140 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
141 "DSROLE_OP_STATUS:");
142 tree = proto_item_add_subtree(item,
143 ett_lsa_ds_op_status);
145 offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
146 hf_lsa_ds_op_status, NULL);
147 proto_item_set_len(item, offset-old_offset);
153 lsa_ds_dissect_DS_DOMINFO_CTR(tvbuff_t *tvb, int offset,
154 packet_info *pinfo, proto_tree *parent_tree, char *drep)
156 proto_item *item=NULL;
157 proto_tree *tree=NULL;
158 int old_offset=offset;
162 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
164 tree = proto_item_add_subtree(item, ett_lsa_ds_domain_info);
167 offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
168 hf_lsa_ds_dominfo_level, &level);
171 case LSA_DS_DSROLE_BASIC_INFO:
172 offset = lsa_ds_dissect_DSROLE_BASIC_INFO(
173 tvb, offset, pinfo, tree, drep);
175 case LSA_DS_DSROLE_UPGRADE_STATUS:
176 offset = lsa_ds_dissect_DSROLE_UPGRADE_STATUS(
177 tvb, offset, pinfo, tree, drep);
179 case LSA_DS_DSROLE_OP_STATUS:
180 offset = lsa_ds_dissect_DSROLE_OP_STATUS(
181 tvb, offset, pinfo, tree, drep);
184 proto_item_set_len(item, offset-old_offset);
190 lsa_ds_dissect_role_get_dom_info_rqst(tvbuff_t *tvb, int offset,
191 packet_info *pinfo, proto_tree *tree, char *drep)
193 offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
194 hf_lsa_ds_dominfo_level, NULL);
199 lsa_ds_dissect_role_get_dom_info_reply(tvbuff_t *tvb, int offset,
200 packet_info *pinfo, proto_tree *tree, char *drep)
202 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
203 lsa_ds_dissect_DS_DOMINFO_CTR, NDR_POINTER_UNIQUE,
204 "DOMAIN_INFORMATION pointer", -1, 0);
206 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
213 static const value_string lsa_ds_opnum_vals[] = {
214 { LSA_DS_DSROLEGETDOMINFO, "DsRoleGetDomInfo" },
218 static const value_string lsa_ds_dominfo_levels[] = {
219 { LSA_DS_DSROLE_BASIC_INFO, "DsRoleBasicInfo"},
220 { LSA_DS_DSROLE_UPGRADE_STATUS, "DsRoleUpgradeStatus"},
221 { LSA_DS_DSROLE_OP_STATUS, "DsRoleOpStatus"},
225 static const value_string lsa_ds_upgrade_vals[] = {
226 { 0, "Not currently upgrading"},
227 { 1, "Upgrade in progress"},
231 static const value_string lsa_ds_previous_roles[] = {
232 { 0, "Unknown state" },
237 static const value_string lsa_ds_op_states[] = {
240 { 2, "Needs reboot" }
244 proto_register_dcerpc_lsa_ds(void)
246 static hf_register_info hf[] = {
249 { "Operation", "ls_ads.opnum", FT_UINT16, BASE_DEC,
250 VALS(lsa_ds_opnum_vals), 0x0, "Operation", HFILL }},
252 { &hf_lsa_ds_dominfo_level,
253 { "Level", "lsa_ds.dominfo.level", FT_UINT16, BASE_DEC,
254 VALS(lsa_ds_dominfo_levels), 0x0,
255 "Information level of requested data", HFILL }},
257 { &hf_lsa_ds_machine_role,
258 { "Machine role", "lsa_ds.role", FT_UINT16, BASE_HEX,
259 NULL, 0x0, "Role of machine in domain", HFILL}},
261 { &hf_lsa_ds_dominfo_flags,
262 { "Flags", "lsa_ds.dominfo.flags", FT_UINT32, BASE_HEX,
263 NULL, 0x0, "Machine flags", HFILL }},
265 { &hf_lsa_ds_dominfo_netb_name,
266 { "Netbios name", "lsa_ds.dominfo.nbname", FT_STRING, BASE_NONE,
267 NULL, 0x0, "Netbios Domain Name", HFILL}},
269 { &hf_lsa_ds_dominfo_dns_name,
270 { "DNS name", "lsa_ds.dominfo.dnsname", FT_STRING, BASE_NONE,
271 NULL, 0x0, "DNS Domain Name", HFILL}},
273 { &hf_lsa_ds_dominfo_forest_name,
274 { "Forest name", "lsa_ds.dominfo.forest", FT_STRING, BASE_NONE,
275 NULL, 0x0, "DNS Forest Name", HFILL}},
277 { &hf_lsa_ds_upgrade_state,
278 { "Upgrading", "ls_ads.upgrading", FT_UINT32, BASE_DEC,
279 VALS(lsa_ds_upgrade_vals), 0x0, "Upgrade State", HFILL }},
281 { &hf_lsa_ds_previous_role,
282 { "Previous role", "ls_ads.upgrading", FT_UINT16, BASE_DEC,
283 VALS(lsa_ds_previous_roles), 0x0,
284 "Previous server role before upgrade", HFILL }},
286 { &hf_lsa_ds_op_status,
287 { "Operational status", "ls_ads.op_status", FT_UINT16, BASE_DEC,
288 VALS(lsa_ds_op_states), 0x0,
289 "Current operational status", HFILL }},
292 { "Return code", "lsa_ds.rc", FT_UINT32, BASE_HEX,
293 VALS (NT_errors), 0x0, "LSA_DS return status code", HFILL }},
296 static gint *ett[] = {
298 &ett_lsa_ds_domain_info,
299 &ett_lsa_ds_basic_domain_info,
300 &ett_lsa_ds_upgrade_status,
301 &ett_lsa_ds_op_status
304 proto_dcerpc_lsa_ds = proto_register_protocol(
305 "Microsoft Local Security Architecture (Directory Services)",
307 proto_register_field_array(proto_dcerpc_lsa_ds, hf, array_length(hf));
308 proto_register_subtree_array(ett, array_length(ett));
311 /* Protocol handoff */
313 static e_uuid_t uuid_dcerpc_lsa_ds = {
314 0x3919286a, 0xb10c, 0x11d0,
315 { 0x9b, 0xa8, 0x00, 0xc0, 0x4f, 0xd9, 0x2e, 0xf5}
318 static guint16 ver_dcerpc_lsa_ds = 0;
320 static dcerpc_sub_dissector lsa_ds_dissectors[] = {
321 { LSA_DS_DSROLEGETDOMINFO, "DsRoleGetDomInfo",
322 lsa_ds_dissect_role_get_dom_info_rqst,
323 lsa_ds_dissect_role_get_dom_info_reply },
324 { 0, NULL, NULL, NULL },
328 proto_reg_handoff_dcerpc_lsa_ds(void)
330 /* Register protocol as dcerpc */
332 dcerpc_init_uuid(proto_dcerpc_lsa_ds, ett_dcerpc_lsa_ds,
333 &uuid_dcerpc_lsa_ds, ver_dcerpc_lsa_ds,
334 lsa_ds_dissectors, -1);