484a354ffd0246874333611c718032673498fd5e
[obnox/wireshark/wip.git] / packet-dcerpc-netlogon.c
1 /* packet-dcerpc-netlogon.c
2  * Routines for SMB \PIPE\NETLOGON packet disassembly
3  * Copyright 2001,2003 Tim Potter <tpot@samba.org>
4  *  2002 structure and command dissectors by Ronnie Sahlberg
5  *
6  * $Id: packet-dcerpc-netlogon.c,v 1.89 2003/09/11 13:24:19 sahlberg Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 1998 Gerald Combs
11  *
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.
16  *
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.
21  *
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.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <glib.h>
32 #include <epan/packet.h>
33 #include "packet-dcerpc.h"
34 #include "packet-dcerpc-nt.h"
35 #include "packet-dcerpc-netlogon.h"
36 #include "smb.h"        /* for "NT_errors[]" */
37 #include "packet-smb-common.h"
38 #include "packet-dcerpc-lsa.h"
39
40 static int proto_dcerpc_netlogon = -1;
41 static int hf_netlogon_opnum = -1;
42 static int hf_netlogon_guid = -1;
43 static int hf_netlogon_rc = -1;
44 static int hf_netlogon_len = -1;
45 static int hf_netlogon_sensitive_data_flag = -1;
46 static int hf_netlogon_sensitive_data_len = -1;
47 static int hf_netlogon_sensitive_data = -1;
48 static int hf_netlogon_security_information = -1;
49 static int hf_netlogon_dummy = -1;
50 static int hf_netlogon_neg_flags = -1;
51 static int hf_netlogon_minworkingsetsize = -1;
52 static int hf_netlogon_maxworkingsetsize = -1;
53 static int hf_netlogon_pagedpoollimit = -1;
54 static int hf_netlogon_pagefilelimit = -1;
55 static int hf_netlogon_timelimit = -1;
56 static int hf_netlogon_nonpagedpoollimit = -1;
57 static int hf_netlogon_pac_size = -1;
58 static int hf_netlogon_pac_data = -1;
59 static int hf_netlogon_auth_size = -1;
60 static int hf_netlogon_auth_data = -1;
61 static int hf_netlogon_cipher_len = -1;
62 static int hf_netlogon_cipher_maxlen = -1;
63 static int hf_netlogon_cipher_current_data = -1;
64 static int hf_netlogon_cipher_current_set_time = -1;
65 static int hf_netlogon_cipher_old_data = -1;
66 static int hf_netlogon_cipher_old_set_time = -1;
67 static int hf_netlogon_priv = -1;
68 static int hf_netlogon_privilege_entries = -1;
69 static int hf_netlogon_privilege_control = -1;
70 static int hf_netlogon_privilege_name = -1;
71 static int hf_netlogon_systemflags = -1;
72 static int hf_netlogon_pdc_connection_status = -1;
73 static int hf_netlogon_tc_connection_status = -1;
74 static int hf_netlogon_restart_state = -1;
75 static int hf_netlogon_attrs = -1;
76 static int hf_netlogon_count = -1;
77 static int hf_netlogon_entries = -1;
78 static int hf_netlogon_minpasswdlen = -1;
79 static int hf_netlogon_passwdhistorylen = -1;
80 static int hf_netlogon_level16 = -1;
81 static int hf_netlogon_validation_level = -1;
82 static int hf_netlogon_reference = -1;
83 static int hf_netlogon_next_reference = -1;
84 static int hf_netlogon_timestamp = -1;
85 static int hf_netlogon_level = -1;
86 static int hf_netlogon_challenge = -1;
87 static int hf_netlogon_reserved = -1;
88 static int hf_netlogon_audit_retention_period = -1;
89 static int hf_netlogon_auditing_mode = -1;
90 static int hf_netlogon_max_audit_event_count = -1;
91 static int hf_netlogon_event_audit_option = -1;
92 static int hf_netlogon_unknown_string = -1;
93 static int hf_netlogon_unknown_long = -1;
94 static int hf_netlogon_unknown_short = -1;
95 static int hf_netlogon_unknown_char = -1;
96 static int hf_netlogon_logon_time = -1;
97 static int hf_netlogon_logoff_time = -1;
98 static int hf_netlogon_kickoff_time = -1;
99 static int hf_netlogon_pwd_last_set_time = -1;
100 static int hf_netlogon_pwd_can_change_time = -1;
101 static int hf_netlogon_pwd_must_change_time = -1;
102 static int hf_netlogon_nt_chal_resp = -1;
103 static int hf_netlogon_lm_chal_resp = -1;
104 static int hf_netlogon_credential = -1;
105 static int hf_netlogon_acct_name = -1;
106 static int hf_netlogon_acct_desc = -1;
107 static int hf_netlogon_group_desc = -1;
108 static int hf_netlogon_full_name = -1;
109 static int hf_netlogon_comment = -1;
110 static int hf_netlogon_parameters = -1;
111 static int hf_netlogon_logon_script = -1;
112 static int hf_netlogon_profile_path = -1;
113 static int hf_netlogon_home_dir = -1;
114 static int hf_netlogon_dir_drive = -1;
115 static int hf_netlogon_logon_count = -1;
116 static int hf_netlogon_logon_count16 = -1;
117 static int hf_netlogon_bad_pw_count = -1;
118 static int hf_netlogon_bad_pw_count16 = -1;
119 static int hf_netlogon_user_rid = -1;
120 static int hf_netlogon_alias_rid = -1;
121 static int hf_netlogon_group_rid = -1;
122 static int hf_netlogon_logon_srv = -1;
123 static int hf_netlogon_principal = -1;
124 static int hf_netlogon_logon_dom = -1;
125 static int hf_netlogon_downlevel_domain_name = -1;
126 static int hf_netlogon_dns_domain_name = -1;
127 static int hf_netlogon_domain_name = -1;
128 static int hf_netlogon_domain_create_time = -1;
129 static int hf_netlogon_domain_modify_time = -1;
130 static int hf_netlogon_modify_count = -1;
131 static int hf_netlogon_db_modify_time = -1;
132 static int hf_netlogon_db_create_time = -1;
133 static int hf_netlogon_oem_info = -1;
134 static int hf_netlogon_serial_number = -1;
135 static int hf_netlogon_num_rids = -1;
136 static int hf_netlogon_num_trusts = -1;
137 static int hf_netlogon_num_controllers = -1;
138 static int hf_netlogon_num_other_groups = -1;
139 static int hf_netlogon_computer_name = -1;
140 static int hf_netlogon_site_name = -1;
141 static int hf_netlogon_trusted_dc_name = -1;
142 static int hf_netlogon_dc_name = -1;
143 static int hf_netlogon_dc_site_name = -1;
144 static int hf_netlogon_dns_forest_name = -1;
145 static int hf_netlogon_dc_address = -1;
146 static int hf_netlogon_dc_address_type = -1;
147 static int hf_netlogon_client_site_name = -1;
148 static int hf_netlogon_workstation = -1;
149 static int hf_netlogon_workstation_site_name = -1;
150 static int hf_netlogon_workstation_os = -1;
151 static int hf_netlogon_workstations = -1;
152 static int hf_netlogon_workstation_fqdn = -1;
153 static int hf_netlogon_group_name = -1;
154 static int hf_netlogon_alias_name = -1;
155 static int hf_netlogon_country = -1;
156 static int hf_netlogon_codepage = -1;
157 static int hf_netlogon_flags = -1;
158 static int hf_netlogon_trust_attribs = -1;
159 static int hf_netlogon_trust_type = -1;
160 static int hf_netlogon_trust_flags = -1;
161 static int hf_netlogon_trust_flags_inbound = -1;
162 static int hf_netlogon_trust_flags_outbound = -1;
163 static int hf_netlogon_trust_flags_in_forest = -1;
164 static int hf_netlogon_trust_flags_native_mode = -1;
165 static int hf_netlogon_trust_flags_primary = -1;
166 static int hf_netlogon_trust_flags_tree_root = -1;
167 static int hf_netlogon_trust_parent_index = -1;
168 static int hf_netlogon_user_flags = -1;
169 static int hf_netlogon_auth_flags = -1;
170 static int hf_netlogon_pwd_expired = -1;
171 static int hf_netlogon_nt_pwd_present = -1;
172 static int hf_netlogon_lm_pwd_present = -1;
173 static int hf_netlogon_code = -1;
174 static int hf_netlogon_database_id = -1;
175 static int hf_netlogon_sync_context = -1;
176 static int hf_netlogon_max_size = -1;
177 static int hf_netlogon_max_log_size = -1;
178 static int hf_netlogon_dns_host = -1;
179 static int hf_netlogon_acct_expiry_time = -1;
180 static int hf_netlogon_encrypted_lm_owf_password = -1;
181 static int hf_netlogon_lm_owf_password = -1;
182 static int hf_netlogon_nt_owf_password = -1;
183 static int hf_netlogon_param_ctrl = -1;
184 static int hf_netlogon_logon_id = -1;
185 static int hf_netlogon_num_deltas = -1;
186 static int hf_netlogon_user_session_key = -1;
187 static int hf_netlogon_blob_size = -1;
188 static int hf_netlogon_blob = -1;
189 static int hf_netlogon_logon_attempts = -1;
190 static int hf_netlogon_authoritative = -1;
191 static int hf_netlogon_secure_channel_type = -1;
192 static int hf_netlogon_logonsrv_handle = -1;
193 static int hf_netlogon_delta_type = -1;
194 static int hf_netlogon_get_dcname_request_flags = -1;
195 static int hf_netlogon_get_dcname_request_flags_force_rediscovery = -1;
196 static int hf_netlogon_get_dcname_request_flags_directory_service_required = -1;
197 static int hf_netlogon_get_dcname_request_flags_directory_service_preferred = -1;
198 static int hf_netlogon_get_dcname_request_flags_gc_server_required = -1;
199 static int hf_netlogon_get_dcname_request_flags_pdc_required = -1;
200 static int hf_netlogon_get_dcname_request_flags_background_only = -1;
201 static int hf_netlogon_get_dcname_request_flags_ip_required = -1;
202 static int hf_netlogon_get_dcname_request_flags_kdc_required = -1;
203 static int hf_netlogon_get_dcname_request_flags_timeserv_required = -1;
204 static int hf_netlogon_get_dcname_request_flags_writable_required = -1;
205 static int hf_netlogon_get_dcname_request_flags_good_timeserv_preferred = -1;
206 static int hf_netlogon_get_dcname_request_flags_avoid_self = -1;
207 static int hf_netlogon_get_dcname_request_flags_only_ldap_needed = -1;
208 static int hf_netlogon_get_dcname_request_flags_is_flat_name = -1;
209 static int hf_netlogon_get_dcname_request_flags_is_dns_name = -1;
210 static int hf_netlogon_get_dcname_request_flags_return_dns_name = -1;
211 static int hf_netlogon_get_dcname_request_flags_return_flat_name = -1;
212 static int hf_netlogon_dc_flags = -1;
213 static int hf_netlogon_dc_flags_pdc_flag = -1;
214 static int hf_netlogon_dc_flags_gc_flag = -1;
215 static int hf_netlogon_dc_flags_ldap_flag = -1;
216 static int hf_netlogon_dc_flags_ds_flag = -1;
217 static int hf_netlogon_dc_flags_kdc_flag = -1;
218 static int hf_netlogon_dc_flags_timeserv_flag = -1;
219 static int hf_netlogon_dc_flags_closest_flag = -1;
220 static int hf_netlogon_dc_flags_writable_flag = -1;
221 static int hf_netlogon_dc_flags_good_timeserv_flag = -1;
222 static int hf_netlogon_dc_flags_ndnc_flag = -1;
223 static int hf_netlogon_dc_flags_dns_controller_flag = -1;
224 static int hf_netlogon_dc_flags_dns_domain_flag = -1;
225 static int hf_netlogon_dc_flags_dns_forest_flag = -1;
226
227 static gint ett_dcerpc_netlogon = -1;
228 static gint ett_QUOTA_LIMITS = -1;
229 static gint ett_IDENTITY_INFO = -1;
230 static gint ett_DELTA_ENUM = -1;
231 static gint ett_CYPHER_VALUE = -1;
232 static gint ett_UNICODE_MULTI = -1;
233 static gint ett_DOMAIN_CONTROLLER_INFO = -1;
234 static gint ett_UNICODE_STRING_512 = -1;
235 static gint ett_TYPE_50 = -1;
236 static gint ett_TYPE_52 = -1;
237 static gint ett_DELTA_ID_UNION = -1;
238 static gint ett_TYPE_44 = -1;
239 static gint ett_DELTA_UNION = -1;
240 static gint ett_LM_OWF_PASSWORD = -1;
241 static gint ett_NT_OWF_PASSWORD = -1;
242 static gint ett_GROUP_MEMBERSHIP = -1;
243 static gint ett_BLOB = -1;
244 static gint ett_DS_DOMAIN_TRUSTS = -1;
245 static gint ett_DOMAIN_TRUST_INFO = -1;
246 static gint ett_trust_flags = -1;
247 static gint ett_get_dcname_request_flags = -1;
248 static gint ett_dc_flags = -1;
249
250 static e_uuid_t uuid_dcerpc_netlogon = {
251         0x12345678, 0x1234, 0xabcd,
252         { 0xef, 0x00, 0x01, 0x23, 0x45, 0x67, 0xcf, 0xfb }
253 };
254
255 static guint16 ver_dcerpc_netlogon = 1;
256
257
258
259 static int
260 netlogon_dissect_LOGONSRV_HANDLE(tvbuff_t *tvb, int offset,
261                         packet_info *pinfo, proto_tree *tree,
262                         char *drep)
263 {
264         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
265                 NDR_POINTER_UNIQUE, "Server Handle", 
266                 hf_netlogon_logonsrv_handle, 0);
267
268         return offset;
269 }
270
271 /*
272  * IDL typedef struct {
273  * IDL    [unique][string] wchar_t *effective_name;
274  * IDL    long priv;
275  * IDL    long auth_flags;
276  * IDL    long logon_count;
277  * IDL    long bad_pw_count;
278  * IDL    long last_logon;
279  * IDL    long last_logoff;
280  * IDL    long logoff_time;
281  * IDL    long kickoff_time;
282  * IDL    long password_age;
283  * IDL    long pw_can_change;
284  * IDL    long pw_must_change;
285  * IDL    [unique][string] wchar_t *computer;
286  * IDL    [unique][string] wchar_t *domain;
287  * IDL    [unique][string] wchar_t *script_path;
288  * IDL    long reserved;
289  */
290 static int
291 netlogon_dissect_VALIDATION_UAS_INFO(tvbuff_t *tvb, int offset,
292                         packet_info *pinfo, proto_tree *tree,
293                         char *drep)
294 {
295         dcerpc_info *di;
296
297         di=pinfo->private_data;
298         if(di->conformant_run){
299                 /*just a run to handle conformant arrays, nothing to dissect */
300                 return offset;
301         }
302
303         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
304                 NDR_POINTER_UNIQUE, "Effective Account", 
305                 hf_netlogon_acct_name, 0);
306
307         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
308                 hf_netlogon_priv, NULL);
309
310         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
311                 hf_netlogon_auth_flags, NULL);
312
313         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
314                 hf_netlogon_logon_count, NULL);
315
316         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
317                 hf_netlogon_bad_pw_count, NULL);
318
319         /* XXX - are these all UNIX "time_t"s, like the time stamps in
320            credentials?
321
322            Or are they, as per some RAP-based operations, UTIMEs? */
323         proto_tree_add_text(tree, tvb, offset, 4, "Last Logon: unknown time format");
324         offset+= 4;
325
326         proto_tree_add_text(tree, tvb, offset, 4, "Last Logoff: unknown time format");
327         offset+= 4;
328
329         proto_tree_add_text(tree, tvb, offset, 4, "Logoff Time: unknown time format");
330         offset+= 4;
331
332         proto_tree_add_text(tree, tvb, offset, 4, "Kickoff Time: unknown time format");
333         offset+= 4;
334
335         proto_tree_add_text(tree, tvb, offset, 4, "Password Age: unknown time format");
336         offset+= 4;
337
338         proto_tree_add_text(tree, tvb, offset, 4, "PW Can Change: unknown time format");
339         offset+= 4;
340
341         proto_tree_add_text(tree, tvb, offset, 4, "PW Must Change: unknown time format");
342         offset+= 4;
343
344         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
345                 NDR_POINTER_UNIQUE, "Computer", hf_netlogon_computer_name, 0);
346
347         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
348                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_domain_name, 0);
349
350         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
351                 NDR_POINTER_UNIQUE, "Script", hf_netlogon_logon_script, 0);
352
353         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
354                 hf_netlogon_reserved, NULL);
355
356         return offset;
357 }
358
359 /*
360  * IDL long NetLogonUasLogon(
361  * IDL      [in][unique][string] wchar_t *ServerName,
362  * IDL      [in][ref][string] wchar_t *UserName,
363  * IDL      [in][ref][string] wchar_t *Workstation,
364  * IDL      [out][unique] VALIDATION_UAS_INFO *info
365  * IDL );
366  */
367 static int
368 netlogon_dissect_netlogonuaslogon_rqst(tvbuff_t *tvb, int offset,
369         packet_info *pinfo, proto_tree *tree, char *drep)
370 {
371         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
372                 pinfo, tree, drep);
373
374         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
375                 NDR_POINTER_REF, "Account", hf_netlogon_acct_name, 0);
376
377         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
378                 NDR_POINTER_REF, "Workstation", hf_netlogon_workstation, 0);
379
380         return offset;
381 }
382
383
384 static int
385 netlogon_dissect_netlogonuaslogon_reply(tvbuff_t *tvb, int offset,
386         packet_info *pinfo, proto_tree *tree, char *drep)
387 {
388         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
389                 netlogon_dissect_VALIDATION_UAS_INFO, NDR_POINTER_UNIQUE,
390                 "VALIDATION_UAS_INFO", -1);
391
392         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
393                                   hf_netlogon_rc, NULL);
394
395         return offset;
396 }
397
398 /*
399  * IDL typedef struct {
400  * IDL   long duration;
401  * IDL   short logon_count;
402  * IDL } LOGOFF_UAS_INFO;
403  */
404 static int
405 netlogon_dissect_LOGOFF_UAS_INFO(tvbuff_t *tvb, int offset,
406                         packet_info *pinfo, proto_tree *tree,
407                         char *drep)
408 {
409         dcerpc_info *di;
410
411         di=pinfo->private_data;
412         if(di->conformant_run){
413                 /*just a run to handle conformant arrays, nothing to dissect */
414                 return offset;
415         }
416
417         proto_tree_add_text(tree, tvb, offset, 4, "Duration: unknown time format");
418         offset+= 4;
419
420         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
421                 hf_netlogon_logon_count16, NULL);
422
423         return offset;
424 }
425
426 /*
427  * IDL long NetLogonUasLogoff(
428  * IDL      [in][unique][string] wchar_t *ServerName,
429  * IDL      [in][ref][string] wchar_t *UserName,
430  * IDL      [in][ref][string] wchar_t *Workstation,
431  * IDL      [out][ref] LOGOFF_UAS_INFO *info
432  * IDL );
433  */
434 static int
435 netlogon_dissect_netlogonuaslogoff_rqst(tvbuff_t *tvb, int offset,
436         packet_info *pinfo, proto_tree *tree, char *drep)
437 {
438         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
439                 pinfo, tree, drep);
440
441         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
442                 NDR_POINTER_REF, "Account", hf_netlogon_acct_name, 0);
443
444         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
445                 NDR_POINTER_REF, "Workstation", hf_netlogon_workstation, 0);
446
447         return offset;
448 }
449
450
451 static int
452 netlogon_dissect_netlogonuaslogoff_reply(tvbuff_t *tvb, int offset,
453         packet_info *pinfo, proto_tree *tree, char *drep)
454 {
455         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
456                 netlogon_dissect_LOGOFF_UAS_INFO, NDR_POINTER_REF,
457                 "LOGOFF_UAS_INFO", -1);
458
459         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
460                                   hf_netlogon_rc, NULL);
461
462         return offset;
463 }
464
465
466
467
468 /*
469  * IDL typedef struct {
470  * IDL   UNICODESTRING LogonDomainName;
471  * IDL   long ParameterControl;
472  * IDL   uint64 LogonID;
473  * IDL   UNICODESTRING UserName;
474  * IDL   UNICODESTRING Workstation;
475  * IDL } LOGON_IDENTITY_INFO;
476  */
477 static int
478 netlogon_dissect_LOGON_IDENTITY_INFO(tvbuff_t *tvb, int offset,
479                         packet_info *pinfo, proto_tree *parent_tree,
480                         char *drep)
481 {
482         proto_item *item=NULL;
483         proto_tree *tree=NULL;
484         int old_offset=offset;
485
486         if(parent_tree){
487                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
488                         "IDENTITY_INFO:");
489                 tree = proto_item_add_subtree(item, ett_IDENTITY_INFO);
490         }
491
492         /* XXX: It would be nice to get the domain and account name 
493            displayed in COL_INFO. */
494
495         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
496                 hf_netlogon_logon_dom, 0);
497
498         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
499                 hf_netlogon_param_ctrl, NULL);
500
501         offset = dissect_ndr_uint64(tvb, offset, pinfo, tree, drep,
502                 hf_netlogon_logon_id, NULL);
503
504         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
505                 hf_netlogon_acct_name, 0);
506
507         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
508                 hf_netlogon_workstation, 0);
509
510 #ifdef REMOVED
511         /* NetMon does not recognize these bytes. Ill comment them out until someone complains */
512         /* XXX 8 extra bytes here */
513         /* there were 8 extra bytes, either here or in NETWORK_INFO that does not match
514            the idl file. Could be a bug in either the NETLOGON implementation or in the
515            idl file.
516         */
517         offset = netlogon_dissect_8_unknown_bytes(tvb, offset, pinfo, tree, drep);
518 #endif
519
520         proto_item_set_len(item, offset-old_offset);
521         return offset;
522 }
523
524
525 /*
526  * IDL typedef struct {
527  * IDL   char password[16];
528  * IDL } LM_OWF_PASSWORD;
529  */
530 static int
531 netlogon_dissect_LM_OWF_PASSWORD(tvbuff_t *tvb, int offset,
532                         packet_info *pinfo, proto_tree *parent_tree,
533                         char *drep _U_)
534 {
535         proto_item *item=NULL;
536         proto_tree *tree=NULL;
537         dcerpc_info *di;
538
539         di=pinfo->private_data;
540         if(di->conformant_run){
541                 /*just a run to handle conformant arrays, nothing to dissect.*/
542                 return offset;
543         }
544
545         if(parent_tree){
546                 item = proto_tree_add_text(parent_tree, tvb, offset, 16,
547                         "LM_OWF_PASSWORD:");
548                 tree = proto_item_add_subtree(item, ett_LM_OWF_PASSWORD);
549         }
550
551         proto_tree_add_item(tree, hf_netlogon_lm_owf_password, tvb, offset, 16,
552                 FALSE);
553         offset += 16;
554
555         return offset;
556 }
557
558 /*
559  * IDL typedef struct {
560  * IDL   char password[16];
561  * IDL } NT_OWF_PASSWORD;
562  */
563 static int
564 netlogon_dissect_NT_OWF_PASSWORD(tvbuff_t *tvb, int offset,
565                         packet_info *pinfo, proto_tree *parent_tree,
566                         char *drep _U_)
567 {
568         proto_item *item=NULL;
569         proto_tree *tree=NULL;
570         dcerpc_info *di;
571
572         di=pinfo->private_data;
573         if(di->conformant_run){
574                 /*just a run to handle conformant arrays, nothing to dissect.*/
575                 return offset;
576         }
577
578         if(parent_tree){
579                 item = proto_tree_add_text(parent_tree, tvb, offset, 16,
580                         "NT_OWF_PASSWORD:");
581                 tree = proto_item_add_subtree(item, ett_NT_OWF_PASSWORD);
582         }
583
584         proto_tree_add_item(tree, hf_netlogon_nt_owf_password, tvb, offset, 16,
585                 FALSE);
586         offset += 16;
587
588         return offset;
589 }
590
591
592 /*
593  * IDL typedef struct {
594  * IDL   LOGON_IDENTITY_INFO identity_info;
595  * IDL   LM_OWF_PASSWORD lmpassword;
596  * IDL   NT_OWF_PASSWORD ntpassword;
597  * IDL } INTERACTIVE_INFO;
598  */
599 static int
600 netlogon_dissect_INTERACTIVE_INFO(tvbuff_t *tvb, int offset,
601                         packet_info *pinfo, proto_tree *tree,
602                         char *drep)
603 {
604         offset = netlogon_dissect_LOGON_IDENTITY_INFO(tvb, offset,
605                 pinfo, tree, drep);
606
607         offset = netlogon_dissect_LM_OWF_PASSWORD(tvb, offset,
608                 pinfo, tree, drep);
609
610         offset = netlogon_dissect_NT_OWF_PASSWORD(tvb, offset,
611                 pinfo, tree, drep);
612
613         return offset;
614 }
615
616 /*
617  * IDL typedef struct {
618  * IDL   char chl[8];
619  * IDL } CHALLENGE;
620  */
621 static int
622 netlogon_dissect_CHALLENGE(tvbuff_t *tvb, int offset,
623                         packet_info *pinfo, proto_tree *tree,
624                         char *drep _U_)
625 {
626         dcerpc_info *di;
627
628         di=pinfo->private_data;
629         if(di->conformant_run){
630                 /*just a run to handle conformant arrays, nothing to dissect.*/
631                 return offset;
632         }
633
634         proto_tree_add_item(tree, hf_netlogon_challenge, tvb, offset, 8,
635                 FALSE);
636         offset += 8;
637
638         return offset;
639 }
640
641 /*
642  * IDL typedef struct {
643  * IDL   LOGON_IDENTITY_INFO logon_info;
644  * IDL   CHALLENGE chal;
645  * IDL   STRING ntchallengeresponse;
646  * IDL   STRING lmchallengeresponse;
647  * IDL } NETWORK_INFO;
648  */
649
650 static void dissect_nt_chal_resp_cb(packet_info *pinfo _U_, proto_tree *tree, 
651                                     proto_item *item _U_, tvbuff_t *tvb, 
652                                     int start_offset, int end_offset, 
653                                     void *callback_args _U_)
654 {
655         int len;
656
657         /* Skip over 3 guint32's in NDR format */
658
659         if (start_offset % 4)
660                 start_offset += 4 - (start_offset % 4);
661
662         start_offset += 12;
663         len = end_offset - start_offset;
664
665         /* Call ntlmv2 response dissector */
666
667         if (len > 24)
668                 dissect_ntlmv2_response(tvb, tree, start_offset, len);
669 }
670
671 static int
672 netlogon_dissect_NETWORK_INFO(tvbuff_t *tvb, int offset,
673                 packet_info *pinfo, proto_tree *tree,
674                 char *drep)
675 {
676         offset = netlogon_dissect_LOGON_IDENTITY_INFO(tvb, offset,
677                 pinfo, tree, drep);
678
679         offset = netlogon_dissect_CHALLENGE(tvb, offset,
680                 pinfo, tree, drep);
681
682         offset = dissect_ndr_counted_byte_array_cb(
683                 tvb, offset, pinfo, tree, drep, hf_netlogon_nt_chal_resp,
684                 dissect_nt_chal_resp_cb, NULL);
685
686         offset = dissect_ndr_counted_byte_array(tvb, offset, pinfo, tree, drep,
687                 hf_netlogon_lm_chal_resp);
688
689         return offset;
690 }
691
692 /*
693  * IDL typedef struct {
694  * IDL   LOGON_IDENTITY_INFO logon_info;
695  * IDL   LM_OWF_PASSWORD lmpassword;
696  * IDL   NT_OWF_PASSWORD ntpassword;
697  * IDL } SERVICE_INFO;
698  */
699 static int
700 netlogon_dissect_SERVICE_INFO(tvbuff_t *tvb, int offset,
701                 packet_info *pinfo, proto_tree *tree,
702                 char *drep)
703 {
704         offset = netlogon_dissect_LOGON_IDENTITY_INFO(tvb, offset,
705                 pinfo, tree, drep);
706
707         offset = netlogon_dissect_LM_OWF_PASSWORD(tvb, offset,
708                 pinfo, tree, drep);
709
710         offset = netlogon_dissect_NT_OWF_PASSWORD(tvb, offset,
711                 pinfo, tree, drep);
712
713         return offset;
714 }
715
716 /*
717  * IDL typedef [switch_type(short)] union {
718  * IDL    [case(1)][unique] INTERACTIVE_INFO *iinfo;
719  * IDL    [case(2)][unique] NETWORK_INFO *ninfo;
720  * IDL    [case(3)][unique] SERVICE_INFO *sinfo;
721  * IDL } LEVEL;
722  */
723 static int
724 netlogon_dissect_LEVEL(tvbuff_t *tvb, int offset,
725                         packet_info *pinfo, proto_tree *tree,
726                         char *drep)
727 {
728         guint16 level;
729
730         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
731                 hf_netlogon_level16, &level);
732
733         ALIGN_TO_4_BYTES;
734         switch(level){
735         case 1:
736                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
737                         netlogon_dissect_INTERACTIVE_INFO, NDR_POINTER_UNIQUE,
738                         "INTERACTIVE_INFO:", -1);
739                 break;
740         case 2:
741                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
742                         netlogon_dissect_NETWORK_INFO, NDR_POINTER_UNIQUE,
743                         "NETWORK_INFO:", -1);
744                 break;
745         case 3:
746                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
747                         netlogon_dissect_SERVICE_INFO, NDR_POINTER_UNIQUE,
748                         "SERVICE_INFO:", -1);
749                 break;
750         }
751
752         return offset;
753 }
754
755 /*
756  * IDL typedef struct {
757  * IDL   char cred[8];
758  * IDL } CREDENTIAL;
759  */
760 static int
761 netlogon_dissect_CREDENTIAL(tvbuff_t *tvb, int offset,
762                         packet_info *pinfo, proto_tree *tree,
763                         char *drep _U_)
764 {
765         dcerpc_info *di;
766
767         di=pinfo->private_data;
768         if(di->conformant_run){
769                 /*just a run to handle conformant arrays, nothing to dissect.*/
770                 return offset;
771         }
772
773         proto_tree_add_item(tree, hf_netlogon_credential, tvb, offset, 8,
774                 FALSE);
775         offset += 8;
776
777         return offset;
778 }
779
780
781 /*
782  * IDL typedef struct {
783  * IDL   CREDENTIAL cred;
784  * IDL   long timestamp;
785  * IDL } AUTHENTICATOR;
786  */
787 static int
788 netlogon_dissect_AUTHENTICATOR(tvbuff_t *tvb, int offset,
789                         packet_info *pinfo, proto_tree *tree,
790                         char *drep)
791 {
792         dcerpc_info *di;
793         nstime_t ts;
794
795         di=pinfo->private_data;
796         if(di->conformant_run){
797                 /*just a run to handle conformant arrays, nothing to dissect */
798                 return offset;
799         }
800
801         offset = netlogon_dissect_CREDENTIAL(tvb, offset,
802                 pinfo, tree, drep);
803
804         /*
805          * XXX - this appears to be a UNIX time_t in some credentials, but
806          * appears to be random junk in other credentials.
807          * For example, it looks like a UNIX time_t in "credential"
808          * AUTHENTICATORs, but like random junk in "return_authenticator"
809          * AUTHENTICATORs.
810          */
811         ALIGN_TO_4_BYTES;
812         ts.secs = tvb_get_letohl(tvb, offset);
813         ts.nsecs = 0;
814         proto_tree_add_time(tree, hf_netlogon_timestamp, tvb, offset, 4, &ts);
815         offset+= 4;
816
817         return offset;
818 }
819
820
821 /*
822  * IDL typedef struct {
823  * IDL   long user_id;
824  * IDL   long attributes;
825  * IDL } GROUP_MEMBERSHIP;
826  */
827 static int
828 netlogon_dissect_GROUP_MEMBERSHIP(tvbuff_t *tvb, int offset,
829                         packet_info *pinfo, proto_tree *parent_tree,
830                         char *drep)
831 {
832         proto_item *item=NULL;
833         proto_tree *tree=NULL;
834
835         if(parent_tree){
836                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
837                         "GROUP_MEMBERSHIP:");
838                 tree = proto_item_add_subtree(item, ett_GROUP_MEMBERSHIP);
839         }
840
841         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
842                 hf_netlogon_user_rid, NULL);
843
844         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
845                 hf_netlogon_attrs, NULL);
846
847         return offset;
848 }
849
850 static int
851 netlogon_dissect_GROUP_MEMBERSHIP_ARRAY(tvbuff_t *tvb, int offset,
852                         packet_info *pinfo, proto_tree *tree,
853                         char *drep)
854 {
855         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
856                 netlogon_dissect_GROUP_MEMBERSHIP);
857
858         return offset;
859 }
860
861 /*
862  * IDL typedef struct {
863  * IDL   char user_session_key[16];
864  * IDL } USER_SESSION_KEY;
865  */
866 static int
867 netlogon_dissect_USER_SESSION_KEY(tvbuff_t *tvb, int offset,
868                         packet_info *pinfo, proto_tree *tree,
869                         char *drep _U_)
870 {
871         dcerpc_info *di;
872
873         di=pinfo->private_data;
874         if(di->conformant_run){
875                 /*just a run to handle conformant arrays, nothing to dissect.*/
876                 return offset;
877         }
878
879         proto_tree_add_item(tree, hf_netlogon_user_session_key, tvb, offset, 16,
880                 FALSE);
881         offset += 16;
882
883         return offset;
884 }
885
886 /*
887  * IDL typedef struct {
888  * IDL   uint64 LogonTime;
889  * IDL   uint64 LogoffTime;
890  * IDL   uint64 KickOffTime;
891  * IDL   uint64 PasswdLastSet;
892  * IDL   uint64 PasswdCanChange;
893  * IDL   uint64 PasswdMustChange;
894  * IDL   unicodestring effectivename;
895  * IDL   unicodestring fullname;
896  * IDL   unicodestring logonscript;
897  * IDL   unicodestring profilepath;
898  * IDL   unicodestring homedirectory;
899  * IDL   unicodestring homedirectorydrive;
900  * IDL   short LogonCount;
901  * IDL   short BadPasswdCount;
902  * IDL   long userid;
903  * IDL   long primarygroup;
904  * IDL   long groupcount;
905  * IDL   [unique][size_is(groupcount)] GROUP_MEMBERSHIP *groupids;
906  * IDL   long userflags;
907  * IDL   USER_SESSION_KEY key;
908  * IDL   unicodestring logonserver;
909  * IDL   unicodestring domainname;
910  * IDL   [unique] SID logondomainid;
911  * IDL   long expansionroom[10];
912  * IDL } VALIDATION_SAM_INFO;
913  */
914 static int
915 netlogon_dissect_VALIDATION_SAM_INFO(tvbuff_t *tvb, int offset,
916                 packet_info *pinfo, proto_tree *tree,
917                 char *drep)
918 {
919         int i;
920
921         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
922                 hf_netlogon_logon_time);
923
924         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
925                 hf_netlogon_logoff_time);
926
927         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
928                 hf_netlogon_kickoff_time);
929
930         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
931                 hf_netlogon_pwd_last_set_time);
932
933         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
934                 hf_netlogon_pwd_can_change_time);
935
936         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
937                 hf_netlogon_pwd_must_change_time);
938
939         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
940                 hf_netlogon_acct_name, 0);
941
942         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
943                 hf_netlogon_full_name, 0);
944
945         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
946                 hf_netlogon_logon_script, 0);
947
948         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
949                 hf_netlogon_profile_path, 0);
950
951         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
952                 hf_netlogon_home_dir, 0);
953
954         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
955                 hf_netlogon_dir_drive, 0);
956
957         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
958                 hf_netlogon_logon_count16, NULL);
959
960         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
961                 hf_netlogon_bad_pw_count16, NULL);
962
963         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
964                 hf_netlogon_user_rid, NULL);
965
966         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
967                 hf_netlogon_group_rid, NULL);
968
969         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
970                 hf_netlogon_num_rids, NULL);
971
972         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
973                 netlogon_dissect_GROUP_MEMBERSHIP_ARRAY, NDR_POINTER_UNIQUE,
974                 "GROUP_MEMBERSHIP_ARRAY", -1);
975
976         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
977                 hf_netlogon_user_flags, NULL);
978
979         offset = netlogon_dissect_USER_SESSION_KEY(tvb, offset,
980                 pinfo, tree, drep);
981
982         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
983                 hf_netlogon_logon_srv, 0);
984
985         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
986                 hf_netlogon_logon_dom, 0);
987
988         offset = dissect_ndr_nt_PSID(tvb, offset,
989                 pinfo, tree, drep, -1);
990
991         for(i=0;i<10;i++){
992                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
993                         hf_netlogon_reserved, NULL);
994         }
995
996         return offset;
997 }
998
999
1000
1001 /*
1002  * IDL typedef struct {
1003  * IDL   uint64 LogonTime;
1004  * IDL   uint64 LogoffTime;
1005  * IDL   uint64 KickOffTime;
1006  * IDL   uint64 PasswdLastSet;
1007  * IDL   uint64 PasswdCanChange;
1008  * IDL   uint64 PasswdMustChange;
1009  * IDL   unicodestring effectivename;
1010  * IDL   unicodestring fullname;
1011  * IDL   unicodestring logonscript;
1012  * IDL   unicodestring profilepath;
1013  * IDL   unicodestring homedirectory;
1014  * IDL   unicodestring homedirectorydrive;
1015  * IDL   short LogonCount;
1016  * IDL   short BadPasswdCount;
1017  * IDL   long userid;
1018  * IDL   long primarygroup;
1019  * IDL   long groupcount;
1020  * IDL   [unique] GROUP_MEMBERSHIP *groupids;
1021  * IDL   long userflags;
1022  * IDL   USER_SESSION_KEY key;
1023  * IDL   unicodestring logonserver;
1024  * IDL   unicodestring domainname;
1025  * IDL   [unique] SID logondomainid;
1026  * IDL   long expansionroom[10];
1027  * IDL   long sidcount;
1028  * IDL   [unique] SID_AND_ATTRIBS;
1029  * IDL } VALIDATION_SAM_INFO2;
1030  */
1031 static int
1032 netlogon_dissect_VALIDATION_SAM_INFO2(tvbuff_t *tvb, int offset,
1033                         packet_info *pinfo, proto_tree *tree,
1034                         char *drep)
1035 {
1036         int i;
1037
1038         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1039                 hf_netlogon_logon_time);
1040
1041         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1042                 hf_netlogon_logoff_time);
1043
1044         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1045                 hf_netlogon_kickoff_time);
1046
1047         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1048                 hf_netlogon_pwd_last_set_time);
1049
1050         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1051                 hf_netlogon_pwd_can_change_time);
1052
1053         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1054                 hf_netlogon_pwd_must_change_time);
1055
1056         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1057                 hf_netlogon_acct_name, 0);
1058
1059         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1060                 hf_netlogon_full_name, 0);
1061
1062         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1063                 hf_netlogon_logon_script, 0);
1064
1065         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1066                 hf_netlogon_profile_path, 0);
1067
1068         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1069                 hf_netlogon_home_dir, 0);
1070
1071         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1072                 hf_netlogon_dir_drive, 0);
1073
1074         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1075                 hf_netlogon_logon_count16, NULL);
1076
1077         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1078                 hf_netlogon_bad_pw_count16, NULL);
1079
1080         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1081                 hf_netlogon_user_rid, NULL);
1082
1083         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1084                 hf_netlogon_group_rid, NULL);
1085
1086         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1087                 hf_netlogon_num_rids, NULL);
1088
1089         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1090                 netlogon_dissect_GROUP_MEMBERSHIP_ARRAY, NDR_POINTER_UNIQUE,
1091                 "GROUP_MEMBERSHIP_ARRAY", -1);
1092
1093         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1094                 hf_netlogon_user_flags, NULL);
1095
1096         offset = netlogon_dissect_USER_SESSION_KEY(tvb, offset,
1097                 pinfo, tree, drep);
1098
1099         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1100                 hf_netlogon_logon_srv, 0);
1101
1102         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1103                 hf_netlogon_logon_dom, 0);
1104
1105         offset = dissect_ndr_nt_PSID(tvb, offset,
1106                 pinfo, tree, drep, -1);
1107
1108         for(i=0;i<10;i++){
1109                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1110                         hf_netlogon_unknown_long, NULL);
1111         }
1112
1113         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1114                 hf_netlogon_num_other_groups, NULL);
1115
1116         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1117                 dissect_ndr_nt_SID_AND_ATTRIBUTES_ARRAY, NDR_POINTER_UNIQUE,
1118                 "SID_AND_ATTRIBUTES_ARRAY:", -1);
1119
1120         return offset;
1121 }
1122
1123
1124
1125 static int
1126 netlogon_dissect_PAC(tvbuff_t *tvb, int offset,
1127                         packet_info *pinfo, proto_tree *tree,
1128                         char *drep _U_)
1129 {
1130         dcerpc_info *di;
1131         guint32 pac_size;
1132
1133         di=pinfo->private_data;
1134         if(di->conformant_run){
1135                 /*just a run to handle conformant arrays, nothing to dissect */
1136                 return offset;
1137         }
1138
1139         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1140                 hf_netlogon_pac_size, &pac_size);
1141
1142         proto_tree_add_item(tree, hf_netlogon_pac_data, tvb, offset, pac_size,
1143                 FALSE);
1144         offset += pac_size;
1145
1146         return offset;
1147 }
1148
1149 static int
1150 netlogon_dissect_AUTH(tvbuff_t *tvb, int offset,
1151                         packet_info *pinfo, proto_tree *tree,
1152                         char *drep _U_)
1153 {
1154         dcerpc_info *di;
1155         guint32 auth_size;
1156
1157         di=pinfo->private_data;
1158         if(di->conformant_run){
1159                 /*just a run to handle conformant arrays, nothing to dissect */
1160                 return offset;
1161         }
1162
1163         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1164                 hf_netlogon_auth_size, &auth_size);
1165
1166         proto_tree_add_item(tree, hf_netlogon_auth_data, tvb, offset, auth_size,
1167                 FALSE);
1168         offset += auth_size;
1169
1170         return offset;
1171 }
1172
1173
1174 /*
1175  * IDL typedef struct {
1176  * IDL   long pac_size
1177  * IDL   [unique][size_is(pac_size)] char *pac;
1178  * IDL   UNICODESTRING logondomain;
1179  * IDL   UNICODESTRING logonserver;
1180  * IDL   UNICODESTRING principalname;
1181  * IDL   long auth_size;
1182  * IDL   [unique][size_is(auth_size)] char *auth;
1183  * IDL   USER_SESSION_KEY user_session_key;
1184  * IDL   long expansionroom[10];
1185  * IDL   UNICODESTRING dummy1;
1186  * IDL   UNICODESTRING dummy2;
1187  * IDL   UNICODESTRING dummy3;
1188  * IDL   UNICODESTRING dummy4;
1189  * IDL } VALIDATION_PAC_INFO;
1190  */
1191 static int
1192 netlogon_dissect_VALIDATION_PAC_INFO(tvbuff_t *tvb, int offset,
1193                         packet_info *pinfo, proto_tree *tree,
1194                         char *drep)
1195 {
1196         int i;
1197
1198         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1199                 hf_netlogon_pac_size, NULL);
1200
1201         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1202                 netlogon_dissect_PAC, NDR_POINTER_UNIQUE, "PAC:", -1);
1203
1204         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1205                 hf_netlogon_logon_dom, 0);
1206
1207         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1208                 hf_netlogon_logon_srv, 0);
1209
1210         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1211                 hf_netlogon_principal, 0);
1212
1213         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1214                 hf_netlogon_auth_size, NULL);
1215
1216         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1217                 netlogon_dissect_AUTH, NDR_POINTER_UNIQUE, "AUTH:", -1);
1218
1219         offset = netlogon_dissect_USER_SESSION_KEY(tvb, offset,
1220                 pinfo, tree, drep);
1221
1222         for(i=0;i<10;i++){
1223                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1224                         hf_netlogon_unknown_long, NULL);
1225         }
1226
1227         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1228                 hf_netlogon_dummy, 0);
1229
1230         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1231                 hf_netlogon_dummy, 0);
1232
1233         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1234                 hf_netlogon_dummy, 0);
1235
1236         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1237                 hf_netlogon_dummy, 0);
1238
1239         return offset;
1240 }
1241
1242
1243 /*
1244  * IDL typedef [switch_type(short)] union {
1245  * IDL    [case(2)][unique] VALIDATION_SAM_INFO *sam;
1246  * IDL    [case(3)][unique] VALIDATION_SAM_INFO2 *sam2;
1247  * IDL    [case(4)][unique] VALIDATION_PAC_INFO *pac;
1248  * IDL    [case(5)][unique] VALIDATION_PAC_INFO *pac2;
1249  * IDL } VALIDATION;
1250  */
1251 static int
1252 netlogon_dissect_VALIDATION(tvbuff_t *tvb, int offset,
1253                         packet_info *pinfo, proto_tree *tree,
1254                         char *drep)
1255 {
1256         guint16 level;
1257
1258         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1259                 hf_netlogon_validation_level, &level);
1260
1261         ALIGN_TO_4_BYTES;
1262         switch(level){
1263         case 2:
1264                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1265                         netlogon_dissect_VALIDATION_SAM_INFO, NDR_POINTER_UNIQUE,
1266                         "VALIDATION_SAM_INFO:", -1);
1267                 break;
1268         case 3:
1269                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1270                         netlogon_dissect_VALIDATION_SAM_INFO2, NDR_POINTER_UNIQUE,
1271                         "VALIDATION_SAM_INFO2:", -1);
1272                 break;
1273         case 4:
1274                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1275                         netlogon_dissect_VALIDATION_PAC_INFO, NDR_POINTER_UNIQUE,
1276                         "VALIDATION_PAC_INFO:", -1);
1277                 break;
1278         case 5:
1279                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1280                         netlogon_dissect_VALIDATION_PAC_INFO, NDR_POINTER_UNIQUE,
1281                         "VALIDATION_PAC_INFO:", -1);
1282                 break;
1283         }
1284
1285         return offset;
1286 }
1287
1288
1289 /*
1290  * IDL long NetLogonSamLogon(
1291  * IDL      [in][unique][string] wchar_t *ServerName,
1292  * IDL      [in][unique][string] wchar_t *Workstation,
1293  * IDL      [in][unique] AUTHENTICATOR *credential,
1294  * IDL      [in][out][unique] AUTHENTICATOR *returnauthenticator,
1295  * IDL      [in] short LogonLevel,
1296  * IDL      [in][ref] LOGON_LEVEL *logonlevel,
1297  * IDL      [in] short ValidationLevel,
1298  * IDL      [out][ref] VALIDATION *validation,
1299  * IDL      [out][ref] boolean Authorative
1300  * IDL );
1301  */
1302 static int
1303 netlogon_dissect_netlogonsamlogon_rqst(tvbuff_t *tvb, int offset,
1304         packet_info *pinfo, proto_tree *tree, char *drep)
1305 {
1306         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
1307                 pinfo, tree, drep);
1308
1309         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1310                 NDR_POINTER_UNIQUE, "Computer Name", 
1311                 hf_netlogon_computer_name, 0);
1312
1313         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1314                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
1315                 "AUTHENTICATOR: credential", -1);
1316
1317         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1318                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
1319                 "AUTHENTICATOR: return_authenticator", -1);
1320
1321         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1322                 hf_netlogon_level16, NULL);
1323
1324         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1325                 netlogon_dissect_LEVEL, NDR_POINTER_REF,
1326                 "LEVEL: LogonLevel", -1);
1327
1328         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1329                 hf_netlogon_validation_level, NULL);
1330
1331         return offset;
1332 }
1333
1334 static int
1335 netlogon_dissect_netlogonsamlogon_reply(tvbuff_t *tvb, int offset,
1336         packet_info *pinfo, proto_tree *tree, char *drep)
1337 {
1338         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1339                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
1340                 "AUTHENTICATOR: return_authenticator", -1);
1341
1342         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1343                 netlogon_dissect_VALIDATION, NDR_POINTER_REF,
1344                 "VALIDATION:", -1);
1345
1346         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
1347                 hf_netlogon_authoritative, NULL);
1348
1349         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
1350                                   hf_netlogon_rc, NULL);
1351
1352         return offset;
1353 }
1354
1355
1356 /*
1357  * IDL long NetLogonSamLogoff(
1358  * IDL      [in][unique][string] wchar_t *ServerName,
1359  * IDL      [in][unique][string] wchar_t *ComputerName,
1360  * IDL      [in][unique] AUTHENTICATOR credential,
1361  * IDL      [in][unique] AUTHENTICATOR return_authenticator,
1362  * IDL      [in] short logon_level,
1363  * IDL      [in][ref] LEVEL logoninformation
1364  * IDL );
1365  */
1366 static int
1367 netlogon_dissect_netlogonsamlogoff_rqst(tvbuff_t *tvb, int offset,
1368         packet_info *pinfo, proto_tree *tree, char *drep)
1369 {
1370         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
1371                 pinfo, tree, drep);
1372
1373         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1374                 NDR_POINTER_UNIQUE, "Computer Name", 
1375                 hf_netlogon_computer_name, 0);
1376
1377         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1378                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
1379                 "AUTHENTICATOR: credential", -1);
1380
1381         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1382                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
1383                 "AUTHENTICATOR: return_authenticator", -1);
1384
1385         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1386                 hf_netlogon_level16, NULL);
1387
1388         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1389                 netlogon_dissect_LEVEL, NDR_POINTER_REF,
1390                 "LEVEL: logoninformation", -1);
1391
1392         return offset;
1393 }
1394 static int
1395 netlogon_dissect_netlogonsamlogoff_reply(tvbuff_t *tvb, int offset,
1396         packet_info *pinfo, proto_tree *tree, char *drep)
1397 {
1398
1399         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1400                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
1401                 "AUTHENTICATOR: return_authenticator", -1);
1402
1403         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
1404                                   hf_netlogon_rc, NULL);
1405
1406         return offset;
1407 }
1408
1409
1410 /*
1411  * IDL long NetServerReqChallenge(
1412  * IDL      [in][unique][string] wchar_t *ServerName,
1413  * IDL      [in][ref][string] wchar_t *ComputerName,
1414  * IDL      [in][ref] CREDENTIAL client_credential,
1415  * IDL      [out][ref] CREDENTIAL server_credential
1416  * IDL );
1417  */
1418 static int
1419 netlogon_dissect_netserverreqchallenge_rqst(tvbuff_t *tvb, int offset,
1420         packet_info *pinfo, proto_tree *tree, char *drep)
1421 {
1422         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
1423                 pinfo, tree, drep);
1424
1425         offset = dissect_ndr_pointer_cb(
1426                 tvb, offset, pinfo, tree, drep, 
1427                 dissect_ndr_wchar_cvstring, NDR_POINTER_REF, 
1428                 "Computer Name", hf_netlogon_computer_name, 
1429                 cb_wstr_postprocess, 
1430                 GINT_TO_POINTER(CB_STR_COL_INFO | 1));
1431
1432         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1433                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
1434                 "CREDENTIAL: client challenge", -1);
1435
1436         return offset;
1437 }
1438 static int
1439 netlogon_dissect_netserverreqchallenge_reply(tvbuff_t *tvb, int offset,
1440         packet_info *pinfo, proto_tree *tree, char *drep)
1441 {
1442         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1443                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
1444                 "CREDENTIAL: server credential", -1);
1445
1446         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
1447                                   hf_netlogon_rc, NULL);
1448
1449         return offset;
1450 }
1451
1452
1453 static int
1454 netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvbuff_t *tvb, int offset,
1455                         packet_info *pinfo, proto_tree *tree,
1456                         char *drep)
1457 {
1458         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1459                         hf_netlogon_secure_channel_type, NULL);
1460
1461         return offset;
1462 }
1463
1464
1465 /*
1466  * IDL long NetServerAuthenticate(
1467  * IDL      [in][unique][string] wchar_t *ServerName,
1468  * IDL      [in][ref][string] wchar_t *UserName,
1469  * IDL      [in] short secure_challenge_type,
1470  * IDL      [in][ref][string] wchar_t *ComputerName,
1471  * IDL      [in][ref] CREDENTIAL client_challenge,
1472  * IDL      [out][ref] CREDENTIAL server_challenge
1473  * IDL );
1474  */
1475 static int
1476 netlogon_dissect_netserverauthenticate_rqst(tvbuff_t *tvb, int offset,
1477         packet_info *pinfo, proto_tree *tree, char *drep)
1478 {
1479         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
1480                 pinfo, tree, drep);
1481
1482         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1483                 NDR_POINTER_REF, "User Name", hf_netlogon_acct_name, 0);
1484
1485         offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
1486                 pinfo, tree, drep);
1487
1488         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1489                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
1490
1491         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1492                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
1493                 "CREDENTIAL: client challenge", -1);
1494
1495         return offset;
1496 }
1497 static int
1498 netlogon_dissect_netserverauthenticate_reply(tvbuff_t *tvb, int offset,
1499         packet_info *pinfo, proto_tree *tree, char *drep)
1500 {
1501         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1502                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
1503                 "CREDENTIAL: server challenge", -1);
1504
1505         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
1506                                   hf_netlogon_rc, NULL);
1507
1508         return offset;
1509 }
1510
1511
1512
1513 /*
1514  * IDL typedef struct {
1515  * IDL   char encrypted_password[16];
1516  * IDL } ENCRYPTED_LM_OWF_PASSWORD;
1517  */
1518 static int
1519 netlogon_dissect_ENCRYPTED_LM_OWF_PASSWORD(tvbuff_t *tvb, int offset,
1520                         packet_info *pinfo, proto_tree *tree,
1521                         char *drep _U_)
1522 {
1523         dcerpc_info *di;
1524
1525         di=pinfo->private_data;
1526         if(di->conformant_run){
1527                 /*just a run to handle conformant arrays, nothing to dissect.*/
1528                 return offset;
1529         }
1530
1531         proto_tree_add_item(tree, hf_netlogon_encrypted_lm_owf_password, tvb, offset, 16,
1532                 FALSE);
1533         offset += 16;
1534
1535         return offset;
1536 }
1537
1538 /*
1539  * IDL long NetServerPasswordSet(
1540  * IDL      [in][unique][string] wchar_t *ServerName,
1541  * IDL      [in][ref][string] wchar_t *UserName,
1542  * IDL      [in] short secure_challenge_type,
1543  * IDL      [in][ref][string] wchar_t *ComputerName,
1544  * IDL      [in][ref] AUTHENTICATOR credential,
1545  * IDL      [in][ref] LM_OWF_PASSWORD UasNewPassword,
1546  * IDL      [out][ref] AUTHENTICATOR return_authenticator
1547  * IDL );
1548  */
1549 static int
1550 netlogon_dissect_netserverpasswordset_rqst(tvbuff_t *tvb, int offset,
1551         packet_info *pinfo, proto_tree *tree, char *drep)
1552 {
1553         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
1554                 pinfo, tree, drep);
1555
1556         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1557                 NDR_POINTER_REF, "User Name", hf_netlogon_acct_name, 0);
1558
1559         offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
1560                 pinfo, tree, drep);
1561
1562         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1563                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
1564
1565         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1566                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
1567                 "AUTHENTICATOR: credential", -1);
1568
1569         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1570                 netlogon_dissect_ENCRYPTED_LM_OWF_PASSWORD, NDR_POINTER_REF,
1571                 "ENCRYPTED_LM_OWF_PASSWORD: hashed_pwd", -1);
1572
1573         return offset;
1574 }
1575 static int
1576 netlogon_dissect_netserverpasswordset_reply(tvbuff_t *tvb, int offset,
1577         packet_info *pinfo, proto_tree *tree, char *drep)
1578 {
1579         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1580                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
1581                 "AUTHENTICATOR: return_authenticator", -1);
1582
1583         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
1584                                   hf_netlogon_rc, NULL);
1585
1586         return offset;
1587 }
1588
1589
1590 /*
1591  * IDL typedef struct {
1592  * IDL   [unique][string] wchar_t *UserName;
1593  * IDL   UNICODESTRING dummy1;
1594  * IDL   UNICODESTRING dummy2;
1595  * IDL   UNICODESTRING dummy3;
1596  * IDL   UNICODESTRING dummy4;
1597  * IDL   long dummy5;
1598  * IDL   long dummy6;
1599  * IDL   long dummy7;
1600  * IDL   long dummy8;
1601  * IDL } DELTA_DELETE_USER;
1602  */
1603 static int
1604 netlogon_dissect_DELTA_DELETE_USER(tvbuff_t *tvb, int offset,
1605                         packet_info *pinfo, proto_tree *tree,
1606                         char *drep)
1607 {
1608         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
1609                 NDR_POINTER_UNIQUE, "Account Name", hf_netlogon_acct_name, 0);
1610
1611         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1612                 hf_netlogon_dummy, 0);
1613
1614         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1615                 hf_netlogon_dummy, 0);
1616
1617         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1618                 hf_netlogon_dummy, 0);
1619
1620         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1621                 hf_netlogon_dummy, 0);
1622
1623         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1624                 hf_netlogon_reserved, NULL);
1625
1626         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1627                 hf_netlogon_reserved, NULL);
1628
1629         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1630                 hf_netlogon_reserved, NULL);
1631
1632         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1633                 hf_netlogon_reserved, NULL);
1634
1635         return offset;
1636 }
1637
1638
1639 /*
1640  * IDL typedef struct {
1641  * IDL   bool SensitiveDataFlag;
1642  * IDL   long DataLength;
1643  * IDL   [unique][size_is(DataLength)] char *SensitiveData;
1644  * IDL } USER_PRIVATE_INFO;
1645  */
1646 static int
1647 netlogon_dissect_SENSITIVE_DATA(tvbuff_t *tvb, int offset,
1648                         packet_info *pinfo, proto_tree *tree,
1649                         char *drep)
1650 {
1651         dcerpc_info *di;
1652         guint32 data_len;
1653
1654         di=pinfo->private_data;
1655         if(di->conformant_run){
1656                 /*just a run to handle conformant arrays, nothing to dissect */
1657                 return offset;
1658         }
1659
1660         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1661                 hf_netlogon_sensitive_data_len, &data_len);
1662
1663         proto_tree_add_item(tree, hf_netlogon_sensitive_data, tvb, offset,
1664                 data_len, FALSE);
1665         offset += data_len;
1666
1667         return offset;
1668 }
1669 static int
1670 netlogon_dissect_USER_PRIVATE_INFO(tvbuff_t *tvb, int offset,
1671                         packet_info *pinfo, proto_tree *tree,
1672                         char *drep)
1673 {
1674         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
1675                 hf_netlogon_sensitive_data_flag, NULL);
1676
1677         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1678                 hf_netlogon_sensitive_data_len, NULL);
1679
1680         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
1681                 netlogon_dissect_SENSITIVE_DATA, NDR_POINTER_UNIQUE,
1682                 "SENSITIVE_DATA", -1);
1683
1684         return offset;
1685 }
1686
1687 /*
1688  * IDL typedef struct {
1689  * IDL   UNICODESTRING UserName;
1690  * IDL   UNICODESTRING FullName;
1691  * IDL   long UserID;
1692  * IDL   long PrimaryGroupID;
1693  * IDL   UNICODESTRING HomeDir;
1694  * IDL   UNICODESTRING HomeDirDrive;
1695  * IDL   UNICODESTRING LogonScript;
1696  * IDL   UNICODESTRING Comment;
1697  * IDL   UNICODESTRING Workstations;
1698  * IDL   NTTIME LastLogon;
1699  * IDL   NTTIME LastLogoff;
1700  * IDL   LOGON_HOURS logonhours;
1701  * IDL   short BadPwCount;
1702  * IDL   short LogonCount;
1703  * IDL   NTTIME PwLastSet;
1704  * IDL   NTTIME AccountExpires;
1705  * IDL   long AccountControl;
1706  * IDL   LM_OWF_PASSWORD lmpw;
1707  * IDL   NT_OWF_PASSWORD ntpw;
1708  * IDL   bool NTPwPresent;
1709  * IDL   bool LMPwPresent;
1710  * IDL   bool PwExpired;
1711  * IDL   UNICODESTRING UserComment;
1712  * IDL   UNICODESTRING Parameters;
1713  * IDL   short CountryCode;
1714  * IDL   short CodePage;
1715  * IDL   USER_PRIVATE_INFO user_private_info;
1716  * IDL   long SecurityInformation;
1717  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
1718  * IDL   UNICODESTRING dummy1;
1719  * IDL   UNICODESTRING dummy2;
1720  * IDL   UNICODESTRING dummy3;
1721  * IDL   UNICODESTRING dummy4;
1722  * IDL   long dummy5;
1723  * IDL   long dummy6;
1724  * IDL   long dummy7;
1725  * IDL   long dummy8;
1726  * IDL } DELTA_USER;
1727  */
1728 static int
1729 netlogon_dissect_DELTA_USER(tvbuff_t *tvb, int offset,
1730                         packet_info *pinfo, proto_tree *tree,
1731                         char *drep)
1732 {
1733         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1734                 hf_netlogon_acct_name, 0);
1735
1736         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1737                 hf_netlogon_full_name, 0);
1738
1739         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1740                 hf_netlogon_user_rid, NULL);
1741
1742         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1743                 hf_netlogon_group_rid, NULL);
1744
1745         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1746                 hf_netlogon_home_dir, 0);
1747
1748         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1749                 hf_netlogon_dir_drive, 0);
1750
1751         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1752                 hf_netlogon_logon_script, 0);
1753
1754         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1755                 hf_netlogon_acct_desc, 0);
1756
1757         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1758                 hf_netlogon_workstations, 0);
1759
1760         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1761                 hf_netlogon_logon_time);
1762
1763         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1764                 hf_netlogon_logoff_time);
1765
1766         offset = dissect_ndr_nt_LOGON_HOURS(tvb, offset, pinfo, tree, drep);
1767
1768         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1769                 hf_netlogon_bad_pw_count16, NULL);
1770
1771         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1772                 hf_netlogon_logon_count16, NULL);
1773
1774         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1775                 hf_netlogon_pwd_last_set_time);
1776
1777         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1778                 hf_netlogon_acct_expiry_time);
1779
1780         offset = dissect_ndr_nt_acct_ctrl(tvb, offset, pinfo, tree, drep);
1781
1782         offset = netlogon_dissect_LM_OWF_PASSWORD(tvb, offset,
1783                 pinfo, tree, drep);
1784
1785         offset = netlogon_dissect_NT_OWF_PASSWORD(tvb, offset,
1786                 pinfo, tree, drep);
1787
1788         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
1789                 hf_netlogon_nt_pwd_present, NULL);
1790
1791         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
1792                 hf_netlogon_lm_pwd_present, NULL);
1793
1794         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
1795                 hf_netlogon_pwd_expired, NULL);
1796
1797         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1798                 hf_netlogon_comment, 0);
1799
1800         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1801                 hf_netlogon_parameters, 0);
1802
1803         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1804                 hf_netlogon_country, NULL);
1805
1806         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1807                 hf_netlogon_codepage, NULL);
1808
1809         offset = netlogon_dissect_USER_PRIVATE_INFO(tvb, offset, pinfo, tree,
1810                 drep);
1811
1812         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1813                 hf_netlogon_security_information, NULL);
1814
1815         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
1816                 pinfo, tree, drep);
1817
1818         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1819                 hf_netlogon_dummy, 0);
1820
1821         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1822                 hf_netlogon_dummy, 0);
1823
1824         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1825                 hf_netlogon_dummy, 0);
1826
1827         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1828                 hf_netlogon_dummy, 0);
1829
1830         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1831                 hf_netlogon_reserved, NULL);
1832
1833         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1834                 hf_netlogon_reserved, NULL);
1835
1836         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1837                 hf_netlogon_reserved, NULL);
1838
1839         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1840                 hf_netlogon_reserved, NULL);
1841
1842         return offset;
1843 }
1844
1845
1846 /*
1847  * IDL typedef struct {
1848  * IDL   UNICODESTRING DomainName;
1849  * IDL   UNICODESTRING OEMInfo;
1850  * IDL   NTTIME forcedlogoff;
1851  * IDL   short minpasswdlen;
1852  * IDL   short passwdhistorylen;
1853  * IDL   NTTIME pwd_must_change_time;
1854  * IDL   NTTIME pwd_can_change_time;
1855  * IDL   NTTIME domain_modify_time;
1856  * IDL   NTTIME domain_create_time;
1857  * IDL   long SecurityInformation;
1858  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
1859  * IDL   UNICODESTRING dummy1;
1860  * IDL   UNICODESTRING dummy2;
1861  * IDL   UNICODESTRING dummy3;
1862  * IDL   UNICODESTRING dummy4;
1863  * IDL   long dummy5;
1864  * IDL   long dummy6;
1865  * IDL   long dummy7;
1866  * IDL   long dummy8;
1867  * IDL } DELTA_DOMAIN;
1868  */
1869 static int
1870 netlogon_dissect_DELTA_DOMAIN(tvbuff_t *tvb, int offset,
1871                         packet_info *pinfo, proto_tree *tree,
1872                         char *drep)
1873 {
1874         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1875                 hf_netlogon_domain_name, 1);
1876
1877         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1878                 hf_netlogon_oem_info, 0);
1879
1880         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1881                 hf_netlogon_kickoff_time);
1882
1883         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1884                 hf_netlogon_minpasswdlen, NULL);
1885
1886         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
1887                 hf_netlogon_passwdhistorylen, NULL);
1888
1889         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1890                 hf_netlogon_pwd_must_change_time);
1891
1892         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1893                 hf_netlogon_pwd_can_change_time);
1894
1895         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1896                 hf_netlogon_domain_modify_time);
1897
1898         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
1899                 hf_netlogon_domain_create_time);
1900
1901         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1902                 hf_netlogon_security_information, NULL);
1903
1904         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
1905                 pinfo, tree, drep);
1906
1907         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1908                 hf_netlogon_dummy, 0);
1909
1910         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1911                 hf_netlogon_dummy, 0);
1912
1913         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1914                 hf_netlogon_dummy, 0);
1915
1916         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1917                 hf_netlogon_dummy, 0);
1918
1919         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1920                 hf_netlogon_reserved, NULL);
1921
1922         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1923                 hf_netlogon_reserved, NULL);
1924
1925         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1926                 hf_netlogon_reserved, NULL);
1927
1928         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1929                 hf_netlogon_reserved, NULL);
1930
1931         return offset;
1932 }
1933
1934
1935 /*
1936  * IDL typedef struct {
1937  * IDL   UNICODESTRING groupname;
1938  * IDL   GROUP_MEMBERSHIP group_membership;
1939  * IDL   UNICODESTRING comment;
1940  * IDL   long SecurityInformation;
1941  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
1942  * IDL   UNICODESTRING dummy1;
1943  * IDL   UNICODESTRING dummy2;
1944  * IDL   UNICODESTRING dummy3;
1945  * IDL   UNICODESTRING dummy4;
1946  * IDL   long dummy5;
1947  * IDL   long dummy6;
1948  * IDL   long dummy7;
1949  * IDL   long dummy8;
1950  * IDL } DELTA_GROUP;
1951  */
1952 static int
1953 netlogon_dissect_DELTA_GROUP(tvbuff_t *tvb, int offset,
1954                         packet_info *pinfo, proto_tree *tree,
1955                         char *drep)
1956 {
1957         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1958                 hf_netlogon_group_name, 0);
1959
1960         offset = netlogon_dissect_GROUP_MEMBERSHIP(tvb, offset,
1961                 pinfo, tree, drep);
1962
1963         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1964                 hf_netlogon_group_desc, 0);
1965
1966         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1967                 hf_netlogon_security_information, NULL);
1968
1969         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
1970                 pinfo, tree, drep);
1971
1972         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1973                 hf_netlogon_dummy, 0);
1974
1975         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1976                 hf_netlogon_dummy, 0);
1977
1978         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1979                 hf_netlogon_dummy, 0);
1980
1981         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
1982                 hf_netlogon_dummy, 0);
1983
1984         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1985                 hf_netlogon_reserved, NULL);
1986
1987         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1988                 hf_netlogon_reserved, NULL);
1989
1990         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1991                 hf_netlogon_reserved, NULL);
1992
1993         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
1994                 hf_netlogon_reserved, NULL);
1995
1996         return offset;
1997 }
1998
1999
2000 /*
2001  * IDL typedef struct {
2002  * IDL   UNICODESTRING OldName;
2003  * IDL   UNICODESTRING NewName;
2004  * IDL   UNICODESTRING dummy1;
2005  * IDL   UNICODESTRING dummy2;
2006  * IDL   UNICODESTRING dummy3;
2007  * IDL   UNICODESTRING dummy4;
2008  * IDL   long dummy5;
2009  * IDL   long dummy6;
2010  * IDL   long dummy7;
2011  * IDL   long dummy8;
2012  * IDL } DELTA_RENAME;
2013  */
2014 static int
2015 netlogon_dissect_DELTA_RENAME(tvbuff_t *tvb, int offset,
2016                         packet_info *pinfo, proto_tree *tree,
2017                         char *drep)
2018 {
2019         dcerpc_info *di;
2020
2021         di=pinfo->private_data;
2022
2023         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2024                 di->hf_index, 0);
2025
2026         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2027                 di->hf_index, 0);
2028
2029         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2030                 hf_netlogon_dummy, 0);
2031
2032         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2033                 hf_netlogon_dummy, 0);
2034
2035         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2036                 hf_netlogon_dummy, 0);
2037
2038         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2039                 hf_netlogon_dummy, 0);
2040
2041         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2042                 hf_netlogon_reserved, NULL);
2043
2044         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2045                 hf_netlogon_reserved, NULL);
2046
2047         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2048                 hf_netlogon_reserved, NULL);
2049
2050         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2051                 hf_netlogon_reserved, NULL);
2052
2053         return offset;
2054 }
2055
2056
2057 static int
2058 netlogon_dissect_RID(tvbuff_t *tvb, int offset,
2059                         packet_info *pinfo, proto_tree *tree,
2060                         char *drep)
2061 {
2062         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2063                                 hf_netlogon_user_rid, NULL);
2064
2065         return offset;
2066 }
2067
2068 static int
2069 netlogon_dissect_RID_array(tvbuff_t *tvb, int offset,
2070                         packet_info *pinfo, proto_tree *tree,
2071                         char *drep)
2072 {
2073         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
2074                         netlogon_dissect_RID);
2075
2076         return offset;
2077 }
2078
2079 static int
2080 netlogon_dissect_ATTRIB(tvbuff_t *tvb, int offset,
2081                         packet_info *pinfo, proto_tree *tree,
2082                         char *drep)
2083 {
2084         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2085                 hf_netlogon_attrs, NULL);
2086
2087         return offset;
2088 }
2089
2090 static int
2091 netlogon_dissect_ATTRIB_array(tvbuff_t *tvb, int offset,
2092                         packet_info *pinfo, proto_tree *tree,
2093                         char *drep)
2094 {
2095         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
2096                         netlogon_dissect_ATTRIB);
2097
2098         return offset;
2099 }
2100
2101 /*
2102  * IDL typedef struct {
2103  * IDL   [unique][size_is(num_rids)] long *rids;
2104  * IDL   [unique][size_is(num_rids)] long *attribs;
2105  * IDL   long num_rids;
2106  * IDL   long dummy1;
2107  * IDL   long dummy2;
2108  * IDL   long dummy3;
2109  * IDL   long dummy4;
2110  * IDL } DELTA_GROUP_MEMBER;
2111  */
2112 static int
2113 netlogon_dissect_DELTA_GROUP_MEMBER(tvbuff_t *tvb, int offset,
2114                         packet_info *pinfo, proto_tree *tree,
2115                         char *drep)
2116 {
2117         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2118                 netlogon_dissect_RID_array, NDR_POINTER_UNIQUE,
2119                 "RIDs:", -1);
2120
2121         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2122                 netlogon_dissect_ATTRIB_array, NDR_POINTER_UNIQUE,
2123                 "Attribs:", -1);
2124
2125         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2126                 hf_netlogon_num_rids, NULL);
2127
2128         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2129                 hf_netlogon_reserved, NULL);
2130
2131         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2132                 hf_netlogon_reserved, NULL);
2133
2134         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2135                 hf_netlogon_reserved, NULL);
2136
2137         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2138                 hf_netlogon_reserved, NULL);
2139
2140         return offset;
2141 }
2142
2143
2144 /*
2145  * IDL typedef struct {
2146  * IDL   UNICODESTRING alias_name;
2147  * IDL   long rid;
2148  * IDL   long SecurityInformation;
2149  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
2150  * IDL   UNICODESTRING dummy1;
2151  * IDL   UNICODESTRING dummy2;
2152  * IDL   UNICODESTRING dummy3;
2153  * IDL   UNICODESTRING dummy4;
2154  * IDL   long dummy5;
2155  * IDL   long dummy6;
2156  * IDL   long dummy7;
2157  * IDL   long dummy8;
2158  * IDL } DELTA_ALIAS;
2159  */
2160 static int
2161 netlogon_dissect_DELTA_ALIAS(tvbuff_t *tvb, int offset,
2162                         packet_info *pinfo, proto_tree *tree,
2163                         char *drep)
2164 {
2165         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2166                 hf_netlogon_alias_name, 0);
2167
2168         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2169                 hf_netlogon_alias_rid, NULL);
2170
2171         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2172                 hf_netlogon_security_information, NULL);
2173
2174         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
2175                 pinfo, tree, drep);
2176
2177         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2178                 hf_netlogon_dummy, 0);
2179
2180         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2181                 hf_netlogon_dummy, 0);
2182
2183         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2184                 hf_netlogon_dummy, 0);
2185
2186         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2187                 hf_netlogon_dummy, 0);
2188
2189         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2190                 hf_netlogon_reserved, NULL);
2191
2192         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2193                 hf_netlogon_reserved, NULL);
2194
2195         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2196                 hf_netlogon_reserved, NULL);
2197
2198         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2199                 hf_netlogon_reserved, NULL);
2200
2201         return offset;
2202 }
2203
2204
2205 /*
2206  * IDL typedef struct {
2207  * IDL   [unique] SID_ARRAY sids;
2208  * IDL   long dummy1;
2209  * IDL   long dummy2;
2210  * IDL   long dummy3;
2211  * IDL   long dummy4;
2212  * IDL } DELTA_ALIAS_MEMBER;
2213  */
2214 static int
2215 netlogon_dissect_DELTA_ALIAS_MEMBER(tvbuff_t *tvb, int offset,
2216                         packet_info *pinfo, proto_tree *tree,
2217                         char *drep)
2218 {
2219         offset = dissect_ndr_nt_PSID_ARRAY(tvb, offset, pinfo, tree, drep);
2220
2221         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2222                 hf_netlogon_reserved, NULL);
2223
2224         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2225                 hf_netlogon_reserved, NULL);
2226
2227         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2228                 hf_netlogon_reserved, NULL);
2229
2230         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2231                 hf_netlogon_reserved, NULL);
2232
2233         return offset;
2234 }
2235
2236
2237 static int
2238 netlogon_dissect_EVENT_AUDIT_OPTION(tvbuff_t *tvb, int offset,
2239                         packet_info *pinfo, proto_tree *tree,
2240                         char *drep)
2241 {
2242         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2243                 hf_netlogon_event_audit_option, NULL);
2244
2245         return offset;
2246 }
2247
2248 static int
2249 netlogon_dissect_EVENT_AUDIT_OPTIONS_ARRAY(tvbuff_t *tvb, int offset,
2250                         packet_info *pinfo, proto_tree *tree,
2251                         char *drep)
2252 {
2253         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
2254                 netlogon_dissect_EVENT_AUDIT_OPTION);
2255
2256         return offset;
2257 }
2258
2259
2260 /*
2261  * IDL typedef struct {
2262  * IDL   long pagedpoollimit;
2263  * IDL   long nonpagedpoollimit;
2264  * IDL   long minimumworkingsetsize;
2265  * IDL   long maximumworkingsetsize;
2266  * IDL   long pagefilelimit;
2267  * IDL   NTTIME timelimit;
2268  * IDL } QUOTA_LIMITS;
2269  */
2270 static int
2271 netlogon_dissect_QUOTA_LIMITS(tvbuff_t *tvb, int offset,
2272                         packet_info *pinfo, proto_tree *parent_tree,
2273                         char *drep)
2274 {
2275         proto_item *item=NULL;
2276         proto_tree *tree=NULL;
2277         int old_offset=offset;
2278
2279         if(parent_tree){
2280                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
2281                         "QUOTA_LIMTS:");
2282                 tree = proto_item_add_subtree(item, ett_QUOTA_LIMITS);
2283         }
2284
2285         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2286                 hf_netlogon_pagedpoollimit, NULL);
2287
2288         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2289                 hf_netlogon_nonpagedpoollimit, NULL);
2290
2291         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2292                 hf_netlogon_minworkingsetsize, NULL);
2293
2294         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2295                 hf_netlogon_maxworkingsetsize, NULL);
2296
2297         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2298                 hf_netlogon_pagefilelimit, NULL);
2299
2300         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
2301                 hf_netlogon_timelimit);
2302
2303         proto_item_set_len(item, offset-old_offset);
2304         return offset;
2305 }
2306
2307
2308 /*
2309  * IDL typedef struct {
2310  * IDL   long maxlogsize;
2311  * IDL   NTTIME auditretentionperiod;
2312  * IDL   bool auditingmode;
2313  * IDL   long maxauditeventcount;
2314  * IDL   [unique][size_is(maxauditeventcount)] long *eventauditoptions;
2315  * IDL   UNICODESTRING primarydomainname;
2316  * IDL   [unique] SID *sid;
2317  * IDL   QUOTA_LIMITS quota_limits;
2318  * IDL   NTTIME db_modify_time;
2319  * IDL   NTTIME db_create_time;
2320  * IDL   long SecurityInformation;
2321  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
2322  * IDL   UNICODESTRING dummy1;
2323  * IDL   UNICODESTRING dummy2;
2324  * IDL   UNICODESTRING dummy3;
2325  * IDL   UNICODESTRING dummy4;
2326  * IDL   long dummy5;
2327  * IDL   long dummy6;
2328  * IDL   long dummy7;
2329  * IDL   long dummy8;
2330  * IDL } DELTA_POLICY;
2331  */
2332 static int
2333 netlogon_dissect_DELTA_POLICY(tvbuff_t *tvb, int offset,
2334                         packet_info *pinfo, proto_tree *tree,
2335                         char *drep)
2336 {
2337         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2338                 hf_netlogon_max_log_size, NULL);
2339
2340         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
2341                 hf_netlogon_audit_retention_period);
2342
2343         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
2344                 hf_netlogon_auditing_mode, NULL);
2345
2346         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2347                 hf_netlogon_max_audit_event_count, NULL);
2348
2349         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2350                 netlogon_dissect_EVENT_AUDIT_OPTIONS_ARRAY, NDR_POINTER_UNIQUE,
2351                 "Event Audit Options:", -1);
2352
2353         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2354                 hf_netlogon_domain_name, 0);
2355
2356         offset = dissect_ndr_nt_PSID(tvb, offset,
2357                 pinfo, tree, drep, -1);
2358
2359         offset = netlogon_dissect_QUOTA_LIMITS(tvb, offset,
2360                 pinfo, tree, drep);
2361
2362         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
2363                 hf_netlogon_db_modify_time);
2364
2365         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
2366                 hf_netlogon_db_create_time);
2367
2368         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2369                 hf_netlogon_security_information, NULL);
2370
2371         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
2372                 pinfo, tree, drep);
2373
2374         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2375                 hf_netlogon_dummy, 0);
2376
2377         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2378                 hf_netlogon_dummy, 0);
2379
2380         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2381                 hf_netlogon_dummy, 0);
2382
2383         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2384                 hf_netlogon_dummy, 0);
2385
2386         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2387                 hf_netlogon_reserved, NULL);
2388
2389         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2390                 hf_netlogon_reserved, NULL);
2391
2392         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2393                 hf_netlogon_reserved, NULL);
2394
2395         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2396                 hf_netlogon_reserved, NULL);
2397
2398         return offset;
2399 }
2400
2401
2402 static int
2403 netlogon_dissect_CONTROLLER(tvbuff_t *tvb, int offset,
2404                         packet_info *pinfo, proto_tree *tree,
2405                         char *drep)
2406 {
2407         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2408                 hf_netlogon_dc_name, 0);
2409
2410         return offset;
2411 }
2412
2413 static int
2414 netlogon_dissect_CONTROLLER_ARRAY(tvbuff_t *tvb, int offset,
2415                         packet_info *pinfo, proto_tree *tree,
2416                         char *drep)
2417 {
2418         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
2419                 netlogon_dissect_CONTROLLER);
2420
2421         return offset;
2422 }
2423
2424
2425 /*
2426  * IDL typedef struct {
2427  * IDL   UNICODESTRING DomainName;
2428  * IDL   long num_controllers;
2429  * IDL   [unique][size_is(num_controllers)] UNICODESTRING *controller_names;
2430  * IDL   long SecurityInformation;
2431  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
2432  * IDL   UNICODESTRING dummy1;
2433  * IDL   UNICODESTRING dummy2;
2434  * IDL   UNICODESTRING dummy3;
2435  * IDL   UNICODESTRING dummy4;
2436  * IDL   long dummy5;
2437  * IDL   long dummy6;
2438  * IDL   long dummy7;
2439  * IDL   long dummy8;
2440  * IDL } DELTA_TRUSTED_DOMAINS;
2441  */
2442 static int
2443 netlogon_dissect_DELTA_TRUSTED_DOMAINS(tvbuff_t *tvb, int offset,
2444                         packet_info *pinfo, proto_tree *tree,
2445                         char *drep)
2446 {
2447         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2448                 hf_netlogon_domain_name, 0);
2449
2450         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2451                 hf_netlogon_num_controllers, NULL);
2452
2453         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2454                 netlogon_dissect_CONTROLLER_ARRAY, NDR_POINTER_UNIQUE,
2455                 "Domain Controllers:", -1);
2456
2457         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2458                 hf_netlogon_security_information, NULL);
2459
2460         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
2461                 pinfo, tree, drep);
2462
2463         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2464                 hf_netlogon_dummy, 0);
2465
2466         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2467                 hf_netlogon_dummy, 0);
2468
2469         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2470                 hf_netlogon_dummy, 0);
2471
2472         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2473                 hf_netlogon_dummy, 0);
2474
2475         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2476                 hf_netlogon_reserved, NULL);
2477
2478         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2479                 hf_netlogon_reserved, NULL);
2480
2481         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2482                 hf_netlogon_reserved, NULL);
2483
2484         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2485                 hf_netlogon_reserved, NULL);
2486
2487         return offset;
2488 }
2489
2490
2491 static int
2492 netlogon_dissect_PRIV_ATTR(tvbuff_t *tvb, int offset,
2493                         packet_info *pinfo, proto_tree *tree,
2494                         char *drep)
2495 {
2496         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2497                 hf_netlogon_attrs, NULL);
2498
2499         return offset;
2500 }
2501
2502 static int
2503 netlogon_dissect_PRIV_ATTR_ARRAY(tvbuff_t *tvb, int offset,
2504                         packet_info *pinfo, proto_tree *tree,
2505                         char *drep)
2506 {
2507         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
2508                 netlogon_dissect_PRIV_ATTR);
2509
2510         return offset;
2511 }
2512
2513 static int
2514 netlogon_dissect_PRIV_NAME(tvbuff_t *tvb, int offset,
2515                         packet_info *pinfo, proto_tree *tree,
2516                         char *drep)
2517 {
2518         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2519                 hf_netlogon_privilege_name, 1);
2520
2521         return offset;
2522 }
2523
2524 static int
2525 netlogon_dissect_PRIV_NAME_ARRAY(tvbuff_t *tvb, int offset,
2526                         packet_info *pinfo, proto_tree *tree,
2527                         char *drep)
2528 {
2529         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
2530                 netlogon_dissect_PRIV_NAME);
2531
2532         return offset;
2533 }
2534
2535
2536
2537 /*
2538  * IDL typedef struct {
2539  * IDL   long privilegeentries;
2540  * IDL   long provolegecontrol;
2541  * IDL   [unique][size_is(privilege_entries)] long *privilege_attrib;
2542  * IDL   [unique][size_is(privilege_entries)] UNICODESTRING *privilege_name;
2543  * IDL   QUOTALIMITS quotalimits;
2544  * IDL   long SecurityInformation;
2545  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
2546  * IDL   UNICODESTRING dummy1;
2547  * IDL   UNICODESTRING dummy2;
2548  * IDL   UNICODESTRING dummy3;
2549  * IDL   UNICODESTRING dummy4;
2550  * IDL   long dummy5;
2551  * IDL   long dummy6;
2552  * IDL   long dummy7;
2553  * IDL   long dummy8;
2554  * IDL } DELTA_ACCOUNTS;
2555  */
2556 static int
2557 netlogon_dissect_DELTA_ACCOUNTS(tvbuff_t *tvb, int offset,
2558                         packet_info *pinfo, proto_tree *tree,
2559                         char *drep)
2560 {
2561         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2562                 hf_netlogon_privilege_entries, NULL);
2563
2564         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2565                 hf_netlogon_privilege_control, NULL);
2566
2567         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2568                 netlogon_dissect_PRIV_ATTR_ARRAY, NDR_POINTER_UNIQUE,
2569                 "PRIV_ATTR_ARRAY:", -1);
2570
2571         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2572                 netlogon_dissect_PRIV_NAME_ARRAY, NDR_POINTER_UNIQUE,
2573                 "PRIV_NAME_ARRAY:", -1);
2574
2575         offset = netlogon_dissect_QUOTA_LIMITS(tvb, offset,
2576                 pinfo, tree, drep);
2577
2578         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2579                 hf_netlogon_systemflags, NULL);
2580
2581         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2582                 hf_netlogon_security_information, NULL);
2583
2584         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
2585                 pinfo, tree, drep);
2586
2587         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2588                 hf_netlogon_dummy, 0);
2589
2590         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2591                 hf_netlogon_dummy, 0);
2592
2593         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2594                 hf_netlogon_dummy, 0);
2595
2596         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2597                 hf_netlogon_dummy, 0);
2598
2599         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2600                 hf_netlogon_reserved, NULL);
2601
2602         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2603                 hf_netlogon_reserved, NULL);
2604
2605         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2606                 hf_netlogon_reserved, NULL);
2607
2608         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2609                 hf_netlogon_reserved, NULL);
2610
2611         return offset;
2612 }
2613
2614 /*
2615  * IDL typedef struct {
2616  * IDL   long len;
2617  * IDL   long maxlen;
2618  * IDL   [unique][size_is(maxlen)][length_is(len)] char *cipher_data;
2619  * IDL } CIPHER_VALUE;
2620  */
2621 static int
2622 netlogon_dissect_CIPHER_VALUE_DATA(tvbuff_t *tvb, int offset,
2623                         packet_info *pinfo, proto_tree *tree,
2624                         char *drep)
2625 {
2626         dcerpc_info *di;
2627         guint32 data_len;
2628
2629         di=pinfo->private_data;
2630         if(di->conformant_run){
2631                 /*just a run to handle conformant arrays, nothing to dissect */
2632                 return offset;
2633         }
2634
2635         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
2636                 hf_netlogon_cipher_maxlen, NULL);
2637
2638         /* skip offset */
2639         offset += 4;
2640
2641         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
2642                 hf_netlogon_cipher_len, &data_len);
2643
2644         proto_tree_add_item(tree, di->hf_index, tvb, offset,
2645                 data_len, FALSE);
2646         offset += data_len;
2647
2648         return offset;
2649 }
2650 static int
2651 netlogon_dissect_CIPHER_VALUE(tvbuff_t *tvb, int offset,
2652                         packet_info *pinfo, proto_tree *parent_tree,
2653                         char *drep, char *name, int hf_index)
2654 {
2655         proto_item *item=NULL;
2656         proto_tree *tree=NULL;
2657         int old_offset=offset;
2658
2659         if(parent_tree){
2660                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
2661                         name);
2662                 tree = proto_item_add_subtree(item, ett_CYPHER_VALUE);
2663         }
2664
2665         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
2666                 hf_netlogon_cipher_len, NULL);
2667
2668         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
2669                 hf_netlogon_cipher_maxlen, NULL);
2670
2671         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2672                 netlogon_dissect_CIPHER_VALUE_DATA, NDR_POINTER_UNIQUE,
2673                 name, hf_index);
2674
2675         proto_item_set_len(item, offset-old_offset);
2676         return offset;
2677 }
2678
2679 /*
2680  * IDL typedef struct {
2681  * IDL   CIPHER_VALUE current_cipher;
2682  * IDL   NTTIME current_cipher_set_time;
2683  * IDL   CIPHER_VALUE old_cipher;
2684  * IDL   NTTIME old_cipher_set_time;
2685  * IDL   long SecurityInformation;
2686  * IDL   LSA_SECURITY_DESCRIPTOR sec_desc;
2687  * IDL   UNICODESTRING dummy1;
2688  * IDL   UNICODESTRING dummy2;
2689  * IDL   UNICODESTRING dummy3;
2690  * IDL   UNICODESTRING dummy4;
2691  * IDL   long dummy5;
2692  * IDL   long dummy6;
2693  * IDL   long dummy7;
2694  * IDL   long dummy8;
2695  * IDL } DELTA_SECRET;
2696  */
2697 static int
2698 netlogon_dissect_DELTA_SECRET(tvbuff_t *tvb, int offset,
2699                         packet_info *pinfo, proto_tree *tree,
2700                         char *drep)
2701 {
2702         offset = netlogon_dissect_CIPHER_VALUE(tvb, offset,
2703                 pinfo, tree, drep,
2704                 "CIPHER_VALUE: current cipher value",
2705                 hf_netlogon_cipher_current_data);
2706
2707         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
2708                 hf_netlogon_cipher_current_set_time);
2709
2710         offset = netlogon_dissect_CIPHER_VALUE(tvb, offset,
2711                 pinfo, tree, drep,
2712                 "CIPHER_VALUE: old cipher value",
2713                 hf_netlogon_cipher_old_data);
2714
2715         offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep,
2716                 hf_netlogon_cipher_old_set_time);
2717
2718         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2719                 hf_netlogon_security_information, NULL);
2720
2721         offset = lsa_dissect_LSA_SECURITY_DESCRIPTOR(tvb, offset,
2722                 pinfo, tree, drep);
2723
2724         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2725                 hf_netlogon_dummy, 0);
2726
2727         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2728                 hf_netlogon_dummy, 0);
2729
2730         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2731                 hf_netlogon_dummy, 0);
2732
2733         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
2734                 hf_netlogon_dummy, 0);
2735
2736         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2737                 hf_netlogon_reserved, NULL);
2738
2739         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2740                 hf_netlogon_reserved, NULL);
2741
2742         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2743                 hf_netlogon_reserved, NULL);
2744
2745         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2746                 hf_netlogon_reserved, NULL);
2747
2748         return offset;
2749 }
2750
2751 /*
2752  * IDL typedef struct {
2753  * IDL   long low_value;
2754  * IDL   long high_value;
2755  * } MODIFIED_COUNT;
2756  */
2757 static int
2758 netlogon_dissect_MODIFIED_COUNT(tvbuff_t *tvb, int offset,
2759                         packet_info *pinfo, proto_tree *tree,
2760                         char *drep)
2761 {
2762         offset = dissect_ndr_uint64(tvb, offset, pinfo, tree, drep,
2763                 hf_netlogon_modify_count, NULL);
2764
2765         return offset;
2766 }
2767
2768
2769 #define DT_DELTA_DOMAIN                 1
2770 #define DT_DELTA_GROUP                  2
2771 #define DT_DELTA_RENAME_GROUP           4
2772 #define DT_DELTA_USER                   5
2773 #define DT_DELTA_RENAME_USER            7
2774 #define DT_DELTA_GROUP_MEMBER           8
2775 #define DT_DELTA_ALIAS                  9
2776 #define DT_DELTA_RENAME_ALIAS           11
2777 #define DT_DELTA_ALIAS_MEMBER           12
2778 #define DT_DELTA_POLICY                 13
2779 #define DT_DELTA_TRUSTED_DOMAINS        14
2780 #define DT_DELTA_ACCOUNTS               16
2781 #define DT_DELTA_SECRET                 18
2782 #define DT_DELTA_DELETE_GROUP           20
2783 #define DT_DELTA_DELETE_USER            21
2784 #define DT_MODIFIED_COUNT               22
2785 static const value_string delta_type_vals[] = {
2786         { DT_DELTA_DOMAIN,              "Domain" },
2787         { DT_DELTA_GROUP,               "Group" },
2788         { DT_DELTA_RENAME_GROUP,        "Rename Group" },
2789         { DT_DELTA_USER,                "User" },
2790         { DT_DELTA_RENAME_USER,         "Rename User" },
2791         { DT_DELTA_GROUP_MEMBER,        "Group Member" },
2792         { DT_DELTA_ALIAS,               "Alias" },
2793         { DT_DELTA_RENAME_ALIAS,        "Rename Alias" },
2794         { DT_DELTA_ALIAS_MEMBER,        "Alias Member" },
2795         { DT_DELTA_POLICY,              "Policy" },
2796         { DT_DELTA_TRUSTED_DOMAINS,     "Trusted Domains" },
2797         { DT_DELTA_ACCOUNTS,            "Accounts" },
2798         { DT_DELTA_SECRET,              "Secret" },
2799         { DT_DELTA_DELETE_GROUP,        "Delete Group" },
2800         { DT_DELTA_DELETE_USER,         "Delete User" },
2801         { DT_MODIFIED_COUNT,            "Modified Count" },
2802         { 0, NULL }
2803 };
2804 /*
2805  * IDL typedef [switch_type(short)] union {
2806  * IDL   [case(1)][unique] DELTA_DOMAIN *domain;
2807  * IDL   [case(2)][unique] DELTA_GROUP *group;
2808  * IDL   [case(4)][unique] DELTA_RENAME_GROUP *rename_group;
2809  * IDL   [case(5)][unique] DELTA_USER *user;
2810  * IDL   [case(7)][unique] DELTA_RENAME_USER *rename_user;
2811  * IDL   [case(8)][unique] DELTA_GROUP_MEMBER *group_member;
2812  * IDL   [case(9)][unique] DELTA_ALIAS *alias;
2813  * IDL   [case(11)][unique] DELTA_RENAME_ALIAS *rename_alias;
2814  * IDL   [case(12)][unique] DELTA_ALIAS_MEMBER *alias_member;
2815  * IDL   [case(13)][unique] DELTA_POLICY *policy;
2816  * IDL   [case(14)][unique] DELTA_TRUSTED_DOMAINS *trusted_domains;
2817  * IDL   [case(16)][unique] DELTA_ACCOUNTS *accounts;
2818  * IDL   [case(18)][unique] DELTA_SECRET *secret;
2819  * IDL   [case(20)][unique] DELTA_DELETE_USER *delete_group;
2820  * IDL   [case(21)][unique] DELTA_DELETE_USER *delete_user;
2821  * IDL   [case(22)][unique] MODIFIED_COUNT *modified_count;
2822  * IDL } DELTA_UNION;
2823  */
2824 static int
2825 netlogon_dissect_DELTA_UNION(tvbuff_t *tvb, int offset,
2826                         packet_info *pinfo, proto_tree *parent_tree,
2827                         char *drep)
2828 {
2829         proto_item *item=NULL;
2830         proto_tree *tree=NULL;
2831         int old_offset=offset;
2832         guint16 level;
2833
2834         if(parent_tree){
2835                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
2836                         "DELTA_UNION:");
2837                 tree = proto_item_add_subtree(item, ett_DELTA_UNION);
2838         }
2839
2840         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
2841                 hf_netlogon_delta_type, &level);
2842
2843         ALIGN_TO_4_BYTES;
2844         switch(level){
2845         case 1:
2846                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2847                         netlogon_dissect_DELTA_DOMAIN, NDR_POINTER_UNIQUE,
2848                         "DELTA_DOMAIN:", -1);
2849                 break;
2850         case 2:
2851                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2852                         netlogon_dissect_DELTA_GROUP, NDR_POINTER_UNIQUE,
2853                         "DELTA_GROUP:", -1);
2854                 break;
2855         case 4:
2856                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2857                         netlogon_dissect_DELTA_RENAME, NDR_POINTER_UNIQUE,
2858                         "DELTA_RENAME_GROUP:", hf_netlogon_group_name);
2859                 break;
2860         case 5:
2861                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2862                         netlogon_dissect_DELTA_USER, NDR_POINTER_UNIQUE,
2863                         "DELTA_USER:", -1);
2864                 break;
2865         case 7:
2866                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2867                         netlogon_dissect_DELTA_RENAME, NDR_POINTER_UNIQUE,
2868                         "DELTA_RENAME_USER:", hf_netlogon_acct_name);
2869                 break;
2870         case 8:
2871                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2872                         netlogon_dissect_DELTA_GROUP_MEMBER, NDR_POINTER_UNIQUE,
2873                         "DELTA_GROUP_MEMBER:", -1);
2874                 break;
2875         case 9:
2876                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2877                         netlogon_dissect_DELTA_ALIAS, NDR_POINTER_UNIQUE,
2878                         "DELTA_ALIAS:", -1);
2879                 break;
2880         case 11:
2881                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2882                         netlogon_dissect_DELTA_RENAME, NDR_POINTER_UNIQUE,
2883                         "DELTA_RENAME_ALIAS:", hf_netlogon_alias_name);
2884                 break;
2885         case 12:
2886                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2887                         netlogon_dissect_DELTA_ALIAS_MEMBER, NDR_POINTER_UNIQUE,
2888                         "DELTA_ALIAS_MEMBER:", -1);
2889                 break;
2890         case 13:
2891                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2892                         netlogon_dissect_DELTA_POLICY, NDR_POINTER_UNIQUE,
2893                         "DELTA_POLICY:", -1);
2894                 break;
2895         case 14:
2896                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2897                         netlogon_dissect_DELTA_TRUSTED_DOMAINS, NDR_POINTER_UNIQUE,
2898                         "DELTA_TRUSTED_DOMAINS:", -1);
2899                 break;
2900         case 16:
2901                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2902                         netlogon_dissect_DELTA_ACCOUNTS, NDR_POINTER_UNIQUE,
2903                         "DELTA_ACCOUNTS:", -1);
2904                 break;
2905         case 18:
2906                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2907                         netlogon_dissect_DELTA_SECRET, NDR_POINTER_UNIQUE,
2908                         "DELTA_SECRET:", -1);
2909                 break;
2910         case 20:
2911                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2912                         netlogon_dissect_DELTA_DELETE_USER, NDR_POINTER_UNIQUE,
2913                         "DELTA_DELETE_GROUP:", -1);
2914                 break;
2915         case 21:
2916                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2917                         netlogon_dissect_DELTA_DELETE_USER, NDR_POINTER_UNIQUE,
2918                         "DELTA_DELETE_USER:", -1);
2919                 break;
2920         case 22:
2921                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
2922                         netlogon_dissect_MODIFIED_COUNT, NDR_POINTER_UNIQUE,
2923                         "MODIFIED_COUNT:", -1);
2924                 break;
2925         }
2926
2927         proto_item_set_len(item, offset-old_offset);
2928         return offset;
2929 }
2930
2931
2932
2933 /* IDL XXX must verify this one, especially 13-19
2934  * IDL typedef [switch_type(short)] union {
2935  * IDL   [case(1)] long rid;
2936  * IDL   [case(2)] long rid;
2937  * IDL   [case(3)] long rid;
2938  * IDL   [case(4)] long rid;
2939  * IDL   [case(5)] long rid;
2940  * IDL   [case(6)] long rid;
2941  * IDL   [case(7)] long rid;
2942  * IDL   [case(8)] long rid;
2943  * IDL   [case(9)] long rid;
2944  * IDL   [case(10)] long rid;
2945  * IDL   [case(11)] long rid;
2946  * IDL   [case(12)] long rid;
2947  * IDL   [case(13)] [unique] SID *sid;
2948  * IDL   [case(14)] [unique] SID *sid;
2949  * IDL   [case(15)] [unique] SID *sid;
2950  * IDL   [case(16)] [unique] SID *sid;
2951  * IDL   [case(17)] [unique] SID *sid;
2952  * IDL   [case(18)] [unique][string] wchar_t *Name ;
2953  * IDL   [case(19)] [unique][string] wchar_t *Name ;
2954  * IDL   [case(20)] long rid;
2955  * IDL   [case(21)] long rid;
2956  * IDL } DELTA_ID_UNION;
2957  */
2958 static int
2959 netlogon_dissect_DELTA_ID_UNION(tvbuff_t *tvb, int offset,
2960                         packet_info *pinfo, proto_tree *parent_tree,
2961                         char *drep)
2962 {
2963         proto_item *item=NULL;
2964         proto_tree *tree=NULL;
2965         int old_offset=offset;
2966         guint16 level;
2967
2968         if(parent_tree){
2969                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
2970                         "DELTA_ID_UNION:");
2971                 tree = proto_item_add_subtree(item, ett_DELTA_ID_UNION);
2972         }
2973
2974         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
2975                 hf_netlogon_level16, &level);
2976
2977         ALIGN_TO_4_BYTES;
2978         switch(level){
2979         case 1:
2980                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2981                         hf_netlogon_user_rid, NULL);
2982                 break;
2983         case 2:
2984                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2985                         hf_netlogon_user_rid, NULL);
2986                 break;
2987         case 3:
2988                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2989                         hf_netlogon_user_rid, NULL);
2990                 break;
2991         case 4:
2992                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2993                         hf_netlogon_user_rid, NULL);
2994                 break;
2995         case 5:
2996                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
2997                         hf_netlogon_user_rid, NULL);
2998                 break;
2999         case 6:
3000                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3001                         hf_netlogon_user_rid, NULL);
3002                 break;
3003         case 7:
3004                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3005                         hf_netlogon_user_rid, NULL);
3006                 break;
3007         case 8:
3008                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3009                         hf_netlogon_user_rid, NULL);
3010                 break;
3011         case 9:
3012                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3013                         hf_netlogon_user_rid, NULL);
3014                 break;
3015         case 10:
3016                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3017                         hf_netlogon_user_rid, NULL);
3018                 break;
3019         case 11:
3020                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3021                         hf_netlogon_user_rid, NULL);
3022                 break;
3023         case 12:
3024                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3025                         hf_netlogon_user_rid, NULL);
3026                 break;
3027         case 13:
3028                 offset = dissect_ndr_nt_PSID(tvb, offset,
3029                         pinfo, tree, drep, -1);
3030                 break;
3031         case 14:
3032                 offset = dissect_ndr_nt_PSID(tvb, offset,
3033                         pinfo, tree, drep, -1);
3034                 break;
3035         case 15:
3036                 offset = dissect_ndr_nt_PSID(tvb, offset,
3037                         pinfo, tree, drep, -1);
3038                 break;
3039         case 16:
3040                 offset = dissect_ndr_nt_PSID(tvb, offset,
3041                         pinfo, tree, drep, -1);
3042                 break;
3043         case 17:
3044                 offset = dissect_ndr_nt_PSID(tvb, offset,
3045                         pinfo, tree, drep, -1);
3046                 break;
3047         case 18:
3048                 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, 
3049                         tree, drep, NDR_POINTER_UNIQUE, "unknown", 
3050                         hf_netlogon_unknown_string, 0);
3051                 break;
3052         case 19:
3053                 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, 
3054                         tree, drep, NDR_POINTER_UNIQUE, "unknown", 
3055                         hf_netlogon_unknown_string, 0);
3056                 break;
3057         case 20:
3058                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3059                         hf_netlogon_user_rid, NULL);
3060                 break;
3061         case 21:
3062                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3063                         hf_netlogon_user_rid, NULL);
3064                 break;
3065         }
3066
3067         proto_item_set_len(item, offset-old_offset);
3068         return offset;
3069 }
3070
3071 /*
3072  * IDL typedef struct {
3073  * IDL   short delta_type;
3074  * IDL   DELTA_ID_UNION delta_id_union;
3075  * IDL   DELTA_UNION delta_union;
3076  * IDL } DELTA_ENUM;
3077  */
3078 static int
3079 netlogon_dissect_DELTA_ENUM(tvbuff_t *tvb, int offset,
3080                         packet_info *pinfo, proto_tree *parent_tree,
3081                         char *drep)
3082 {
3083         proto_item *item=NULL;
3084         proto_tree *tree=NULL;
3085         int old_offset=offset;
3086
3087         if(parent_tree){
3088                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
3089                         "DELTA_ENUM:");
3090                 tree = proto_item_add_subtree(item, ett_DELTA_ENUM);
3091         }
3092
3093         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
3094                 hf_netlogon_delta_type, NULL);
3095
3096         offset = netlogon_dissect_DELTA_ID_UNION(tvb, offset,
3097                 pinfo, tree, drep);
3098
3099         offset = netlogon_dissect_DELTA_UNION(tvb, offset,
3100                 pinfo, tree, drep);
3101
3102         proto_item_set_len(item, offset-old_offset);
3103         return offset;
3104 }
3105
3106 static int
3107 netlogon_dissect_DELTA_ENUM_array(tvbuff_t *tvb, int offset,
3108                         packet_info *pinfo, proto_tree *tree,
3109                         char *drep)
3110 {
3111         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
3112                 netlogon_dissect_DELTA_ENUM);
3113
3114         return offset;
3115 }
3116
3117 /*
3118  * IDL typedef struct {
3119  * IDL   long num_deltas;
3120  * IDL   [unique][size_is(num_deltas)] DELTA_ENUM *delta_enum;
3121  * IDL } DELTA_ENUM_ARRAY;
3122  */
3123 static int
3124 netlogon_dissect_DELTA_ENUM_ARRAY(tvbuff_t *tvb, int offset,
3125                         packet_info *pinfo, proto_tree *tree,
3126                         char *drep)
3127 {
3128         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3129                 hf_netlogon_num_deltas, NULL);
3130
3131         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3132                 netlogon_dissect_DELTA_ENUM_array, NDR_POINTER_UNIQUE,
3133                 "DELTA_ENUM: deltas", -1);
3134
3135         return offset;
3136 }
3137
3138
3139 /*
3140  * IDL long NetDatabaseDeltas(
3141  * IDL      [in][string][ref] wchar_t *logonserver, # REF!!!
3142  * IDL      [in][string][ref] wchar_t *computername,
3143  * IDL      [in][ref] AUTHENTICATOR credential,
3144  * IDL      [in][out][ref] AUTHENTICATOR return_authenticator,
3145  * IDL      [in] long database_id,
3146  * IDL      [in][out][ref] MODIFIED_COUNT domain_modify_count,
3147  * IDL      [in] long preferredmaximumlength,
3148  * IDL      [out][unique] DELTA_ENUM_ARRAY *delta_enum_array
3149  * IDL );
3150  */
3151 static int
3152 netlogon_dissect_netsamdeltas_rqst(tvbuff_t *tvb, int offset,
3153         packet_info *pinfo, proto_tree *tree, char *drep)
3154 {
3155         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3156                 NDR_POINTER_REF, "Server Handle", hf_netlogon_logonsrv_handle, 0);
3157
3158         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3159                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3160
3161         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3162                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3163                 "AUTHENTICATOR: credential", -1);
3164
3165         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3166                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3167                 "AUTHENTICATOR: return_authenticator", -1);
3168
3169         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3170                 hf_netlogon_database_id, NULL);
3171
3172         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3173                 netlogon_dissect_MODIFIED_COUNT, NDR_POINTER_REF,
3174                 "MODIFIED_COUNT: domain modified count", -1);
3175
3176         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3177                 hf_netlogon_max_size, NULL);
3178
3179         return offset;
3180 }
3181 static int
3182 netlogon_dissect_netsamdeltas_reply(tvbuff_t *tvb, int offset,
3183         packet_info *pinfo, proto_tree *tree, char *drep)
3184 {
3185         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3186                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3187                 "AUTHENTICATOR: return_authenticator", -1);
3188
3189         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3190                 netlogon_dissect_MODIFIED_COUNT, NDR_POINTER_REF,
3191                 "MODIFIED_COUNT: domain modified count", -1);
3192
3193         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3194                 netlogon_dissect_DELTA_ENUM_ARRAY, NDR_POINTER_UNIQUE,
3195                 "DELTA_ENUM_ARRAY: deltas", -1);
3196
3197         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3198                                   hf_netlogon_rc, NULL);
3199
3200         return offset;
3201 }
3202
3203
3204 /*
3205  * IDL long NetDatabaseSync(
3206  * IDL      [in][string][ref] wchar_t *logonserver, # REF!!!
3207  * IDL      [in][string][ref] wchar_t *computername,
3208  * IDL      [in][ref] AUTHENTICATOR credential,
3209  * IDL      [in][out][ref] AUTHENTICATOR return_authenticator,
3210  * IDL      [in] long database_id,
3211  * IDL      [in][out][ref] long sync_context,
3212  * IDL      [in] long preferredmaximumlength,
3213  * IDL      [out][unique] DELTA_ENUM_ARRAY *delta_enum_array
3214  * IDL );
3215  */
3216 static int
3217 netlogon_dissect_netlogondatabasesync_rqst(tvbuff_t *tvb, int offset,
3218         packet_info *pinfo, proto_tree *tree, char *drep)
3219 {
3220         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3221                 NDR_POINTER_REF, "Server Handle", hf_netlogon_logonsrv_handle, 0);
3222
3223         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3224                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3225
3226         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3227                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3228                 "AUTHENTICATOR: credential", -1);
3229
3230         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3231                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3232                 "AUTHENTICATOR: return_authenticator", -1);
3233
3234         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3235                 hf_netlogon_database_id, NULL);
3236
3237         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3238                 hf_netlogon_sync_context, NULL);
3239
3240         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3241                 hf_netlogon_max_size, NULL);
3242
3243         return offset;
3244 }
3245
3246
3247 static int
3248 netlogon_dissect_netlogondatabasesync_reply(tvbuff_t *tvb, int offset,
3249         packet_info *pinfo, proto_tree *tree, char *drep)
3250 {
3251         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3252                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3253                 "AUTHENTICATOR: return_authenticator", -1);
3254
3255         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3256                 hf_netlogon_sync_context, NULL);
3257
3258         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3259                 netlogon_dissect_DELTA_ENUM_ARRAY, NDR_POINTER_UNIQUE,
3260                 "DELTA_ENUM_ARRAY: deltas", -1);
3261
3262         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3263                                   hf_netlogon_rc, NULL);
3264
3265         return offset;
3266 }
3267
3268 /*
3269  * IDL typedef struct {
3270  * IDL   char computer_name[16];
3271  * IDL   long timecreated;
3272  * IDL   long serial_number;
3273  * IDL } UAS_INFO_0;
3274  */
3275 static int
3276 netlogon_dissect_UAS_INFO_0(tvbuff_t *tvb, int offset,
3277                         packet_info *pinfo, proto_tree *tree,
3278                         char *drep)
3279 {
3280         dcerpc_info *di;
3281
3282         di=pinfo->private_data;
3283         if(di->conformant_run){
3284                 /*just a run to handle conformant arrays, nothing to dissect */
3285                 return offset;
3286         }
3287
3288         proto_tree_add_item(tree, hf_netlogon_computer_name, tvb, offset, 16, FALSE);
3289         offset += 16;
3290
3291         proto_tree_add_text(tree, tvb, offset, 4, "Time Created: unknown time format");
3292         offset+= 4;
3293
3294         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3295                 hf_netlogon_serial_number, NULL);
3296
3297         return offset;
3298 }
3299
3300
3301 static int
3302 netlogon_dissect_BYTE_byte(tvbuff_t *tvb, int offset,
3303                         packet_info *pinfo, proto_tree *tree,
3304                         char *drep)
3305 {
3306                 offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
3307                         hf_netlogon_unknown_char, NULL);
3308
3309         return offset;
3310 }
3311
3312 static int
3313 netlogon_dissect_BYTE_array(tvbuff_t *tvb, int offset,
3314                         packet_info *pinfo, proto_tree *tree,
3315                         char *drep)
3316 {
3317         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
3318                 netlogon_dissect_BYTE_byte);
3319
3320         return offset;
3321 }
3322
3323 /*
3324  * IDL long NetAccountDelta(
3325  * IDL      [in][string][unique] wchar_t *logonserver,
3326  * IDL      [in][string][ref] wchar_t *computername,
3327  * IDL      [in][ref] AUTHENTICATOR credential,
3328  * IDL      [in][out][ref] AUTHENTICATOR return_authenticator,
3329  * IDL      [out][ref][size_is(count_returned)] char *Buffer,
3330  * IDL      [out][ref] long count_returned,
3331  * IDL      [out][ref] long total_entries,
3332  * IDL      [in][out][ref] UAS_INFO_0 recordid,
3333  * IDL      [in][long] count,
3334  * IDL      [in][long] level,
3335  * IDL      [in][long] buffersize,
3336  * IDL );
3337  */
3338 static int
3339 netlogon_dissect_netlogonaccountdeltas_rqst(tvbuff_t *tvb, int offset,
3340         packet_info *pinfo, proto_tree *tree, char *drep)
3341 {
3342         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
3343                 pinfo, tree, drep);
3344
3345         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3346                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3347
3348         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3349                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3350                 "AUTHENTICATOR: credential", -1);
3351
3352         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3353                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3354                 "AUTHENTICATOR: return_authenticator", -1);
3355
3356         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3357                 netlogon_dissect_UAS_INFO_0, NDR_POINTER_REF,
3358                 "UAS_INFO_0: RecordID", -1);
3359
3360         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3361                 hf_netlogon_count, NULL);
3362
3363         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3364                 hf_netlogon_level, NULL);
3365
3366         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3367                 hf_netlogon_max_size, NULL);
3368
3369         return offset;
3370 }
3371 static int
3372 netlogon_dissect_netlogonaccountdeltas_reply(tvbuff_t *tvb, int offset,
3373         packet_info *pinfo, proto_tree *tree, char *drep)
3374 {
3375         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3376                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3377                 "AUTHENTICATOR: return_authenticator", -1);
3378
3379         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3380                 netlogon_dissect_BYTE_array, NDR_POINTER_REF,
3381                 "BYTE_array: Buffer", -1);
3382
3383         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3384                 hf_netlogon_count, NULL);
3385
3386         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3387                 hf_netlogon_entries, NULL);
3388
3389         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3390                 netlogon_dissect_UAS_INFO_0, NDR_POINTER_REF,
3391                 "UAS_INFO_0: RecordID", -1);
3392
3393         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3394                                   hf_netlogon_rc, NULL);
3395
3396         return offset;
3397 }
3398
3399
3400 /*
3401  * IDL long NetAccountDelta(
3402  * IDL      [in][string][unique] wchar_t *logonserver,
3403  * IDL      [in][string][ref] wchar_t *computername,
3404  * IDL      [in][ref] AUTHENTICATOR credential,
3405  * IDL      [in][out][ref] AUTHENTICATOR return_authenticator,
3406  * IDL      [out][ref][size_is(count_returned)] char *Buffer,
3407  * IDL      [out][ref] long count_returned,
3408  * IDL      [out][ref] long total_entries,
3409  * IDL      [out][ref] long next_reference,
3410  * IDL      [in][long] reference,
3411  * IDL      [in][long] level,
3412  * IDL      [in][long] buffersize,
3413  * IDL      [in][out][ref] UAS_INFO_0 recordid,
3414  * IDL );
3415  */
3416 static int
3417 netlogon_dissect_netlogonaccountsync_rqst(tvbuff_t *tvb, int offset,
3418         packet_info *pinfo, proto_tree *tree, char *drep)
3419 {
3420         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
3421                 pinfo, tree, drep);
3422
3423         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3424                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3425
3426         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3427                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3428                 "AUTHENTICATOR: credential", -1);
3429
3430         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3431                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3432                 "AUTHENTICATOR: return_authenticator", -1);
3433
3434         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3435                 hf_netlogon_reference, NULL);
3436
3437         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3438                 hf_netlogon_level, NULL);
3439
3440         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3441                 hf_netlogon_max_size, NULL);
3442
3443         return offset;
3444 }
3445 static int
3446 netlogon_dissect_netlogonaccountsync_reply(tvbuff_t *tvb, int offset,
3447         packet_info *pinfo, proto_tree *tree, char *drep)
3448 {
3449         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3450                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3451                 "AUTHENTICATOR: return_authenticator", -1);
3452
3453         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3454                 netlogon_dissect_BYTE_array, NDR_POINTER_REF,
3455                 "BYTE_array: Buffer", -1);
3456
3457         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3458                 hf_netlogon_count, NULL);
3459
3460         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3461                 hf_netlogon_entries, NULL);
3462
3463         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3464                 hf_netlogon_next_reference, NULL);
3465
3466         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3467                 netlogon_dissect_UAS_INFO_0, NDR_POINTER_REF,
3468                 "UAS_INFO_0: RecordID", -1);
3469
3470         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3471                                   hf_netlogon_rc, NULL);
3472
3473         return offset;
3474 }
3475
3476
3477 /*
3478  * IDL long NetGetDCName(
3479  * IDL    [in][ref][string] wchar_t *logon_server,
3480  * IDL    [in][unique][string] wchar_t *domainname,
3481  * IDL    [out][unique][string] wchar_t *dcname,
3482  * IDL };
3483  */
3484 static int
3485 netlogon_dissect_netlogongetdcname_rqst(tvbuff_t *tvb, int offset,
3486         packet_info *pinfo, proto_tree *tree, char *drep)
3487 {
3488         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3489                 NDR_POINTER_REF, "Server Handle", hf_netlogon_logonsrv_handle, 0);
3490
3491         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3492                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_domain_name, 0);
3493
3494         return offset;
3495 }
3496 static int
3497 netlogon_dissect_netlogongetdcname_reply(tvbuff_t *tvb, int offset,
3498         packet_info *pinfo, proto_tree *tree, char *drep)
3499 {
3500         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3501                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_dc_name, 0);
3502
3503         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3504                                   hf_netlogon_rc, NULL);
3505
3506         return offset;
3507 }
3508
3509
3510
3511 /*
3512  * IDL typedef struct {
3513  * IDL   long flags;
3514  * IDL   long pdc_connection_status;
3515  * IDL } NETLOGON_INFO_1;
3516  */
3517 static int
3518 netlogon_dissect_NETLOGON_INFO_1(tvbuff_t *tvb, int offset,
3519                         packet_info *pinfo, proto_tree *tree,
3520                         char *drep)
3521 {
3522         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3523                 hf_netlogon_flags, NULL);
3524
3525         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3526                 hf_netlogon_pdc_connection_status, NULL);
3527
3528         return offset;
3529 }
3530
3531
3532 /*
3533  * IDL typedef struct {
3534  * IDL   long flags;
3535  * IDL   long pdc_connection_status;
3536  * IDL   [unique][string] wchar_t trusted_dc_name;
3537  * IDL   long tc_connection_status;
3538  * IDL } NETLOGON_INFO_2;
3539  */
3540 static int
3541 netlogon_dissect_NETLOGON_INFO_2(tvbuff_t *tvb, int offset,
3542                         packet_info *pinfo, proto_tree *tree,
3543                         char *drep)
3544 {
3545         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3546                 hf_netlogon_flags, NULL);
3547
3548         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3549                 hf_netlogon_pdc_connection_status, NULL);
3550
3551         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3552                 NDR_POINTER_UNIQUE, "Trusted DC Name", 
3553                 hf_netlogon_trusted_dc_name, 0);
3554
3555         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3556                 hf_netlogon_tc_connection_status, NULL);
3557
3558         return offset;
3559 }
3560
3561
3562 /*
3563  * IDL typedef struct {
3564  * IDL   long flags;
3565  * IDL   long logon_attempts;
3566  * IDL   long reserved;
3567  * IDL   long reserved;
3568  * IDL   long reserved;
3569  * IDL   long reserved;
3570  * IDL   long reserved;
3571  * IDL } NETLOGON_INFO_3;
3572  */
3573 static int
3574 netlogon_dissect_NETLOGON_INFO_3(tvbuff_t *tvb, int offset,
3575                         packet_info *pinfo, proto_tree *tree,
3576                         char *drep)
3577 {
3578         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3579                 hf_netlogon_flags, NULL);
3580
3581         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3582                 hf_netlogon_logon_attempts, NULL);
3583
3584         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3585                 hf_netlogon_reserved, NULL);
3586
3587         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3588                 hf_netlogon_reserved, NULL);
3589
3590         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3591                 hf_netlogon_reserved, NULL);
3592
3593         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3594                 hf_netlogon_reserved, NULL);
3595
3596         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3597                 hf_netlogon_reserved, NULL);
3598
3599         return offset;
3600 }
3601
3602
3603 /*
3604  * IDL typedef [switch_type(long)] union {
3605  * IDL   [case(1)] [unique] NETLOGON_INFO_1 *i1;
3606  * IDL   [case(2)] [unique] NETLOGON_INFO_2 *i2;
3607  * IDL   [case(3)] [unique] NETLOGON_INFO_3 *i3;
3608  * IDL } CONTROL_QUERY_INFORMATION;
3609  */
3610 static int
3611 netlogon_dissect_CONTROL_QUERY_INFORMATION(tvbuff_t *tvb, int offset,
3612                         packet_info *pinfo, proto_tree *tree,
3613                         char *drep)
3614 {
3615         guint32 level;
3616
3617         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3618                 hf_netlogon_level, &level);
3619
3620         ALIGN_TO_4_BYTES;
3621         switch(level){
3622         case 1:
3623                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3624                         netlogon_dissect_NETLOGON_INFO_1, NDR_POINTER_UNIQUE,
3625                         "NETLOGON_INFO_1:", -1);
3626                 break;
3627         case 2:
3628                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3629                         netlogon_dissect_NETLOGON_INFO_2, NDR_POINTER_UNIQUE,
3630                         "NETLOGON_INFO_2:", -1);
3631                 break;
3632         case 3:
3633                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3634                         netlogon_dissect_NETLOGON_INFO_3, NDR_POINTER_UNIQUE,
3635                         "NETLOGON_INFO_3:", -1);
3636                 break;
3637         }
3638
3639         return offset;
3640 }
3641
3642
3643 /*
3644  * IDL long NetLogonControl(
3645  * IDL      [in][string][unique] wchar_t *logonserver,
3646  * IDL      [in] long function_code,
3647  * IDL      [in] long level,
3648  * IDL      [out][ref] CONTROL_QUERY_INFORMATION
3649  * IDL );
3650  */
3651 static int
3652 netlogon_dissect_netlogoncontrol_rqst(tvbuff_t *tvb, int offset,
3653         packet_info *pinfo, proto_tree *tree, char *drep)
3654 {
3655         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
3656                 pinfo, tree, drep);
3657
3658         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3659                 hf_netlogon_code, NULL);
3660
3661         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3662                 hf_netlogon_level, NULL);
3663
3664         return offset;
3665 }
3666 static int
3667 netlogon_dissect_netlogoncontrol_reply(tvbuff_t *tvb, int offset,
3668         packet_info *pinfo, proto_tree *tree, char *drep)
3669 {
3670         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3671                 netlogon_dissect_CONTROL_QUERY_INFORMATION, NDR_POINTER_REF,
3672                 "CONTROL_QUERY_INFORMATION:", -1);
3673
3674         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3675                                   hf_netlogon_rc, NULL);
3676
3677         return offset;
3678 }
3679
3680
3681 /*
3682  * IDL long NetGetDCName(
3683  * IDL    [in][unique][string] wchar_t *logon_server,
3684  * IDL    [in][unique][string] wchar_t *domainname,
3685  * IDL    [out][unique][string] wchar_t *dcname,
3686  * IDL };
3687  */
3688 static int
3689 netlogon_dissect_netlogongetanydcname_rqst(tvbuff_t *tvb, int offset,
3690         packet_info *pinfo, proto_tree *tree, char *drep)
3691 {
3692         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3693                 NDR_POINTER_UNIQUE, "Server Handle", 
3694                 hf_netlogon_logonsrv_handle, 0);
3695
3696         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3697                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_domain_name, 0);
3698
3699         return offset;
3700 }
3701 static int
3702 netlogon_dissect_netlogongetanydcname_reply(tvbuff_t *tvb, int offset,
3703         packet_info *pinfo, proto_tree *tree, char *drep)
3704 {
3705         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3706                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_dc_name, 0);
3707
3708         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3709                                   hf_netlogon_rc, NULL);
3710
3711         return offset;
3712 }
3713
3714
3715 /*
3716  * IDL typedef [switch_type(long)] union {
3717  * IDL   [case(5)] [unique][string] wchar_t *unknown;
3718  * IDL   [case(6)] [unique][string] wchar_t *unknown;
3719  * IDL   [case(0xfffe)] long unknown;
3720  * IDL   [case(7)] [unique][string] wchar_t *unknown;
3721  * IDL } CONTROL_DATA_INFORMATION;
3722  */
3723 /* XXX
3724  * According to muddle this is what CONTROL_DATA_INFORMATION is supposed
3725  * to look like. However NetMon does not recognize any such informationlevels.
3726  *
3727  * Ill leave it as CONTROL_DATA_INFORMATION with no informationlevels
3728  * until someone has any source of better authority to call upon.
3729  */
3730 static int
3731 netlogon_dissect_CONTROL_DATA_INFORMATION(tvbuff_t *tvb, int offset,
3732                         packet_info *pinfo, proto_tree *tree,
3733                         char *drep)
3734 {
3735         guint32 level;
3736
3737         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3738                 hf_netlogon_level, &level);
3739
3740         ALIGN_TO_4_BYTES;
3741         switch(level){
3742         case 5:
3743                 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, 
3744                         tree, drep, NDR_POINTER_UNIQUE, "unknown", 
3745                         hf_netlogon_unknown_string, 0);
3746                 break;
3747         case 6:
3748                 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, 
3749                         tree, drep, NDR_POINTER_UNIQUE, "unknown", 
3750                         hf_netlogon_unknown_string, 0);
3751                 break;
3752         case 0xfffe:
3753                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3754                         hf_netlogon_unknown_long, NULL);
3755                 break;
3756         case 8:
3757                 offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, 
3758                         tree, drep, NDR_POINTER_UNIQUE, "unknown", 
3759                         hf_netlogon_unknown_string, 0);
3760                 break;
3761         }
3762
3763         return offset;
3764 }
3765
3766
3767 /*
3768  * IDL long NetLogonControl2(
3769  * IDL      [in][string][unique] wchar_t *logonserver,
3770  * IDL      [in] long function_code,
3771  * IDL      [in] long level,
3772  * IDL      [in][ref] CONTROL_DATA_INFORMATION *data,
3773  * IDL      [out][ref] CONTROL_QUERY_INFORMATION *query
3774  * IDL );
3775  */
3776 static int
3777 netlogon_dissect_netlogoncontrol2_rqst(tvbuff_t *tvb, int offset,
3778         packet_info *pinfo, proto_tree *tree, char *drep)
3779 {
3780         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
3781                 pinfo, tree, drep);
3782
3783         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3784                 hf_netlogon_code, NULL);
3785
3786         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3787                 hf_netlogon_level, NULL);
3788
3789         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3790                 netlogon_dissect_CONTROL_DATA_INFORMATION, NDR_POINTER_REF,
3791                 "CONTROL_DATA_INFORMATION: ", -1);
3792
3793         return offset;
3794 }
3795
3796 static int
3797 netlogon_dissect_netlogoncontrol2_reply(tvbuff_t *tvb, int offset,
3798         packet_info *pinfo, proto_tree *tree, char *drep)
3799 {
3800         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3801                 netlogon_dissect_CONTROL_QUERY_INFORMATION, NDR_POINTER_REF,
3802                 "CONTROL_QUERY_INFORMATION:", -1);
3803
3804         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3805                                   hf_netlogon_rc, NULL);
3806
3807         return offset;
3808 }
3809
3810
3811 /*
3812  * IDL long NetServerAuthenticate2(
3813  * IDL      [in][string][unique] wchar_t *logonserver,
3814  * IDL      [in][ref][string] wchar_t *username,
3815  * IDL      [in] short secure_channel_type,
3816  * IDL      [in][ref][string] wchar_t *computername,
3817  * IDL      [in][ref] CREDENTIAL *client_chal,
3818  * IDL      [out][ref] CREDENTIAL *server_chal,
3819  * IDL      [in][out][ref] long *negotiate_flags,
3820  * IDL );
3821  */
3822 static int
3823 netlogon_dissect_netserverauthenticate2_rqst(tvbuff_t *tvb, int offset,
3824         packet_info *pinfo, proto_tree *tree, char *drep)
3825 {
3826         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
3827                 pinfo, tree, drep);
3828
3829         offset = dissect_ndr_pointer_cb(
3830                 tvb, offset, pinfo, tree, drep, 
3831                 dissect_ndr_wchar_cvstring, NDR_POINTER_REF, 
3832                 "User Name", hf_netlogon_acct_name, 
3833                 cb_wstr_postprocess, GINT_TO_POINTER(CB_STR_COL_INFO | 1));
3834
3835         offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
3836                 pinfo, tree, drep);
3837
3838         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3839                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3840
3841         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3842                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
3843                 "CREDENTIAL: client_chal", -1);
3844
3845         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3846                 hf_netlogon_neg_flags, NULL);
3847
3848         return offset;
3849 }
3850
3851 static int
3852 netlogon_dissect_netserverauthenticate2_reply(tvbuff_t *tvb, int offset,
3853         packet_info *pinfo, proto_tree *tree, char *drep)
3854 {
3855         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3856                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
3857                 "CREDENTIAL: server_chal", -1);
3858
3859         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3860                 hf_netlogon_neg_flags, NULL);
3861
3862         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3863                                   hf_netlogon_rc, NULL);
3864
3865         return offset;
3866 }
3867
3868
3869 /*
3870  * IDL long NetDatabaseSync2(
3871  * IDL      [in][string][ref] wchar_t *logonserver, # REF!!!
3872  * IDL      [in][string][ref] wchar_t *computername,
3873  * IDL      [in][ref] AUTHENTICATOR credential,
3874  * IDL      [in][out][ref] AUTHENTICATOR return_authenticator,
3875  * IDL      [in] long database_id,
3876  * IDL      [in] short restart_state,
3877  * IDL      [in][out][ref] long *sync_context,
3878  * IDL      [in] long preferredmaximumlength,
3879  * IDL      [out][unique] DELTA_ENUM_ARRAY *delta_enum_array
3880  * IDL );
3881  */
3882 static int
3883 netlogon_dissect_netdatabasesync2_rqst(tvbuff_t *tvb, int offset,
3884         packet_info *pinfo, proto_tree *tree, char *drep)
3885 {
3886         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3887                 NDR_POINTER_REF, "Server Handle", hf_netlogon_logonsrv_handle, 0);
3888
3889         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3890                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3891
3892         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3893                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3894                 "AUTHENTICATOR: credential", -1);
3895
3896         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3897                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3898                 "AUTHENTICATOR: return_authenticator", -1);
3899
3900         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3901                 hf_netlogon_database_id, NULL);
3902
3903         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
3904                 hf_netlogon_restart_state, NULL);
3905
3906         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3907                 hf_netlogon_sync_context, NULL);
3908
3909         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3910                 hf_netlogon_max_size, NULL);
3911
3912         return offset;
3913 }
3914
3915 static int
3916 netlogon_dissect_netdatabasesync2_reply(tvbuff_t *tvb, int offset,
3917         packet_info *pinfo, proto_tree *tree, char *drep)
3918 {
3919         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3920                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3921                 "AUTHENTICATOR: return_authenticator", -1);
3922
3923         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3924                 hf_netlogon_sync_context, NULL);
3925
3926         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3927                 netlogon_dissect_DELTA_ENUM_ARRAY, NDR_POINTER_UNIQUE,
3928                 "DELTA_ENUM_ARRAY: deltas", -1);
3929
3930         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3931                                   hf_netlogon_rc, NULL);
3932
3933         return offset;
3934 }
3935
3936
3937 /*
3938  * IDL long NetDatabaseRedo(
3939  * IDL      [in][string][ref] wchar_t *logonserver, # REF!!!
3940  * IDL      [in][string][ref] wchar_t *computername,
3941  * IDL      [in][ref] AUTHENTICATOR credential,
3942  * IDL      [in][out][ref] AUTHENTICATOR return_authenticator,
3943  * IDL      [in][ref][size_is(change_log_entry_size)] char *change_log_entry,
3944  * IDL      [in] long change_log_entry_size,
3945  * IDL      [out][unique] DELTA_ENUM_ARRAY *delta_enum_array
3946  * IDL );
3947  */
3948 static int
3949 netlogon_dissect_netlogondatabaseredo_rqst(tvbuff_t *tvb, int offset,
3950         packet_info *pinfo, proto_tree *tree, char *drep)
3951 {
3952         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3953                 NDR_POINTER_REF, "Server Handle", hf_netlogon_logonsrv_handle, 0);
3954
3955         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
3956                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
3957
3958         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3959                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3960                 "AUTHENTICATOR: credential", -1);
3961
3962         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3963                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3964                 "AUTHENTICATOR: return_authenticator", -1);
3965
3966         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3967                 netlogon_dissect_BYTE_array, NDR_POINTER_REF,
3968                 "Change log entry: ", -1);
3969
3970         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
3971                 hf_netlogon_max_log_size, NULL);
3972
3973         return offset;
3974 }
3975
3976 static int
3977 netlogon_dissect_netlogondatabaseredo_reply(tvbuff_t *tvb, int offset,
3978         packet_info *pinfo, proto_tree *tree, char *drep)
3979 {
3980         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3981                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
3982                 "AUTHENTICATOR: return_authenticator", -1);
3983
3984         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
3985                 netlogon_dissect_DELTA_ENUM_ARRAY, NDR_POINTER_UNIQUE,
3986                 "DELTA_ENUM_ARRAY: deltas", -1);
3987
3988         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
3989                                   hf_netlogon_rc, NULL);
3990
3991         return offset;
3992 }
3993
3994
3995 /* XXX NetMon does not recognize this as a valid function. Muddle however
3996  * tells us what parameters it takes but not their names.
3997  * It looks similar to logoncontrol2.  perhaps it is logoncontrol3?
3998  */
3999 /*
4000  * IDL long NetFunction_12(
4001  * IDL      [in][string][unique] wchar_t *logonserver,
4002  * IDL      [in] long function_code,
4003  * IDL      [in] long level,
4004  * IDL      [in][ref] CONTROL_DATA_INFORMATION *data,
4005  * IDL      [out][ref] CONTROL_QUERY_INFORMATION *query
4006  * IDL );
4007  */
4008 static int
4009 netlogon_dissect_function_12_rqst(tvbuff_t *tvb, int offset,
4010         packet_info *pinfo, proto_tree *tree, char *drep)
4011 {
4012         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
4013                 pinfo, tree, drep);
4014
4015         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4016                 hf_netlogon_code, NULL);
4017
4018         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4019                 hf_netlogon_level, NULL);
4020
4021         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4022                 netlogon_dissect_CONTROL_DATA_INFORMATION, NDR_POINTER_REF,
4023                 "CONTROL_DATA_INFORMATION: ", -1);
4024
4025         return offset;
4026 }
4027 static int
4028 netlogon_dissect_function_12_reply(tvbuff_t *tvb, int offset,
4029         packet_info *pinfo, proto_tree *tree, char *drep)
4030 {
4031         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4032                 netlogon_dissect_CONTROL_QUERY_INFORMATION, NDR_POINTER_REF,
4033                 "CONTROL_QUERY_INFORMATION:", -1);
4034
4035         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
4036                                   hf_netlogon_rc, NULL);
4037
4038         return offset;
4039 }
4040
4041
4042
4043
4044 static const value_string trust_type_vals[] = {
4045         { 1,                            "DOWNLEVEL" },
4046         { 2,                            "UPLEVEL" },
4047         { 3,                            "MIT" },
4048         { 4,                            "DCE" },
4049         { 0, NULL }
4050 };
4051
4052 #define DS_INET_ADDRESS         1
4053 #define DS_NETBIOS_ADDRESS      2
4054 static const value_string dc_address_types[] = {
4055         { DS_INET_ADDRESS,              "IP/DNS name" },
4056         { DS_NETBIOS_ADDRESS,           "NetBIOS name" },
4057         { 0, NULL}
4058 };
4059
4060
4061 #define DS_DOMAIN_IN_FOREST             0x0001
4062 #define DS_DOMAIN_DIRECT_OUTBOUND       0x0002
4063 #define DS_DOMAIN_TREE_ROOT             0x0004
4064 #define DS_DOMAIN_PRIMARY               0x0008
4065 #define DS_DOMAIN_NATIVE_MODE           0x0010
4066 #define DS_DOMAIN_DIRECT_INBOUND        0x0020
4067 static const true_false_string trust_inbound = {
4068         "There is a DIRECT INBOUND trust for the servers domain",
4069         "There is NO direct inbound trust for the servers domain"
4070 };
4071 static const true_false_string trust_outbound = {
4072         "There is a DIRECT OUTBOUND trust for this domain",
4073         "There is NO direct outbound trust for this domain"
4074 };
4075 static const true_false_string trust_in_forest = {
4076         "The domain is a member IN the same FOREST as the queried server",
4077         "The domain is NOT a member of the queried servers domain"
4078 };
4079 static const true_false_string trust_native_mode = {
4080         "The primary domain is a NATIVE MODE w2k domain",
4081         "The primary is NOT a native mode w2k domain"
4082 };
4083 static const true_false_string trust_primary = {
4084         "The domain is the PRIMARY domain of the queried server",
4085         "The domain is NOT the primary domain of the queried server"
4086 };
4087 static const true_false_string trust_tree_root = {
4088         "The domain is the ROOT of a domain TREE",
4089         "The domain is NOT a root of a domain tree"
4090 };
4091 static int
4092 netlogon_dissect_DOMAIN_TRUST_FLAGS(tvbuff_t *tvb, int offset,
4093         packet_info *pinfo, proto_tree *parent_tree, char *drep)
4094 {
4095         guint32 mask;
4096         proto_item *item = NULL;
4097         proto_tree *tree = NULL;
4098         dcerpc_info *di;
4099
4100         di=pinfo->private_data;
4101         if(di->conformant_run){
4102                 /*just a run to handle conformant arrays, nothing to dissect */
4103                 return offset;
4104         }
4105
4106         offset=dissect_ndr_uint32(tvb, offset, pinfo, NULL, drep,
4107                         hf_netlogon_trust_flags, &mask);
4108
4109         if(parent_tree){
4110                 item = proto_tree_add_uint(parent_tree, hf_netlogon_trust_flags,
4111                         tvb, offset-4, 4, mask);
4112                 tree = proto_item_add_subtree(item, ett_trust_flags);
4113         }
4114
4115         proto_tree_add_boolean(tree, hf_netlogon_trust_flags_inbound,
4116                 tvb, offset-4, 4, mask);
4117         proto_tree_add_boolean(tree, hf_netlogon_trust_flags_native_mode,
4118                 tvb, offset-4, 4, mask);
4119         proto_tree_add_boolean(tree, hf_netlogon_trust_flags_primary,
4120                 tvb, offset-4, 4, mask);
4121         proto_tree_add_boolean(tree, hf_netlogon_trust_flags_tree_root,
4122                 tvb, offset-4, 4, mask);
4123         proto_tree_add_boolean(tree, hf_netlogon_trust_flags_outbound,
4124                 tvb, offset-4, 4, mask);
4125         proto_tree_add_boolean(tree, hf_netlogon_trust_flags_in_forest,
4126                 tvb, offset-4, 4, mask);
4127
4128         return offset;
4129 }
4130
4131
4132 #define DS_FORCE_REDISCOVERY            0x00000001
4133 #define DS_DIRECTORY_SERVICE_REQUIRED   0x00000010
4134 #define DS_DIRECTORY_SERVICE_PREFERRED  0x00000020
4135 #define DS_GC_SERVER_REQUIRED           0x00000040
4136 #define DS_PDC_REQUIRED                 0x00000080
4137 #define DS_BACKGROUND_ONLY              0x00000100
4138 #define DS_IP_REQUIRED                  0x00000200
4139 #define DS_KDC_REQUIRED                 0x00000400
4140 #define DS_TIMESERV_REQUIRED            0x00000800
4141 #define DS_WRITABLE_REQUIRED            0x00001000
4142 #define DS_GOOD_TIMESERV_PREFERRED      0x00002000
4143 #define DS_AVOID_SELF                   0x00004000
4144 #define DS_ONLY_LDAP_NEEDED             0x00008000
4145 #define DS_IS_FLAT_NAME                 0x00010000
4146 #define DS_IS_DNS_NAME                  0x00020000
4147 #define DS_RETURN_DNS_NAME              0x40000000
4148 #define DS_RETURN_FLAT_NAME             0x80000000
4149 static const true_false_string get_dcname_request_flags_force_rediscovery = {
4150         "FORCE REDISCOVERY of any cached data",
4151         "You may return cached data"
4152 };
4153 static const true_false_string get_dcname_request_flags_directory_service_required = {
4154         "DIRECRTORY SERVICE is REQUIRED on the server",
4155         "We do NOT require directory service servers"
4156 };
4157 static const true_false_string get_dcname_request_flags_directory_service_preferred = {
4158         "DIRECTORY SERVICE servers are PREFERRED",
4159         "We do NOT have a preference for directory service servers"
4160 };
4161 static const true_false_string get_dcname_request_flags_gc_server_required = {
4162         "GC SERVER is REQUIRED",
4163         "gc server is NOT required"
4164 };
4165 static const true_false_string get_dcname_request_flags_pdc_required = {
4166         "PDC SERVER is REQUIRED",
4167         "pdc server is NOT required"
4168 };
4169 static const true_false_string get_dcname_request_flags_background_only = {
4170         "Only returned cahced data, even if it has expired",
4171         "Return cached data unless it has expired"
4172 };
4173 static const true_false_string get_dcname_request_flags_ip_required = {
4174         "IP address is REQUIRED",
4175         "ip address is NOT required"
4176 };
4177 static const true_false_string get_dcname_request_flags_kdc_required = {
4178         "KDC server is REQUIRED",
4179         "kdc server is NOT required"
4180 };
4181 static const true_false_string get_dcname_request_flags_timeserv_required = {
4182         "TIMESERV service is REQUIRED",
4183         "timeserv service is NOT required"
4184 };
4185 static const true_false_string get_dcname_request_flags_writable_required = {
4186         "the requrned dc MUST be WRITEABLE",
4187         "a read-only dc may be returned"
4188 };
4189 static const true_false_string get_dcname_request_flags_good_timeserv_preferred = {
4190         "GOOD TIMESERV servers are PREFERRED",
4191         "we do NOT have a preference for good timeserv servers"
4192 };
4193 static const true_false_string get_dcname_request_flags_avoid_self = {
4194         "do NOT return self as dc, return someone else",
4195         "you may return yourSELF as the dc"
4196 };
4197 static const true_false_string get_dcname_request_flags_only_ldap_needed = {
4198         "we ONLY NEED LDAP, you dont have to return a dc",
4199         "we need a normal dc, an ldap only server will not do"
4200 };
4201 static const true_false_string get_dcname_request_flags_is_flat_name = {
4202         "the name we specify is a NetBIOS name",
4203         "the name we specify is NOT a NetBIOS name"
4204 };
4205 static const true_false_string get_dcname_request_flags_is_dns_name = {
4206         "the name we specify is a DNS name",
4207         "ther name we specify is NOT a dns name"
4208 };
4209 static const true_false_string get_dcname_request_flags_return_dns_name = {
4210         "return a DNS name",
4211         "you may return a NON-dns name"
4212 };
4213 static const true_false_string get_dcname_request_flags_return_flat_name = {
4214         "return a NetBIOS name",
4215         "you may return a NON-NetBIOS name"
4216 };
4217 static int
4218 netlogon_dissect_GET_DCNAME_REQUEST_FLAGS(tvbuff_t *tvb, int offset,
4219         packet_info *pinfo, proto_tree *parent_tree, char *drep)
4220 {
4221         guint32 mask;
4222         proto_item *item = NULL;
4223         proto_tree *tree = NULL;
4224         dcerpc_info *di;
4225
4226         di=pinfo->private_data;
4227         if(di->conformant_run){
4228                 /*just a run to handle conformant arrays, nothing to dissect */
4229                 return offset;
4230         }
4231
4232         offset=dissect_ndr_uint32(tvb, offset, pinfo, NULL, drep,
4233                         hf_netlogon_get_dcname_request_flags, &mask);
4234
4235         if(parent_tree){
4236                 item = proto_tree_add_uint(parent_tree, hf_netlogon_get_dcname_request_flags,
4237                         tvb, offset-4, 4, mask);
4238                 tree = proto_item_add_subtree(item, ett_get_dcname_request_flags);
4239         }
4240
4241         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_return_flat_name,
4242                 tvb, offset-4, 4, mask);
4243         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_return_dns_name,
4244                 tvb, offset-4, 4, mask);
4245         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_is_flat_name,
4246                 tvb, offset-4, 4, mask);
4247         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_is_dns_name,
4248                 tvb, offset-4, 4, mask);
4249         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_only_ldap_needed,
4250                 tvb, offset-4, 4, mask);
4251         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_avoid_self,
4252                 tvb, offset-4, 4, mask);
4253         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_good_timeserv_preferred,
4254                 tvb, offset-4, 4, mask);
4255         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_writable_required,
4256                 tvb, offset-4, 4, mask);
4257         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_timeserv_required,
4258                 tvb, offset-4, 4, mask);
4259         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_kdc_required,
4260                 tvb, offset-4, 4, mask);
4261         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_ip_required,
4262                 tvb, offset-4, 4, mask);
4263         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_background_only,
4264                 tvb, offset-4, 4, mask);
4265         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_pdc_required,
4266                 tvb, offset-4, 4, mask);
4267         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_gc_server_required,
4268                 tvb, offset-4, 4, mask);
4269         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_directory_service_preferred,
4270                 tvb, offset-4, 4, mask);
4271         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_directory_service_required,
4272                 tvb, offset-4, 4, mask);
4273         proto_tree_add_boolean(tree, hf_netlogon_get_dcname_request_flags_force_rediscovery,
4274                 tvb, offset-4, 4, mask);
4275         
4276         return offset;
4277 }
4278
4279
4280
4281 #define DS_PDC_FLAG             0x00000001
4282 #define DS_GC_FLAG              0x00000004
4283 #define DS_LDAP_FLAG            0x00000008
4284 #define DS_DS_FLAG              0x00000010
4285 #define DS_KDC_FLAG             0x00000020
4286 #define DS_TIMESERV_FLAG        0x00000040
4287 #define DS_CLOSEST_FLAG         0x00000080
4288 #define DS_WRITABLE_FLAG        0x00000100
4289 #define DS_GOOD_TIMESERV_FLAG   0x00000200
4290 #define DS_NDNC_FLAG            0x00000400
4291 #define DS_DNS_CONTROLLER_FLAG  0x20000000
4292 #define DS_DNS_DOMAIN_FLAG      0x40000000
4293 #define DS_DNS_FOREST_FLAG      0x80000000
4294 static const true_false_string dc_flags_pdc_flag = {
4295         "this is the PDC of the domain",
4296         "this is NOT the pdc of the domain"
4297 };
4298 static const true_false_string dc_flags_gc_flag = {
4299         "this is the GC of the forest",
4300         "this is NOT the gc of the forest"
4301 };
4302 static const true_false_string dc_flags_ldap_flag = {
4303         "this is an LDAP server",
4304         "this is NOT an ldap server"
4305 };
4306 static const true_false_string dc_flags_ds_flag = {
4307         "this is a DS server",
4308         "this is NOT a ds server"
4309 };
4310 static const true_false_string dc_flags_kdc_flag = {
4311         "this is a KDC server",
4312         "this is NOT a kdc server"
4313 };
4314 static const true_false_string dc_flags_timeserv_flag = {
4315         "this is a TIMESERV server",
4316         "this is NOT a timeserv server"
4317 };
4318 static const true_false_string dc_flags_closest_flag = {
4319         "this is the CLOSEST server",
4320         "this is NOT the closest server"
4321 };
4322 static const true_false_string dc_flags_writable_flag = {
4323         "this server has a WRITABLE ds database",
4324         "this server has a READ-ONLY ds database"
4325 };
4326 static const true_false_string dc_flags_good_timeserv_flag = {
4327         "this server is a GOOD TIMESERV server",
4328         "this is NOT a good timeserv server"
4329 };
4330 static const true_false_string dc_flags_ndnc_flag = {
4331         "NDNC is set",
4332         "ndnc is NOT set"
4333 };
4334 static const true_false_string dc_flags_dns_controller_flag = {
4335         "DomainControllerName is a DNS name",
4336         "DomainControllerName is NOT a dns name"
4337 };
4338 static const true_false_string dc_flags_dns_domain_flag = {
4339         "DomainName is a DNS name",
4340         "DomainName is NOT a dns name"
4341 };
4342 static const true_false_string dc_flags_dns_forest_flag = {
4343         "DnsForestName is a DNS name",
4344         "DnsForestName is NOT a dns name"
4345 };
4346 static int
4347 netlogon_dissect_DC_FLAGS(tvbuff_t *tvb, int offset,
4348         packet_info *pinfo, proto_tree *parent_tree, char *drep)
4349 {
4350         guint32 mask;
4351         proto_item *item = NULL;
4352         proto_tree *tree = NULL;
4353         dcerpc_info *di;
4354
4355         di=pinfo->private_data;
4356         if(di->conformant_run){
4357                 /*just a run to handle conformant arrays, nothing to dissect */
4358                 return offset;
4359         }
4360
4361         offset=dissect_ndr_uint32(tvb, offset, pinfo, NULL, drep,
4362                         hf_netlogon_dc_flags, &mask);
4363
4364         if(parent_tree){
4365                 item = proto_tree_add_uint_format(parent_tree, hf_netlogon_dc_flags,
4366                                 tvb, offset-4, 4, mask, "Domain Controller Flags: 0x%08x%s", mask, (mask==0x0000ffff)?"  PING (mask==0x0000ffff)":"");
4367                 tree = proto_item_add_subtree(item, ett_dc_flags);
4368         }
4369
4370         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_dns_forest_flag,
4371                 tvb, offset-4, 4, mask);
4372         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_dns_domain_flag,
4373                 tvb, offset-4, 4, mask);
4374         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_dns_controller_flag,
4375                 tvb, offset-4, 4, mask);
4376         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_ndnc_flag,
4377                 tvb, offset-4, 4, mask);
4378         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_good_timeserv_flag,
4379                 tvb, offset-4, 4, mask);
4380         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_writable_flag,
4381                 tvb, offset-4, 4, mask);
4382         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_closest_flag,
4383                 tvb, offset-4, 4, mask);
4384         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_timeserv_flag,
4385                 tvb, offset-4, 4, mask);
4386         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_kdc_flag,
4387                 tvb, offset-4, 4, mask);
4388         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_ds_flag,
4389                 tvb, offset-4, 4, mask);
4390         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_ldap_flag,
4391                 tvb, offset-4, 4, mask);
4392         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_gc_flag,
4393                 tvb, offset-4, 4, mask);
4394         proto_tree_add_boolean(tree, hf_netlogon_dc_flags_pdc_flag,
4395                 tvb, offset-4, 4, mask);
4396
4397         return offset;
4398 }
4399
4400
4401
4402 static int
4403 netlogon_dissect_pointer_long(tvbuff_t *tvb, int offset,
4404                              packet_info *pinfo, proto_tree *tree,
4405                              char *drep)
4406 {
4407         dcerpc_info *di;
4408
4409         di=pinfo->private_data;
4410         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
4411                                      di->hf_index, NULL);
4412         return offset;
4413 }
4414
4415 static int
4416 netlogon_dissect_pointer_char(tvbuff_t *tvb, int offset,
4417                              packet_info *pinfo, proto_tree *tree,
4418                              char *drep)
4419 {
4420         dcerpc_info *di;
4421
4422         di=pinfo->private_data;
4423         offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
4424                                      di->hf_index, NULL);
4425         return offset;
4426 }
4427
4428 static int
4429 netlogon_dissect_UNICODE_MULTI_byte(tvbuff_t *tvb, int offset,
4430                         packet_info *pinfo, proto_tree *tree,
4431                         char *drep)
4432 {
4433                 offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
4434                         hf_netlogon_unknown_char, NULL);
4435
4436         return offset;
4437 }
4438
4439 static int
4440 netlogon_dissect_UNICODE_MULTI_array(tvbuff_t *tvb, int offset,
4441                         packet_info *pinfo, proto_tree *tree,
4442                         char *drep)
4443 {
4444         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
4445                 netlogon_dissect_UNICODE_MULTI_byte);
4446
4447         return offset;
4448 }
4449
4450 static int
4451 netlogon_dissect_UNICODE_MULTI(tvbuff_t *tvb, int offset,
4452                         packet_info *pinfo, proto_tree *parent_tree,
4453                         char *drep)
4454 {
4455         proto_item *item=NULL;
4456         proto_tree *tree=NULL;
4457         int old_offset=offset;
4458
4459         if(parent_tree){
4460                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4461                         "UNICODE_MULTI:");
4462                 tree = proto_item_add_subtree(item, ett_UNICODE_MULTI);
4463         }
4464
4465         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4466                 hf_netlogon_len, NULL);
4467
4468         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4469                 netlogon_dissect_UNICODE_MULTI_array, NDR_POINTER_UNIQUE,
4470                 "unknown", hf_netlogon_unknown_string);
4471
4472         proto_item_set_len(item, offset-old_offset);
4473         return offset;
4474 }
4475
4476 int
4477 dissect_nt_GUID(tvbuff_t *tvb, int offset,
4478                         packet_info *pinfo, proto_tree *tree,
4479                         char *drep)
4480 {
4481         offset=dissect_ndr_uuid_t(tvb, offset, pinfo, tree, drep, hf_netlogon_guid, NULL);
4482
4483         return offset;
4484 }
4485
4486 static int
4487 netlogon_dissect_DOMAIN_CONTROLLER_INFO(tvbuff_t *tvb, int offset,
4488                         packet_info *pinfo, proto_tree *parent_tree,
4489                         char *drep)
4490 {
4491         proto_item *item=NULL;
4492         proto_tree *tree=NULL;
4493         int old_offset=offset;
4494
4495         if(parent_tree){
4496                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4497                         "DOMAIN_CONTROLLER_INFO:");
4498                 tree = proto_item_add_subtree(item, ett_DOMAIN_CONTROLLER_INFO);
4499         }
4500
4501         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4502                 NDR_POINTER_UNIQUE, "DC Name", hf_netlogon_dc_name, 0);
4503
4504         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4505                 NDR_POINTER_UNIQUE, "DC Address", hf_netlogon_dc_address, 0);
4506
4507         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4508                 hf_netlogon_dc_address_type, NULL);
4509
4510         offset = dissect_nt_GUID(tvb, offset,
4511                 pinfo, tree, drep);
4512
4513         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4514                 NDR_POINTER_UNIQUE, "Logon Domain", hf_netlogon_logon_dom, 0);
4515
4516         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4517                 NDR_POINTER_UNIQUE, "DNS Forest", hf_netlogon_dns_forest_name, 0);
4518
4519         offset = netlogon_dissect_DC_FLAGS(tvb, offset, pinfo, tree, drep);
4520
4521         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4522                 NDR_POINTER_UNIQUE, "DC Site", hf_netlogon_dc_site_name, 0);
4523
4524         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4525                 NDR_POINTER_UNIQUE, "Client Site", 
4526                 hf_netlogon_client_site_name, 0);
4527
4528         proto_item_set_len(item, offset-old_offset);
4529         return offset;
4530 }
4531
4532 static int
4533 netlogon_dissect_BLOB_array(tvbuff_t *tvb, int offset,
4534                         packet_info *pinfo, proto_tree *tree,
4535                         char *drep)
4536 {
4537         guint32 len;
4538         dcerpc_info *di;
4539
4540         di=pinfo->private_data;
4541         if(di->conformant_run){
4542                 /*just a run to handle conformant arrays, nothing to dissect.*/
4543                 return offset;
4544         }
4545
4546         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4547                 hf_netlogon_blob_size, &len);
4548
4549         proto_tree_add_item(tree, hf_netlogon_blob, tvb, offset, len,
4550                 FALSE);
4551         offset += len;
4552
4553         return offset;
4554 }
4555
4556 static int
4557 netlogon_dissect_BLOB(tvbuff_t *tvb, int offset,
4558                         packet_info *pinfo, proto_tree *parent_tree,
4559                         char *drep)
4560 {
4561         proto_item *item=NULL;
4562         proto_tree *tree=NULL;
4563
4564         if(parent_tree){
4565                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4566                         "BLOB:");
4567                 tree = proto_item_add_subtree(item, ett_BLOB);
4568         }
4569
4570         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4571                 hf_netlogon_blob_size, NULL);
4572
4573         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4574                 netlogon_dissect_BLOB_array, NDR_POINTER_UNIQUE,
4575                 "BLOB:", -1);
4576
4577         return offset;
4578 }
4579
4580 static int
4581 netlogon_dissect_DOMAIN_TRUST_INFO(tvbuff_t *tvb, int offset,
4582                         packet_info *pinfo, proto_tree *parent_tree,
4583                         char *drep)
4584 {
4585         proto_item *item=NULL;
4586         proto_tree *tree=NULL;
4587         int old_offset=offset;
4588
4589         if(parent_tree){
4590                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4591                         "DOMAIN_TRUST_INFO:");
4592                 tree = proto_item_add_subtree(item, ett_DOMAIN_TRUST_INFO);
4593         }
4594
4595
4596         offset = lsa_dissect_POLICY_DNS_DOMAIN_INFO(tvb, offset, pinfo, tree, drep);
4597
4598         /* Guesses at best. */
4599         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4600                 hf_netlogon_unknown_string, 0);
4601
4602         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4603                 hf_netlogon_unknown_string, 0);
4604
4605         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4606                 hf_netlogon_unknown_string, 0);
4607
4608         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4609                 hf_netlogon_unknown_string, 0);
4610
4611         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4612                 hf_netlogon_unknown_long, NULL);
4613
4614         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4615                 hf_netlogon_unknown_long, NULL);
4616
4617         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4618                 hf_netlogon_unknown_long, NULL);
4619
4620         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4621                 hf_netlogon_unknown_long, NULL);
4622
4623         proto_item_set_len(item, offset-old_offset);
4624         return offset;
4625 }
4626
4627 static int
4628 netlogon_dissect_DOMAIN_TRUST_INFO_ARRAY(tvbuff_t *tvb, int offset,
4629                         packet_info *pinfo, proto_tree *tree,
4630                         char *drep)
4631 {
4632         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
4633                 netlogon_dissect_DOMAIN_TRUST_INFO);
4634
4635         return offset;
4636 }
4637
4638 static int
4639 netlogon_dissect_DOMAIN_QUERY_1(tvbuff_t *tvb, int offset,
4640                         packet_info *pinfo, proto_tree *tree,
4641                         char *drep)
4642 {
4643         offset = netlogon_dissect_BLOB(tvb, offset,
4644                 pinfo, tree, drep);
4645
4646         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4647                 NDR_POINTER_UNIQUE, "Workstation FQDN", 
4648                 hf_netlogon_workstation_fqdn, 0);
4649
4650         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4651                 NDR_POINTER_UNIQUE, "Workstation Site", 
4652                 hf_netlogon_workstation_site_name, 0);
4653
4654         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4655                 NDR_POINTER_UNIQUE, "unknown", hf_netlogon_unknown_string, 0);
4656
4657         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4658                 NDR_POINTER_UNIQUE, "unknown", hf_netlogon_unknown_string, 0);
4659
4660         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4661                 NDR_POINTER_UNIQUE, "unknown", hf_netlogon_unknown_string, 0);
4662
4663         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4664                 NDR_POINTER_UNIQUE, "unknown", hf_netlogon_unknown_string, 0);
4665
4666         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4667                 hf_netlogon_unknown_string, 0);
4668
4669         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4670                 hf_netlogon_workstation_os, 0);
4671
4672         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4673                 hf_netlogon_unknown_string, 0);
4674
4675         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4676                 hf_netlogon_unknown_string, 0);
4677
4678         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4679                 hf_netlogon_unknown_long, NULL);
4680
4681         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4682                 hf_netlogon_unknown_long, NULL);
4683
4684         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4685                 hf_netlogon_unknown_long, NULL);
4686
4687         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4688                 hf_netlogon_unknown_long, NULL);
4689
4690         return offset;
4691 }
4692
4693 static int
4694 netlogon_dissect_DOMAIN_INFO_1(tvbuff_t *tvb, int offset,
4695                         packet_info *pinfo, proto_tree *tree,
4696                         char *drep)
4697 {
4698         offset = netlogon_dissect_DOMAIN_TRUST_INFO(tvb, offset, pinfo, tree, drep);
4699
4700         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4701                 hf_netlogon_num_trusts, NULL);
4702
4703         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4704                 netlogon_dissect_DOMAIN_TRUST_INFO_ARRAY, NDR_POINTER_UNIQUE,
4705                 "DOMAIN_TRUST_ARRAY: Trusts", -1);
4706
4707         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4708                 hf_netlogon_num_trusts, NULL);
4709
4710         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4711                 netlogon_dissect_DOMAIN_TRUST_INFO_ARRAY, NDR_POINTER_UNIQUE,
4712                 "DOMAIN_TRUST_ARRAY:", -1);
4713  
4714         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4715                 hf_netlogon_dns_domain_name, 0);
4716
4717         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4718                 hf_netlogon_unknown_string, 0);
4719
4720         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4721                 hf_netlogon_unknown_string, 0);
4722
4723         offset = dissect_ndr_counted_string(tvb, offset, pinfo, tree, drep,
4724                 hf_netlogon_unknown_string, 0);
4725
4726         /* These four integers appear to mirror the last four in the query. */
4727         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4728                 hf_netlogon_unknown_long, NULL);
4729
4730         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4731                 hf_netlogon_unknown_long, NULL);
4732
4733         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4734                 hf_netlogon_unknown_long, NULL);
4735
4736         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4737                 hf_netlogon_unknown_long, NULL);
4738
4739         return offset;
4740 }
4741
4742
4743 static int
4744 netlogon_dissect_DOMAIN_INFO(tvbuff_t *tvb, int offset,
4745                         packet_info *pinfo, proto_tree *tree,
4746                         char *drep)
4747 {
4748         guint32 level;
4749
4750         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4751                 hf_netlogon_level, &level);
4752
4753         ALIGN_TO_4_BYTES;
4754         switch(level){
4755         case 1:
4756                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4757                         netlogon_dissect_DOMAIN_INFO_1, NDR_POINTER_UNIQUE,
4758                         "DOMAIN_INFO_1:", -1);
4759                 break;
4760         }
4761
4762         return offset;
4763 }
4764
4765 static int
4766 netlogon_dissect_UNICODE_STRING_512(tvbuff_t *tvb, int offset,
4767                         packet_info *pinfo, proto_tree *parent_tree,
4768                         char *drep)
4769 {
4770         proto_item *item=NULL;
4771         proto_tree *tree=NULL;
4772         int old_offset=offset;
4773         int i;
4774
4775         if(parent_tree){
4776                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4777                         "UNICODE_STRING_512:");
4778                 tree = proto_item_add_subtree(item, ett_UNICODE_STRING_512);
4779         }
4780
4781         for(i=0;i<512;i++){
4782                 offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
4783                         hf_netlogon_unknown_short, NULL);
4784         }
4785
4786         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4787                 hf_netlogon_unknown_long, NULL);
4788
4789         proto_item_set_len(item, offset-old_offset);
4790         return offset;
4791 }
4792
4793 static int
4794 netlogon_dissect_element_844_byte(tvbuff_t *tvb, int offset,
4795                         packet_info *pinfo, proto_tree *tree,
4796                         char *drep)
4797 {
4798                 offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
4799                         hf_netlogon_unknown_char, NULL);
4800
4801         return offset;
4802 }
4803
4804 static int
4805 netlogon_dissect_element_844_array(tvbuff_t *tvb, int offset,
4806                         packet_info *pinfo, proto_tree *tree,
4807                         char *drep)
4808 {
4809         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
4810                 netlogon_dissect_element_844_byte);
4811
4812         return offset;
4813 }
4814
4815 static int
4816 netlogon_dissect_TYPE_50(tvbuff_t *tvb, int offset,
4817                         packet_info *pinfo, proto_tree *parent_tree,
4818                         char *drep)
4819 {
4820         proto_item *item=NULL;
4821         proto_tree *tree=NULL;
4822         int old_offset=offset;
4823
4824         if(parent_tree){
4825                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4826                         "TYPE_50:");
4827                 tree = proto_item_add_subtree(item, ett_TYPE_50);
4828         }
4829
4830         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4831                 hf_netlogon_unknown_long, NULL);
4832
4833         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4834                 netlogon_dissect_element_844_array, NDR_POINTER_UNIQUE,
4835                 "unknown", hf_netlogon_unknown_string);
4836
4837         proto_item_set_len(item, offset-old_offset);
4838         return offset;
4839 }
4840
4841 static int
4842 netlogon_dissect_TYPE_50_ptr(tvbuff_t *tvb, int offset,
4843                         packet_info *pinfo, proto_tree *tree,
4844                         char *drep)
4845 {
4846         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4847                 netlogon_dissect_TYPE_50, NDR_POINTER_UNIQUE,
4848                 "TYPE_50 pointer: unknown_TYPE_50", -1);
4849
4850         return offset;
4851 }
4852
4853 static int
4854 netlogon_dissect_DS_DOMAIN_TRUSTS(tvbuff_t *tvb, int offset,
4855         packet_info *pinfo, proto_tree *parent_tree, char *drep)
4856 {
4857         guint32 tmp;
4858         proto_item *item=NULL;
4859         proto_tree *tree=NULL;
4860         int old_offset=offset;
4861
4862         if(parent_tree){
4863                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4864                         "DS_DOMAIN_TRUSTS");
4865                 tree = proto_item_add_subtree(item, ett_DS_DOMAIN_TRUSTS);
4866         }
4867
4868         /* name */
4869         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4870                 NDR_POINTER_UNIQUE, "NetBIOS Name", 
4871                 hf_netlogon_downlevel_domain_name, 0);
4872
4873         /* domain */
4874         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
4875                 NDR_POINTER_UNIQUE, "DNS Domain Name", 
4876                 hf_netlogon_dns_domain_name, 0);
4877
4878         offset = netlogon_dissect_DOMAIN_TRUST_FLAGS(tvb, offset, pinfo, tree, drep);
4879
4880         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4881                 hf_netlogon_trust_parent_index, &tmp);
4882
4883         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4884                 hf_netlogon_trust_type, &tmp);
4885
4886         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4887                 hf_netlogon_trust_attribs, &tmp);
4888
4889         /* SID pointer */
4890         offset = dissect_ndr_nt_PSID(tvb, offset, pinfo, tree, drep, -1);
4891
4892         /* GUID */
4893         offset = dissect_nt_GUID(tvb, offset, pinfo, tree, drep);
4894
4895         proto_item_set_len(item, offset-old_offset);
4896         return offset;
4897 }
4898
4899 static int
4900 netlogon_dissect_DS_DOMAIN_TRUSTS_ARRAY(tvbuff_t *tvb, int offset,
4901                         packet_info *pinfo, proto_tree *tree,
4902                         char *drep)
4903 {
4904         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
4905                 netlogon_dissect_DS_DOMAIN_TRUSTS);
4906
4907         return offset;
4908 }
4909
4910 static int
4911 netlogon_dissect_element_865_byte(tvbuff_t *tvb, int offset,
4912                         packet_info *pinfo, proto_tree *tree,
4913                         char *drep)
4914 {
4915                 offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
4916                         hf_netlogon_unknown_char, NULL);
4917
4918         return offset;
4919 }
4920
4921 static int
4922 netlogon_dissect_element_865_array(tvbuff_t *tvb, int offset,
4923                         packet_info *pinfo, proto_tree *tree,
4924                         char *drep)
4925 {
4926         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
4927                 netlogon_dissect_element_865_byte);
4928
4929         return offset;
4930 }
4931
4932 static int
4933 netlogon_dissect_element_866_byte(tvbuff_t *tvb, int offset,
4934                         packet_info *pinfo, proto_tree *tree,
4935                         char *drep)
4936 {
4937                 offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
4938                         hf_netlogon_unknown_char, NULL);
4939
4940         return offset;
4941 }
4942
4943 static int
4944 netlogon_dissect_element_866_array(tvbuff_t *tvb, int offset,
4945                         packet_info *pinfo, proto_tree *tree,
4946                         char *drep)
4947 {
4948         offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
4949                 netlogon_dissect_element_866_byte);
4950
4951         return offset;
4952 }
4953
4954 static int
4955 netlogon_dissect_TYPE_52(tvbuff_t *tvb, int offset,
4956                         packet_info *pinfo, proto_tree *parent_tree,
4957                         char *drep)
4958 {
4959         proto_item *item=NULL;
4960         proto_tree *tree=NULL;
4961         int old_offset=offset;
4962
4963         if(parent_tree){
4964                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
4965                         "TYPE_52:");
4966                 tree = proto_item_add_subtree(item, ett_TYPE_52);
4967         }
4968
4969         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
4970                 hf_netlogon_unknown_long, NULL);
4971
4972         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4973                 netlogon_dissect_element_865_array, NDR_POINTER_UNIQUE,
4974                 "unknown", hf_netlogon_unknown_string);
4975
4976         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4977                 netlogon_dissect_element_866_array, NDR_POINTER_UNIQUE,
4978                 "unknown", hf_netlogon_unknown_string);
4979
4980         proto_item_set_len(item, offset-old_offset);
4981         return offset;
4982 }
4983
4984 static int
4985 netlogon_dissect_TYPE_52_ptr(tvbuff_t *tvb, int offset,
4986                         packet_info *pinfo, proto_tree *tree,
4987                         char *drep)
4988 {
4989         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
4990                 netlogon_dissect_TYPE_52, NDR_POINTER_UNIQUE,
4991                 "TYPE_52 pointer: unknown_TYPE_52", -1);
4992         return offset;
4993 }
4994
4995
4996 static int
4997 netlogon_dissect_TYPE_44(tvbuff_t *tvb, int offset,
4998                         packet_info *pinfo, proto_tree *parent_tree,
4999                         char *drep)
5000 {
5001         proto_item *item=NULL;
5002         proto_tree *tree=NULL;
5003         int old_offset=offset;
5004         guint32 level;
5005
5006         if(parent_tree){
5007                 item = proto_tree_add_text(parent_tree, tvb, offset, 0,
5008                         "TYPE_44:");
5009                 tree = proto_item_add_subtree(item, ett_TYPE_44);
5010         }
5011
5012         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5013                 hf_netlogon_level, &level);
5014
5015         ALIGN_TO_4_BYTES;
5016         switch(level){
5017         case 1:
5018                 offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5019                         hf_netlogon_unknown_long, NULL);
5020                 break;
5021         }
5022
5023         proto_item_set_len(item, offset-old_offset);
5024         return offset;
5025 }
5026
5027 static int
5028 netlogon_dissect_DOMAIN_QUERY(tvbuff_t *tvb, int offset,
5029                         packet_info *pinfo, proto_tree *tree,
5030                         char *drep)
5031 {
5032         guint32 level;
5033
5034         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5035                 hf_netlogon_level, &level);
5036
5037         ALIGN_TO_4_BYTES;
5038         switch(level){
5039         case 1:
5040                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5041                         netlogon_dissect_DOMAIN_QUERY_1, NDR_POINTER_UNIQUE,
5042                         "DOMAIN_QUERY_1:", -1);
5043                 break;
5044         case 2:
5045                 offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5046                         netlogon_dissect_DOMAIN_QUERY_1, NDR_POINTER_UNIQUE,
5047                         "DOMAIN_QUERY_1:", -1);
5048                 break;
5049         }
5050
5051         return offset;
5052 }
5053
5054 static int
5055 netlogon_dissect_nettrusteddomainlist_rqst(tvbuff_t *tvb, int offset,
5056         packet_info *pinfo, proto_tree *tree, char *drep)
5057 {
5058         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5059                 pinfo, tree, drep);
5060
5061         return offset;
5062 }
5063
5064
5065 static int
5066 netlogon_dissect_nettrusteddomainlist_reply(tvbuff_t *tvb, int offset,
5067         packet_info *pinfo, proto_tree *tree, char *drep)
5068 {
5069         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5070                 netlogon_dissect_UNICODE_MULTI, NDR_POINTER_REF,
5071                 "UNICODE_MULTI pointer: trust_dom_name_list", -1);
5072
5073         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5074                                   hf_netlogon_rc, NULL);
5075
5076         return offset;
5077 }
5078
5079 static int
5080 netlogon_dissect_dsrgetdcname2_rqst(tvbuff_t *tvb, int offset,
5081         packet_info *pinfo, proto_tree *tree, char *drep)
5082 {
5083         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5084                 pinfo, tree, drep);
5085
5086         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5087                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_logon_dom, 0);
5088
5089         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5090                 dissect_nt_GUID, NDR_POINTER_UNIQUE,
5091                 "GUID pointer: domain_guid", -1);
5092
5093         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5094                 dissect_nt_GUID, NDR_POINTER_UNIQUE,
5095                 "GUID pointer: site_guid", -1);
5096
5097         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5098                 hf_netlogon_flags, NULL);
5099
5100         return offset;
5101 }
5102
5103
5104 static int
5105 netlogon_dissect_dsrgetdcname2_reply(tvbuff_t *tvb, int offset,
5106         packet_info *pinfo, proto_tree *tree, char *drep)
5107 {
5108         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5109                 netlogon_dissect_DOMAIN_CONTROLLER_INFO, NDR_POINTER_UNIQUE,
5110                 "DOMAIN_CONTROLLER_INFO:", -1);
5111
5112         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5113                                   hf_netlogon_rc, NULL);
5114
5115         return offset;
5116 }
5117
5118 static int
5119 netlogon_dissect_function_15_rqst(tvbuff_t *tvb, int offset,
5120         packet_info *pinfo, proto_tree *tree, char *drep)
5121 {
5122         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5123                 pinfo, tree, drep);
5124
5125         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5126                 NDR_POINTER_UNIQUE, "unknown string", 
5127                 hf_netlogon_unknown_string, 0);
5128
5129         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5130                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5131                 "AUTHENTICATOR: credential", -1);
5132
5133         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5134                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
5135                 "AUTHENTICATOR: return_authenticator", -1);
5136
5137         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5138                 hf_netlogon_unknown_long, NULL);
5139
5140         return offset;
5141 }
5142
5143
5144 static int
5145 netlogon_dissect_function_15_reply(tvbuff_t *tvb, int offset,
5146         packet_info *pinfo, proto_tree *tree, char *drep)
5147 {
5148         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5149                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
5150                 "AUTHENTICATOR: return_authenticator", -1);
5151
5152         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5153                 netlogon_dissect_TYPE_44, NDR_POINTER_UNIQUE,
5154                 "TYPE_44 pointer: unknown_TYPE_44", -1);
5155
5156         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5157                                   hf_netlogon_rc, NULL);
5158
5159         return offset;
5160 }
5161
5162 static int
5163 netlogon_dissect_function_16_rqst(tvbuff_t *tvb, int offset,
5164         packet_info *pinfo, proto_tree *tree, char *drep)
5165 {
5166         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5167                 pinfo, tree, drep);
5168
5169         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5170                 hf_netlogon_unknown_long, NULL);
5171
5172         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5173                 hf_netlogon_unknown_long, NULL);
5174
5175         return offset;
5176 }
5177
5178
5179 static int
5180 netlogon_dissect_function_16_reply(tvbuff_t *tvb, int offset,
5181         packet_info *pinfo, proto_tree *tree, char *drep)
5182 {
5183         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5184                                   hf_netlogon_rc, NULL);
5185
5186         return offset;
5187 }
5188
5189 static int
5190 netlogon_dissect_function_17_rqst(tvbuff_t *tvb, int offset,
5191         packet_info *pinfo, proto_tree *tree, char *drep)
5192 {
5193         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5194                 pinfo, tree, drep);
5195
5196         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5197                 NDR_POINTER_UNIQUE, "unknown string", 
5198                 hf_netlogon_unknown_string, 0);
5199
5200         return offset;
5201 }
5202
5203
5204 static int
5205 netlogon_dissect_function_17_reply(tvbuff_t *tvb, int offset,
5206         packet_info *pinfo, proto_tree *tree, char *drep)
5207 {
5208         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5209                 netlogon_dissect_pointer_long, NDR_POINTER_UNIQUE,
5210                 "ULONG pointer: unknown_ULONG", hf_netlogon_unknown_long);
5211
5212         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5213                                   hf_netlogon_rc, NULL);
5214
5215         return offset;
5216 }
5217
5218 static int
5219 netlogon_dissect_function_18_rqst(tvbuff_t *tvb, int offset,
5220         packet_info *pinfo, proto_tree *tree, char *drep)
5221 {
5222         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5223                 pinfo, tree, drep);
5224
5225         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5226                 hf_netlogon_unknown_long, NULL);
5227
5228         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5229                 netlogon_dissect_BYTE_array, NDR_POINTER_UNIQUE,
5230                 "BYTE pointer: unknown_BYTE", -1);
5231
5232         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5233                 hf_netlogon_unknown_long, NULL);
5234
5235         return offset;
5236 }
5237
5238 static int
5239 netlogon_dissect_BYTE_16_array(tvbuff_t *tvb, int offset,
5240         packet_info *pinfo, proto_tree *tree, char *drep)
5241 {
5242         int i;
5243
5244         for(i=0;i<16;i++){
5245                 offset = dissect_ndr_uint8(tvb, offset, pinfo, tree, drep,
5246                         hf_netlogon_unknown_char, NULL);
5247         }
5248
5249         return offset;
5250 }
5251
5252 static int
5253 netlogon_dissect_function_18_reply(tvbuff_t *tvb, int offset,
5254         packet_info *pinfo, proto_tree *tree, char *drep)
5255 {
5256         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5257                 netlogon_dissect_BYTE_16_array, NDR_POINTER_UNIQUE,
5258                 "BYTE pointer: unknown_BYTE", -1);
5259
5260         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5261                                   hf_netlogon_rc, NULL);
5262
5263         return offset;
5264 }
5265
5266 static int
5267 netlogon_dissect_function_19_rqst(tvbuff_t *tvb, int offset,
5268         packet_info *pinfo, proto_tree *tree, char *drep)
5269 {
5270         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5271                 pinfo, tree, drep);
5272
5273         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5274                 NDR_POINTER_UNIQUE, "unknown string", 
5275                 hf_netlogon_unknown_string, 0);
5276
5277         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5278                 netlogon_dissect_BYTE_array, NDR_POINTER_UNIQUE,
5279                 "BYTE pointer: unknown_BYTE", -1);
5280
5281         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5282                 hf_netlogon_unknown_long, NULL);
5283
5284         return offset;
5285 }
5286
5287
5288 static int
5289 netlogon_dissect_function_19_reply(tvbuff_t *tvb, int offset,
5290         packet_info *pinfo, proto_tree *tree, char *drep)
5291 {
5292         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5293                 netlogon_dissect_BYTE_16_array, NDR_POINTER_UNIQUE,
5294                 "BYTE pointer: unknown_BYTE", -1);
5295
5296         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5297                                   hf_netlogon_rc, NULL);
5298
5299         return offset;
5300 }
5301
5302 static int
5303 netlogon_dissect_netserverauthenticate3_rqst(tvbuff_t *tvb, int offset,
5304         packet_info *pinfo, proto_tree *tree, char *drep)
5305 {
5306         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5307                 pinfo, tree, drep);
5308
5309         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5310                 NDR_POINTER_REF, "Acct Name", hf_netlogon_acct_name, 0);
5311
5312         offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
5313                 pinfo, tree, drep);
5314
5315         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5316                 NDR_POINTER_REF, "Computer Name", hf_netlogon_computer_name, 0);
5317
5318         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5319                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
5320                 "CREDENTIAL: authenticator", -1);
5321
5322         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5323                 hf_netlogon_neg_flags, NULL);
5324
5325         return offset;
5326 }
5327
5328
5329 static int
5330 netlogon_dissect_netserverauthenticate3_reply(tvbuff_t *tvb, int offset,
5331         packet_info *pinfo, proto_tree *tree, char *drep)
5332 {
5333         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5334                 netlogon_dissect_CREDENTIAL, NDR_POINTER_REF,
5335                 "CREDENTIAL pointer: unknown_NETLOGON_CREDENTIAL", -1);
5336
5337         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5338                 hf_netlogon_neg_flags, NULL);
5339
5340         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5341                 netlogon_dissect_pointer_long, NDR_POINTER_REF,
5342                 "ULONG: unknown_ULONG", hf_netlogon_unknown_long);
5343
5344         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5345                                   hf_netlogon_rc, NULL);
5346
5347         return offset;
5348 }
5349
5350 static int
5351 netlogon_dissect_dsrgetdcname_rqst(tvbuff_t *tvb, int offset,
5352         packet_info *pinfo, proto_tree *tree, char *drep)
5353 {
5354         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5355                 pinfo, tree, drep);
5356
5357         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5358                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_logon_dom, 0);
5359
5360         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5361                 dissect_nt_GUID, NDR_POINTER_UNIQUE,
5362                 "GUID pointer: domain_guid", -1);
5363
5364         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5365                 NDR_POINTER_UNIQUE, "Site Name", hf_netlogon_site_name, 0);
5366
5367         offset = netlogon_dissect_GET_DCNAME_REQUEST_FLAGS(tvb, offset, pinfo, tree, drep);
5368
5369         return offset;
5370 }
5371
5372
5373 static int
5374 netlogon_dissect_dsrgetdcname_reply(tvbuff_t *tvb, int offset,
5375         packet_info *pinfo, proto_tree *tree, char *drep)
5376 {
5377         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5378                 netlogon_dissect_DOMAIN_CONTROLLER_INFO, NDR_POINTER_UNIQUE,
5379                 "DOMAIN_CONTROLLER_INFO:", -1);
5380
5381         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5382                                   hf_netlogon_rc, NULL);
5383
5384         return offset;
5385 }
5386
5387 static int
5388 netlogon_dissect_dsrgetsitename_rqst(tvbuff_t *tvb, int offset,
5389         packet_info *pinfo, proto_tree *tree, char *drep)
5390 {
5391         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5392                 pinfo, tree, drep);
5393
5394         return offset;
5395 }
5396
5397
5398 static int
5399 netlogon_dissect_dsrgetsitename_reply(tvbuff_t *tvb, int offset,
5400         packet_info *pinfo, proto_tree *tree, char *drep)
5401 {
5402
5403         /* XXX hmmm this does not really look like a UNIQUE pointer but
5404            will do for now.   I think it is really a 32bit integer followed by
5405            a REF pointer to a unicode string */
5406         offset = dissect_ndr_pointer_cb(tvb, offset, pinfo, tree, drep,
5407                 dissect_ndr_wchar_cvstring, NDR_POINTER_UNIQUE, "Site Name", 
5408                 hf_netlogon_site_name, cb_wstr_postprocess, 
5409                 GINT_TO_POINTER(CB_STR_COL_INFO | 1));
5410
5411         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5412                                   hf_netlogon_rc, NULL);
5413
5414         return offset;
5415 }
5416
5417 static int
5418 netlogon_dissect_netrlogongetdomaininfo_rqst(tvbuff_t *tvb, int offset,
5419         packet_info *pinfo, proto_tree *tree, char *drep)
5420 {
5421        /* Unlike the other NETLOGON RPCs, this is not a unique pointer. */
5422        offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5423                NDR_POINTER_REF, "Server Handle", hf_netlogon_computer_name, 0);
5424
5425         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5426                 NDR_POINTER_UNIQUE, "Computer Name", 
5427                 hf_netlogon_computer_name, 0);
5428
5429         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5430                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5431                 "AUTHENTICATOR: credential", -1);
5432
5433         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5434                 hf_netlogon_unknown_long, NULL);
5435
5436         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5437                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5438                 "AUTHENTICATOR: return_authenticator", -1);
5439
5440         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5441                 netlogon_dissect_DOMAIN_QUERY, NDR_POINTER_REF,
5442                 "DOMAIN_QUERY: ", -1);
5443
5444         return offset;
5445 }
5446
5447
5448 static int
5449 netlogon_dissect_netrlogongetdomaininfo_reply(tvbuff_t *tvb, int offset,
5450         packet_info *pinfo, proto_tree *tree, char *drep)
5451 {
5452         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5453                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5454                 "AUTHENTICATOR: return_authenticator", -1);
5455
5456         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5457                 netlogon_dissect_DOMAIN_INFO, NDR_POINTER_REF,
5458                 "DOMAIN_INFO: ", -1);
5459
5460         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5461                                   hf_netlogon_rc, NULL);
5462
5463         return offset;
5464 }
5465
5466 static int
5467 netlogon_dissect_function_1e_rqst(tvbuff_t *tvb, int offset,
5468         packet_info *pinfo, proto_tree *tree, char *drep)
5469 {
5470         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5471                 pinfo, tree, drep);
5472
5473         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5474                 NDR_POINTER_UNIQUE, "unknown string", 
5475                 hf_netlogon_unknown_string, 0);
5476
5477         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
5478                 hf_netlogon_unknown_short, NULL);
5479
5480         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5481                 NDR_POINTER_UNIQUE, "unknown string", 
5482                 hf_netlogon_unknown_string, 0);
5483
5484         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5485                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5486                 "AUTHENTICATOR: credential", -1);
5487
5488         offset = netlogon_dissect_UNICODE_STRING_512(tvb, offset,
5489                 pinfo, tree, drep);
5490
5491         return offset;
5492 }
5493
5494
5495 static int
5496 netlogon_dissect_function_1e_reply(tvbuff_t *tvb, int offset,
5497         packet_info *pinfo, proto_tree *tree, char *drep)
5498 {
5499         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5500                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
5501                 "AUTHENTICATOR: return_authenticator", -1);
5502
5503         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5504                                   hf_netlogon_rc, NULL);
5505
5506         return offset;
5507 }
5508
5509 static int
5510 netlogon_dissect_netserverpasswordset2_rqst(tvbuff_t *tvb, int offset,
5511         packet_info *pinfo, proto_tree *tree, char *drep)
5512 {
5513         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5514                 pinfo, tree, drep);
5515
5516         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5517                 NDR_POINTER_UNIQUE, "Acct Name", hf_netlogon_acct_name, 0);
5518
5519         offset = netlogon_dissect_NETLOGON_SECURE_CHANNEL_TYPE(tvb, offset,
5520                 pinfo, tree, drep);
5521
5522         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5523                 NDR_POINTER_UNIQUE, "Computer Name", 
5524                 hf_netlogon_computer_name, 0);
5525
5526         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5527                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5528                 "AUTHENTICATOR: credential", -1);
5529
5530         return offset;
5531 }
5532
5533
5534 static int
5535 netlogon_dissect_netserverpasswordset2_reply(tvbuff_t *tvb, int offset,
5536         packet_info *pinfo, proto_tree *tree, char *drep)
5537 {
5538         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5539                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5540                 "AUTHENTICATOR: return_authenticator", -1);
5541
5542         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5543                 netlogon_dissect_LM_OWF_PASSWORD, NDR_POINTER_REF,
5544                 "LM_OWF_PASSWORD pointer: server_pwd", -1);
5545
5546         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5547                                   hf_netlogon_rc, NULL);
5548
5549         return offset;
5550 }
5551
5552 static int
5553 netlogon_dissect_function_20_rqst(tvbuff_t *tvb, int offset,
5554         packet_info *pinfo, proto_tree *tree, char *drep)
5555 {
5556         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5557                 pinfo, tree, drep);
5558
5559         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5560                 NDR_POINTER_UNIQUE, "unknown string", 
5561                 hf_netlogon_unknown_string, 0);
5562
5563         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5564                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_REF,
5565                 "AUTHENTICATOR: credential", -1);
5566
5567         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5568                 netlogon_dissect_BYTE_array, NDR_POINTER_UNIQUE,
5569                 "BYTE pointer: unknown_BYTE", -1);
5570
5571         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5572                 hf_netlogon_unknown_long, NULL);
5573
5574         return offset;
5575 }
5576
5577
5578 static int
5579 netlogon_dissect_function_20_reply(tvbuff_t *tvb, int offset,
5580         packet_info *pinfo, proto_tree *tree, char *drep)
5581 {
5582         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5583                 netlogon_dissect_AUTHENTICATOR, NDR_POINTER_UNIQUE,
5584                 "AUTHENTICATOR: return_authenticator", -1);
5585
5586         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5587                                   hf_netlogon_rc, NULL);
5588
5589         return offset;
5590 }
5591
5592 static int
5593 netlogon_dissect_function_21_rqst(tvbuff_t *tvb, int offset,
5594         packet_info *pinfo, proto_tree *tree, char *drep)
5595 {
5596         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5597                 pinfo, tree, drep);
5598
5599         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5600                 hf_netlogon_unknown_long, NULL);
5601
5602         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5603                 netlogon_dissect_BYTE_array, NDR_POINTER_UNIQUE,
5604                 "BYTE pointer: unknown_BYTE", -1);
5605
5606         return offset;
5607 }
5608
5609
5610 static int
5611 netlogon_dissect_function_21_reply(tvbuff_t *tvb, int offset,
5612         packet_info *pinfo, proto_tree *tree, char *drep)
5613 {
5614         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5615                 netlogon_dissect_TYPE_50_ptr, NDR_POINTER_UNIQUE,
5616                 "TYPE_50** pointer: unknown_TYPE_50", -1);
5617
5618         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5619                                   hf_netlogon_rc, NULL);
5620
5621         return offset;
5622 }
5623
5624 static int
5625 netlogon_dissect_function_22_rqst(tvbuff_t *tvb, int offset,
5626         packet_info *pinfo, proto_tree *tree, char *drep)
5627 {
5628         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5629                 pinfo, tree, drep);
5630
5631         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5632                 NDR_POINTER_UNIQUE, "unknown string", 
5633                 hf_netlogon_unknown_string, 0);
5634
5635         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5636                 hf_netlogon_unknown_long, NULL);
5637
5638         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5639                 NDR_POINTER_UNIQUE, "unknown string", 
5640                 hf_netlogon_unknown_string, 0);
5641
5642         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5643                 dissect_nt_GUID, NDR_POINTER_UNIQUE,
5644                 "GUID pointer: unknown_GUID", -1);
5645
5646         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5647                 NDR_POINTER_UNIQUE, "unknown string", 
5648                 hf_netlogon_unknown_string, 0);
5649
5650         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5651                 hf_netlogon_unknown_long, NULL);
5652
5653         return offset;
5654 }
5655
5656
5657 static int
5658 netlogon_dissect_function_22_reply(tvbuff_t *tvb, int offset,
5659         packet_info *pinfo, proto_tree *tree, char *drep)
5660 {
5661         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5662                 netlogon_dissect_DOMAIN_CONTROLLER_INFO, NDR_POINTER_UNIQUE,
5663                 "DOMAIN_CONTROLLER_INFO:", -1);
5664
5665         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5666                                   hf_netlogon_rc, NULL);
5667
5668         return offset;
5669 }
5670
5671 static int
5672 netlogon_dissect_function_23_rqst(tvbuff_t *tvb, int offset,
5673         packet_info *pinfo, proto_tree *tree, char *drep)
5674 {
5675         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5676                 pinfo, tree, drep);
5677
5678         return offset;
5679 }
5680
5681
5682 static int
5683 netlogon_dissect_function_23_reply(tvbuff_t *tvb, int offset,
5684         packet_info *pinfo, proto_tree *tree, char *drep)
5685 {
5686         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5687                 NDR_POINTER_UNIQUE, "unknown string", 
5688                 hf_netlogon_unknown_string, 0);
5689
5690         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5691                 netlogon_dissect_pointer_long, NDR_POINTER_UNIQUE,
5692                 "ULONG pointer: unknown_ULONG", hf_netlogon_unknown_long);
5693
5694         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5695                                   hf_netlogon_rc, NULL);
5696
5697         return offset;
5698 }
5699
5700 static int
5701 netlogon_dissect_function_24_rqst(tvbuff_t *tvb, int offset,
5702         packet_info *pinfo, proto_tree *tree, char *drep)
5703 {
5704         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5705                 pinfo, tree, drep);
5706
5707         return offset;
5708 }
5709
5710 static int
5711 netlogon_dissect_function_24_reply(tvbuff_t *tvb, int offset,
5712         packet_info *pinfo, proto_tree *tree, char *drep)
5713 {
5714         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5715                 hf_netlogon_entries, NULL);
5716
5717         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5718                 netlogon_dissect_DS_DOMAIN_TRUSTS_ARRAY, NDR_POINTER_UNIQUE,
5719                 "DS_DOMAIN_TRUSTS_ARRAY:", -1);
5720
5721         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5722                                   hf_netlogon_rc, NULL);
5723
5724         return offset;
5725 }
5726
5727 static int
5728 netlogon_dissect_function_25_rqst(tvbuff_t *tvb, int offset,
5729         packet_info *pinfo, proto_tree *tree, char *drep)
5730 {
5731         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5732                 pinfo, tree, drep);
5733
5734         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5735                 hf_netlogon_unknown_long, NULL);
5736
5737         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5738                 netlogon_dissect_BYTE_array, NDR_POINTER_UNIQUE,
5739                 "BYTE pointer: unknown_BYTE", -1);
5740
5741         return offset;
5742 }
5743
5744
5745 static int
5746 netlogon_dissect_function_25_reply(tvbuff_t *tvb, int offset,
5747         packet_info *pinfo, proto_tree *tree, char *drep)
5748 {
5749         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5750                 netlogon_dissect_TYPE_52_ptr, NDR_POINTER_UNIQUE,
5751                 "TYPE_52 pointer: unknown_TYPE_52", -1);
5752
5753         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5754                                   hf_netlogon_rc, NULL);
5755
5756         return offset;
5757 }
5758
5759
5760 static int
5761 netlogon_dissect_function_26_rqst(tvbuff_t *tvb, int offset,
5762         packet_info *pinfo, proto_tree *tree, char *drep)
5763 {
5764         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5765                 NDR_POINTER_UNIQUE, "unknown string", 
5766                 hf_netlogon_unknown_string, 0);
5767
5768         return offset;
5769 }
5770
5771
5772 static int
5773 netlogon_dissect_function_26_reply(tvbuff_t *tvb, int offset,
5774         packet_info *pinfo, proto_tree *tree, char *drep)
5775 {
5776         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5777                 netlogon_dissect_TYPE_50_ptr, NDR_POINTER_UNIQUE,
5778                 "TYPE_50** pointer: unknown_TYPE_50", -1);
5779
5780         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5781                                   hf_netlogon_rc, NULL);
5782
5783         return offset;
5784 }
5785
5786 static int
5787 netlogon_dissect_logonsamlogonex_rqst(tvbuff_t *tvb, int offset,
5788         packet_info *pinfo, proto_tree *tree, char *drep)
5789 {
5790         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5791                 NDR_POINTER_UNIQUE, "unknown string", 
5792                 hf_netlogon_unknown_string, 0);
5793
5794         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5795                 NDR_POINTER_UNIQUE, "unknown string", 
5796                 hf_netlogon_unknown_string, 0);
5797
5798         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
5799                 hf_netlogon_unknown_short, NULL);
5800
5801         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5802                 netlogon_dissect_LEVEL, NDR_POINTER_UNIQUE,
5803                 "LEVEL pointer: unknown_NETLOGON_LEVEL", -1);
5804
5805         offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, drep,
5806                 hf_netlogon_unknown_short, NULL);
5807
5808         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5809                 netlogon_dissect_pointer_long, NDR_POINTER_UNIQUE,
5810                 "ULONG pointer: unknown_ULONG", hf_netlogon_unknown_long);
5811         return offset;
5812 }
5813
5814
5815 static int
5816 netlogon_dissect_logonsamlogonex_reply(tvbuff_t *tvb, int offset,
5817         packet_info *pinfo, proto_tree *tree, char *drep)
5818 {
5819         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5820                 netlogon_dissect_VALIDATION, NDR_POINTER_UNIQUE,
5821                 "VALIDATION: unknown_NETLOGON_VALIDATION", -1);
5822
5823         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5824                 netlogon_dissect_pointer_char, NDR_POINTER_UNIQUE,
5825                 "BOOLEAN pointer: unknown_BOOLEAN", hf_netlogon_unknown_char);
5826
5827         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5828                 netlogon_dissect_pointer_long, NDR_POINTER_UNIQUE,
5829                 "ULONG pointer: unknown_ULONG", hf_netlogon_unknown_long);
5830
5831         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5832                                   hf_netlogon_rc, NULL);
5833
5834         return offset;
5835 }
5836
5837
5838 static int
5839 netlogon_dissect_dsenumeratetrusteddomains_rqst(tvbuff_t *tvb, int offset,
5840         packet_info *pinfo, proto_tree *tree, char *drep)
5841 {
5842         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5843                 pinfo, tree, drep);
5844
5845         offset = netlogon_dissect_DOMAIN_TRUST_FLAGS(tvb, offset, pinfo, tree, drep);
5846
5847         return offset;
5848 }
5849
5850
5851 static int
5852 netlogon_dissect_dsenumeratetrusteddomains_reply(tvbuff_t *tvb, int offset,
5853         packet_info *pinfo, proto_tree *tree, char *drep)
5854 {
5855         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
5856                 hf_netlogon_entries, NULL);
5857
5858         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5859                 netlogon_dissect_DS_DOMAIN_TRUSTS_ARRAY, NDR_POINTER_UNIQUE,
5860                 "DS_DOMAIN_TRUSTS_ARRAY:", -1);
5861
5862         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5863                                   hf_netlogon_rc, NULL);
5864
5865         return offset;
5866 }
5867
5868 static int
5869 netlogon_dissect_dsrderegisterdnshostrecords_rqst(tvbuff_t *tvb, int offset,
5870         packet_info *pinfo, proto_tree *tree, char *drep)
5871 {
5872         offset = netlogon_dissect_LOGONSRV_HANDLE(tvb, offset,
5873                 pinfo, tree, drep);
5874
5875         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5876                 NDR_POINTER_UNIQUE, "Domain", hf_netlogon_logon_dom, 0);
5877
5878         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5879                 dissect_nt_GUID, NDR_POINTER_UNIQUE,
5880                 "GUID pointer: domain_guid", -1);
5881
5882         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
5883                 dissect_nt_GUID, NDR_POINTER_UNIQUE,
5884                 "GUID pointer: dsa_guid", -1);
5885
5886         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
5887                 NDR_POINTER_REF, "dns_host", hf_netlogon_dns_host, 0);
5888
5889         return offset;
5890 }
5891
5892
5893 static int
5894 netlogon_dissect_dsrderegisterdnshostrecords_reply(tvbuff_t *tvb, int offset,
5895         packet_info *pinfo, proto_tree *tree, char *drep)
5896 {
5897         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
5898                                   hf_netlogon_rc, NULL);
5899
5900         return offset;
5901 }
5902
5903 /* Dissect secure channel stuff */
5904
5905 static int hf_netlogon_secchan_bind_unknown1 = -1;
5906 static int hf_netlogon_secchan_bind_unknown2 = -1;
5907 static int hf_netlogon_secchan_domain = -1;
5908 static int hf_netlogon_secchan_host = -1;
5909 static int hf_netlogon_secchan_bind_ack_unknown1 = -1;
5910 static int hf_netlogon_secchan_bind_ack_unknown2 = -1;
5911 static int hf_netlogon_secchan_bind_ack_unknown3 = -1;
5912
5913 static gint ett_secchan_verf = -1;
5914 static gint ett_secchan_bind_creds = -1;
5915 static gint ett_secchan_bind_ack_creds = -1;
5916
5917 static int dissect_secchan_bind_creds(tvbuff_t *tvb, int offset,
5918                                       packet_info *pinfo, 
5919                                       proto_tree *tree, char *drep)
5920 {
5921         proto_item *item = NULL;
5922         proto_tree *subtree = NULL;
5923         int len;
5924
5925         if (tree) {
5926                 item = proto_tree_add_text(
5927                         tree, tvb, offset, tvb_length(tvb),
5928                         "Secure Channel Bind Credentials");
5929                 subtree = proto_item_add_subtree(
5930                         item, ett_secchan_bind_creds);
5931         }
5932
5933         /* We can't use the NDR routines as the DCERPC call data hasn't
5934            been initialised since we haven't made a DCERPC call yet, just
5935            a bind request. */
5936
5937         offset = dissect_dcerpc_uint32(
5938                 tvb, offset, pinfo, subtree, drep, 
5939                 hf_netlogon_secchan_bind_unknown1, NULL);
5940
5941         offset = dissect_dcerpc_uint32(
5942                 tvb, offset, pinfo, subtree, drep, 
5943                 hf_netlogon_secchan_bind_unknown2, NULL);
5944
5945         len = tvb_strsize(tvb, offset);
5946
5947         proto_tree_add_item(
5948                 subtree, hf_netlogon_secchan_domain, tvb, offset, len, FALSE);
5949
5950         offset += len;
5951
5952         len = tvb_strsize(tvb, offset);
5953
5954         proto_tree_add_item(
5955                 subtree, hf_netlogon_secchan_host, tvb, offset, len, FALSE);
5956
5957         offset += len;
5958
5959         return offset;
5960 }
5961
5962 static int dissect_secchan_bind_ack_creds(tvbuff_t *tvb, int offset,
5963                                           packet_info *pinfo, 
5964                                           proto_tree *tree, char *drep)
5965 {
5966         proto_item *item = NULL;
5967         proto_tree *subtree = NULL;
5968
5969         if (tree) {
5970                 item = proto_tree_add_text(
5971                         tree, tvb, offset, 0,
5972                         "Secure Channel Bind ACK Credentials");
5973                 subtree = proto_item_add_subtree(
5974                         item, ett_secchan_bind_ack_creds);
5975         }
5976
5977         /* Don't use NDR routines here */
5978
5979         offset = dissect_dcerpc_uint32(
5980                 tvb, offset, pinfo, subtree, drep, 
5981                 hf_netlogon_secchan_bind_ack_unknown1, NULL);
5982
5983         offset = dissect_dcerpc_uint32(
5984                 tvb, offset, pinfo, subtree, drep, 
5985                 hf_netlogon_secchan_bind_ack_unknown2, NULL);
5986
5987         offset = dissect_dcerpc_uint32(
5988                 tvb, offset, pinfo, subtree, drep, 
5989                 hf_netlogon_secchan_bind_ack_unknown3, NULL);
5990
5991         return offset;
5992 }
5993
5994 /* Subdissectors */
5995
5996 static dcerpc_sub_dissector dcerpc_netlogon_dissectors[] = {
5997         { NETLOGON_UASLOGON, "UasLogon",
5998                 netlogon_dissect_netlogonuaslogon_rqst,
5999                 netlogon_dissect_netlogonuaslogon_reply },
6000         { NETLOGON_UASLOGOFF, "UasLogoff",
6001                 netlogon_dissect_netlogonuaslogoff_rqst,
6002                 netlogon_dissect_netlogonuaslogoff_reply },
6003         { NETLOGON_NETLOGONSAMLOGON, "SamLogon",
6004                 netlogon_dissect_netlogonsamlogon_rqst,
6005                 netlogon_dissect_netlogonsamlogon_reply },
6006         { NETLOGON_NETLOGONSAMLOGOFF, "SamLogoff",
6007                 netlogon_dissect_netlogonsamlogoff_rqst,
6008                 netlogon_dissect_netlogonsamlogoff_reply },
6009         { NETLOGON_NETSERVERREQCHALLENGE, "ServerReqChallenge",
6010                 netlogon_dissect_netserverreqchallenge_rqst,
6011                 netlogon_dissect_netserverreqchallenge_reply },
6012         { NETLOGON_NETSERVERAUTHENTICATE, "ServerAuthenticate",
6013                 netlogon_dissect_netserverauthenticate_rqst,
6014                 netlogon_dissect_netserverauthenticate_reply },
6015         { NETLOGON_NETSERVERPASSWORDSET, "ServerPasswdSet",
6016                 netlogon_dissect_netserverpasswordset_rqst,
6017                 netlogon_dissect_netserverpasswordset_reply },
6018         { NETLOGON_NETSAMDELTAS, "DatabaseDeltas",
6019                 netlogon_dissect_netsamdeltas_rqst,
6020                 netlogon_dissect_netsamdeltas_reply },
6021         { NETLOGON_DATABASESYNC, "DatabaseSync",
6022                 netlogon_dissect_netlogondatabasesync_rqst,
6023                 netlogon_dissect_netlogondatabasesync_reply },
6024         { NETLOGON_ACCOUNTDELTAS, "AccountDeltas",
6025                 netlogon_dissect_netlogonaccountdeltas_rqst,
6026                 netlogon_dissect_netlogonaccountdeltas_reply },
6027         { NETLOGON_ACCOUNTSYNC, "AccountSync",
6028                 netlogon_dissect_netlogonaccountsync_rqst,
6029                 netlogon_dissect_netlogonaccountsync_reply },
6030         { NETLOGON_GETDCNAME, "GetDCName",
6031                 netlogon_dissect_netlogongetdcname_rqst,
6032                 netlogon_dissect_netlogongetdcname_reply },
6033         { NETLOGON_NETLOGONCONTROL, "LogonControl",
6034                 netlogon_dissect_netlogoncontrol_rqst,
6035                 netlogon_dissect_netlogoncontrol_reply },
6036         { NETLOGON_GETANYDCNAME, "GetAnyDCName",
6037                 netlogon_dissect_netlogongetanydcname_rqst,
6038                 netlogon_dissect_netlogongetanydcname_reply },
6039         { NETLOGON_NETLOGONCONTROL2, "LogonControl2",
6040                 netlogon_dissect_netlogoncontrol2_rqst,
6041                 netlogon_dissect_netlogoncontrol2_reply },
6042         { NETLOGON_NETSERVERAUTHENTICATE2, "ServerAuthenticate2",
6043                 netlogon_dissect_netserverauthenticate2_rqst,
6044                 netlogon_dissect_netserverauthenticate2_reply },
6045         { NETLOGON_NETDATABASESYNC2, "DatabaseSync2",
6046                 netlogon_dissect_netdatabasesync2_rqst,
6047                 netlogon_dissect_netdatabasesync2_reply },
6048         { NETLOGON_DATABASEREDO, "DatabaseRedo",
6049                 netlogon_dissect_netlogondatabaseredo_rqst,
6050                 netlogon_dissect_netlogondatabaseredo_reply },
6051         { NETLOGON_FUNCTION_12, "Function_0x12",
6052                 netlogon_dissect_function_12_rqst,
6053                 netlogon_dissect_function_12_reply },
6054         { NETLOGON_NETTRUSTEDDOMAINLIST, "TrustedDomainList",
6055                 netlogon_dissect_nettrusteddomainlist_rqst,
6056                 netlogon_dissect_nettrusteddomainlist_reply },
6057         { NETLOGON_DSRGETDCNAME2, "DsrGetDCName2",
6058                 netlogon_dissect_dsrgetdcname2_rqst,
6059                 netlogon_dissect_dsrgetdcname2_reply },
6060         { NETLOGON_FUNCTION_15, "Function 0x15",
6061                 netlogon_dissect_function_15_rqst,
6062                 netlogon_dissect_function_15_reply },
6063         { NETLOGON_FUNCTION_16, "Function 0x16",
6064                 netlogon_dissect_function_16_rqst,
6065                 netlogon_dissect_function_16_reply },
6066         { NETLOGON_FUNCTION_17, "Function 0x17",
6067                 netlogon_dissect_function_17_rqst,
6068                 netlogon_dissect_function_17_reply },
6069         { NETLOGON_FUNCTION_18, "Function 0x18",
6070                 netlogon_dissect_function_18_rqst,
6071                 netlogon_dissect_function_18_reply },
6072         { NETLOGON_FUNCTION_19, "Function 0x19",
6073                 netlogon_dissect_function_19_rqst,
6074                 netlogon_dissect_function_19_reply },
6075         { NETLOGON_NETSERVERAUTHENTICATE3, "ServerAuthenticate3",
6076                 netlogon_dissect_netserverauthenticate3_rqst,
6077                 netlogon_dissect_netserverauthenticate3_reply },
6078         { NETLOGON_DSRGETDCNAME, "DsrGetDCName",
6079                 netlogon_dissect_dsrgetdcname_rqst,
6080                 netlogon_dissect_dsrgetdcname_reply },
6081         { NETLOGON_DSRGETSITENAME, "DsrGetSiteName",
6082                 netlogon_dissect_dsrgetsitename_rqst,
6083                 netlogon_dissect_dsrgetsitename_reply },
6084         { NETLOGON_NETRLOGONGETDOMAININFO, "NetrLogonGetDomainInfo",
6085                 netlogon_dissect_netrlogongetdomaininfo_rqst,
6086                 netlogon_dissect_netrlogongetdomaininfo_reply },
6087         { NETLOGON_FUNCTION_1E, "Function_0x1E",
6088                 netlogon_dissect_function_1e_rqst,
6089                 netlogon_dissect_function_1e_reply },
6090         { NETLOGON_NETSERVERPASSWORDSET2, "ServerPasswordSet2",
6091                 netlogon_dissect_netserverpasswordset2_rqst,
6092                 netlogon_dissect_netserverpasswordset2_reply },
6093         { NETLOGON_FUNCTION_20, "Function_0x20",
6094                 netlogon_dissect_function_20_rqst,
6095                 netlogon_dissect_function_20_reply },
6096         { NETLOGON_FUNCTION_21, "Function_0x21",
6097                 netlogon_dissect_function_21_rqst,
6098                 netlogon_dissect_function_21_reply },
6099         { NETLOGON_FUNCTION_22, "Function_0x22",
6100                 netlogon_dissect_function_22_rqst,
6101                 netlogon_dissect_function_22_reply },
6102         { NETLOGON_FUNCTION_23, "Function_0x23",
6103                 netlogon_dissect_function_23_rqst,
6104                 netlogon_dissect_function_23_reply },
6105         { NETLOGON_FUNCTION_24, "Function_0x24",
6106                 netlogon_dissect_function_24_rqst,
6107                 netlogon_dissect_function_24_reply },
6108         { NETLOGON_FUNCTION_25, "Function_0x25",
6109                 netlogon_dissect_function_25_rqst,
6110                 netlogon_dissect_function_25_reply },
6111         { NETLOGON_FUNCTION_26, "Function_0x26",
6112                 netlogon_dissect_function_26_rqst,
6113                 netlogon_dissect_function_26_reply },
6114         { NETLOGON_LOGONSAMLOGONEX, "LogonSamLogonEx",
6115                 netlogon_dissect_logonsamlogonex_rqst,
6116                 netlogon_dissect_logonsamlogonex_reply },
6117         { NETLOGON_DSENUMERATETRUSTEDDOMAINS, "DSEnumerateTrustedDomains",
6118                 netlogon_dissect_dsenumeratetrusteddomains_rqst,
6119                 netlogon_dissect_dsenumeratetrusteddomains_reply },
6120         { NETLOGON_DSRDEREGISTERDNSHOSTRECORDS, "DsrDeregisterDNSHostRecords",
6121                 netlogon_dissect_dsrderegisterdnshostrecords_rqst,
6122                 netlogon_dissect_dsrderegisterdnshostrecords_reply },
6123         {0, NULL, NULL,  NULL }
6124 };
6125
6126 static int hf_netlogon_secchan_verf = -1;
6127 static int hf_netlogon_secchan_verf_sig = -1;
6128 static int hf_netlogon_secchan_verf_unk = -1;
6129 static int hf_netlogon_secchan_verf_seq = -1;
6130 static int hf_netlogon_secchan_verf_nonce = -1;
6131
6132 static int
6133 dissect_secchan_verf(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, 
6134                      proto_tree *tree, char *drep _U_)
6135 {
6136           proto_item *vf = NULL;
6137           proto_tree *subtree = NULL;
6138           
6139           /*
6140            * Create a new tree, and split into 4 components ...
6141            */
6142           vf = proto_tree_add_item(tree, hf_netlogon_secchan_verf, tvb,
6143               offset, -1, FALSE);
6144           subtree = proto_item_add_subtree(vf, ett_secchan_verf);
6145                                                                                 
6146           proto_tree_add_item(subtree, hf_netlogon_secchan_verf_sig, tvb,
6147               offset, 8, FALSE);
6148           offset += 8;
6149                                                                                 
6150           proto_tree_add_item(subtree, hf_netlogon_secchan_verf_unk, tvb,
6151               offset, 8, FALSE);
6152           offset += 8;
6153                                                                                 
6154           proto_tree_add_item(subtree, hf_netlogon_secchan_verf_seq, tvb,
6155               offset, 8, FALSE);
6156           offset += 8;
6157                                                                                 
6158           proto_tree_add_item(subtree, hf_netlogon_secchan_verf_nonce, tvb,
6159               offset, 8, FALSE);
6160           offset += 8;
6161
6162           return offset;
6163 }
6164
6165 /* Secure channel types */
6166
6167 static const value_string sec_chan_type_vals[] = {
6168         { SEC_CHAN_WKSTA,  "Workstation" },
6169         { SEC_CHAN_DOMAIN, "Domain trust" },
6170         { SEC_CHAN_BDC,    "Backup domain controller" },
6171         { 0, NULL }
6172 };
6173
6174 void
6175 proto_register_dcerpc_netlogon(void)
6176 {
6177
6178 static hf_register_info hf[] = {
6179         { &hf_netlogon_opnum,
6180           { "Operation", "netlogon.opnum", FT_UINT16, BASE_DEC,
6181             NULL, 0x0, "Operation", HFILL }},
6182
6183         { &hf_netlogon_rc, {
6184                 "Return code", "netlogon.rc", FT_UINT32, BASE_HEX,
6185                 VALS(NT_errors), 0x0, "Netlogon return code", HFILL }},
6186
6187         { &hf_netlogon_param_ctrl, {
6188                 "Param Ctrl", "netlogon.param_ctrl", FT_UINT32, BASE_HEX,
6189                 NULL, 0x0, "Param ctrl", HFILL }},
6190
6191         { &hf_netlogon_logon_id, {
6192                 "Logon ID", "netlogon.logon_id", FT_UINT64, BASE_DEC,
6193                 NULL, 0x0, "Logon ID", HFILL }},
6194
6195         { &hf_netlogon_modify_count, {
6196                 "Modify Count", "netlogon.modify_count", FT_UINT64, BASE_DEC,
6197                 NULL, 0x0, "How many times the object has been modified", HFILL }},
6198
6199         { &hf_netlogon_security_information, {
6200                 "Security Information", "netlogon.security_information", FT_UINT32, BASE_DEC,
6201                 NULL, 0x0, "Security Information", HFILL }},
6202
6203         { &hf_netlogon_count, {
6204                 "Count", "netlogon.count", FT_UINT32, BASE_DEC,
6205                 NULL, 0x0, "", HFILL }},
6206
6207         { &hf_netlogon_entries, {
6208                 "Entries", "netlogon.entries", FT_UINT32, BASE_DEC,
6209                 NULL, 0x0, "", HFILL }},
6210
6211         { &hf_netlogon_credential, {
6212                 "Credential", "netlogon.credential", FT_BYTES, BASE_HEX,
6213                 NULL, 0x0, "Netlogon Credential", HFILL }},
6214
6215         { &hf_netlogon_challenge, {
6216                 "Challenge", "netlogon.challenge", FT_BYTES, BASE_HEX,
6217                 NULL, 0x0, "Netlogon challenge", HFILL }},
6218
6219         { &hf_netlogon_lm_owf_password, {
6220                 "LM Pwd", "netlogon.lm_owf_pwd", FT_BYTES, BASE_HEX,
6221                 NULL, 0x0, "LanManager OWF Password", HFILL }},
6222
6223         { &hf_netlogon_user_session_key, {
6224                 "User Session Key", "netlogon.user_session_key", FT_BYTES, BASE_HEX,
6225                 NULL, 0x0, "User Session Key", HFILL }},
6226
6227         { &hf_netlogon_encrypted_lm_owf_password, {
6228                 "Encrypted LM Pwd", "netlogon.lm_owf_pwd.encrypted", FT_BYTES, BASE_HEX,
6229                 NULL, 0x0, "Encrypted LanManager OWF Password", HFILL }},
6230
6231         { &hf_netlogon_nt_owf_password, {
6232                 "NT Pwd", "netlogon.nt_owf_pwd", FT_BYTES, BASE_HEX,
6233                 NULL, 0x0, "NT OWF Password", HFILL }},
6234
6235         { &hf_netlogon_blob, {
6236                 "BLOB", "netlogon.blob", FT_BYTES, BASE_HEX,
6237                 NULL, 0x0, "BLOB", HFILL }},
6238
6239         { &hf_netlogon_len, {
6240                 "Len", "netlogon.len", FT_UINT32, BASE_DEC,
6241                 NULL, 0, "Length", HFILL }},
6242
6243         { &hf_netlogon_priv, {
6244                 "Priv", "netlogon.priv", FT_UINT32, BASE_DEC,
6245                 NULL, 0, "", HFILL }},
6246
6247         { &hf_netlogon_privilege_entries, {
6248                 "Privilege Entries", "netlogon.privilege_entries", FT_UINT32, BASE_DEC,
6249                 NULL, 0, "", HFILL }},
6250
6251         { &hf_netlogon_privilege_control, {
6252                 "Privilege Control", "netlogon.privilege_control", FT_UINT32, BASE_HEX,
6253                 NULL, 0, "", HFILL }},
6254
6255         { &hf_netlogon_privilege_name, {
6256                 "Privilege Name", "netlogon.privilege_name", FT_STRING, BASE_HEX,
6257                 NULL, 0, "", HFILL }},
6258
6259         { &hf_netlogon_pdc_connection_status, {
6260                 "PDC Connection Status", "netlogon.pdc_connection_status", FT_UINT32, BASE_DEC,
6261                 NULL, 0, "PDC Connection Status", HFILL }},
6262
6263         { &hf_netlogon_tc_connection_status, {
6264                 "TC Connection Status", "netlogon.tc_connection_status", FT_UINT32, BASE_DEC,
6265                 NULL, 0, "TC Connection Status", HFILL }},
6266
6267         { &hf_netlogon_attrs, {
6268                 "Attributes", "netlogon.attrs", FT_UINT32, BASE_HEX,
6269                 NULL, 0, "Attributes", HFILL }},
6270
6271         { &hf_netlogon_unknown_string,
6272                 { "Unknown string", "netlogon.unknown_string", FT_STRING, BASE_NONE,
6273                 NULL, 0, "Unknown string. If you know what this is, contact ethereal developers.", HFILL }},
6274         { &hf_netlogon_unknown_long,
6275                 { "Unknown long", "netlogon.unknown.long", FT_UINT32, BASE_HEX,
6276                 NULL, 0x0, "Unknown long. If you know what this is, contact ethereal developers.", HFILL }},
6277         { &hf_netlogon_reserved,
6278                 { "Reserved", "netlogon.reserved", FT_UINT32, BASE_HEX,
6279                 NULL, 0x0, "Reserved", HFILL }},
6280         { &hf_netlogon_unknown_short,
6281                 { "Unknown short", "netlogon.unknown.short", FT_UINT16, BASE_HEX,
6282                 NULL, 0x0, "Unknown short. If you know what this is, contact ethereal developers.", HFILL }},
6283
6284         { &hf_netlogon_unknown_char,
6285                 { "Unknown char", "netlogon.unknown.char", FT_UINT8, BASE_HEX,
6286                 NULL, 0x0, "Unknown char. If you know what this is, contact ethereal developers.", HFILL }},
6287
6288         { &hf_netlogon_acct_expiry_time,
6289                 { "Acct Expiry Time", "netlogon.acct.expiry_time", FT_ABSOLUTE_TIME, BASE_NONE,
6290                 NULL, 0x0, "When this account will expire", HFILL }},
6291
6292         { &hf_netlogon_nt_pwd_present,
6293                 { "NT PWD Present", "netlogon.nt_pwd_present", FT_UINT8, BASE_HEX,
6294                 NULL, 0x0, "Is NT password present for this account?", HFILL }},
6295
6296         { &hf_netlogon_lm_pwd_present,
6297                 { "LM PWD Present", "netlogon.lm_pwd_present", FT_UINT8, BASE_HEX,
6298                 NULL, 0x0, "Is LanManager password present for this account?", HFILL }},
6299
6300         { &hf_netlogon_pwd_expired,
6301                 { "PWD Expired", "netlogon.pwd_expired", FT_UINT8, BASE_HEX,
6302                 NULL, 0x0, "Whether this password has expired or not", HFILL }},
6303
6304         { &hf_netlogon_authoritative,
6305                 { "Authoritative", "netlogon.authoritative", FT_UINT8, BASE_DEC,
6306                 NULL, 0x0, "", HFILL }},
6307
6308         { &hf_netlogon_sensitive_data_flag,
6309                 { "Sensitive Data", "netlogon.sensitive_data_flag", FT_UINT8, BASE_DEC,
6310                 NULL, 0x0, "Sensitive data flag", HFILL }},
6311
6312         { &hf_netlogon_auditing_mode,
6313                 { "Auditing Mode", "netlogon.auditing_mode", FT_UINT8, BASE_DEC,
6314                 NULL, 0x0, "Auditing Mode", HFILL }},
6315
6316         { &hf_netlogon_max_audit_event_count,
6317                 { "Max Audit Event Count", "netlogon.max_audit_event_count", FT_UINT32, BASE_DEC,
6318                 NULL, 0x0, "Max audit event count", HFILL }},
6319
6320         { &hf_netlogon_event_audit_option,
6321                 { "Event Audit Option", "netlogon.event_audit_option", FT_UINT32, BASE_HEX,
6322                 NULL, 0x0, "Event audit option", HFILL }},
6323
6324         { &hf_netlogon_sensitive_data_len,
6325                 { "Length", "netlogon.sensitive_data_len", FT_UINT32, BASE_DEC,
6326                 NULL, 0x0, "Length of sensitive data", HFILL }},
6327
6328         { &hf_netlogon_nt_chal_resp,
6329                 { "NT Chal resp", "netlogon.nt_chal_resp", FT_BYTES, BASE_HEX,
6330                 NULL, 0, "Challenge response for NT authentication", HFILL }},
6331
6332         { &hf_netlogon_lm_chal_resp,
6333                 { "LM Chal resp", "netlogon.lm_chal_resp", FT_BYTES, BASE_HEX,
6334                 NULL, 0, "Challenge response for LM authentication", HFILL }},
6335
6336         { &hf_netlogon_cipher_len,
6337                 { "Cipher Len", "netlogon.cipher_len", FT_UINT32, BASE_DEC,
6338                 NULL, 0, "", HFILL }},
6339
6340         { &hf_netlogon_cipher_maxlen,
6341                 { "Cipher Max Len", "netlogon.cipher_maxlen", FT_UINT32, BASE_DEC,
6342                 NULL, 0, "", HFILL }},
6343
6344         { &hf_netlogon_pac_data,
6345                 { "Pac Data", "netlogon.pac.data", FT_BYTES, BASE_HEX,
6346                 NULL, 0, "Pac Data", HFILL }},
6347
6348         { &hf_netlogon_sensitive_data,
6349                 { "Data", "netlogon.sensitive_data", FT_BYTES, BASE_HEX,
6350                 NULL, 0, "Sensitive Data", HFILL }},
6351
6352         { &hf_netlogon_auth_data,
6353                 { "Auth Data", "netlogon.auth.data", FT_BYTES, BASE_HEX,
6354                 NULL, 0, "Auth Data", HFILL }},
6355
6356         { &hf_netlogon_cipher_current_data,
6357                 { "Cipher Current Data", "netlogon.cipher_current_data", FT_BYTES, BASE_HEX,
6358                 NULL, 0, "", HFILL }},
6359
6360         { &hf_netlogon_cipher_old_data,
6361                 { "Cipher Old Data", "netlogon.cipher_old_data", FT_BYTES, BASE_HEX,
6362                 NULL, 0, "", HFILL }},
6363
6364         { &hf_netlogon_acct_name,
6365                 { "Acct Name", "netlogon.acct_name", FT_STRING, BASE_NONE,
6366                 NULL, 0, "Account Name", HFILL }},
6367
6368         { &hf_netlogon_acct_desc,
6369                 { "Acct Desc", "netlogon.acct_desc", FT_STRING, BASE_NONE,
6370                 NULL, 0, "Account Description", HFILL }},
6371
6372         { &hf_netlogon_group_desc,
6373                 { "Group Desc", "netlogon.group_desc", FT_STRING, BASE_NONE,
6374                 NULL, 0, "Group Description", HFILL }},
6375
6376         { &hf_netlogon_full_name,
6377                 { "Full Name", "netlogon.full_name", FT_STRING, BASE_NONE,
6378                 NULL, 0, "Full Name", HFILL }},
6379
6380         { &hf_netlogon_comment,
6381                 { "Comment", "netlogon.comment", FT_STRING, BASE_NONE,
6382                 NULL, 0, "Comment", HFILL }},
6383
6384         { &hf_netlogon_parameters,
6385                 { "Parameters", "netlogon.parameters", FT_STRING, BASE_NONE,
6386                 NULL, 0, "Parameters", HFILL }},
6387
6388         { &hf_netlogon_logon_script,
6389                 { "Logon Script", "netlogon.logon_script", FT_STRING, BASE_NONE,
6390                 NULL, 0, "Logon Script", HFILL }},
6391
6392         { &hf_netlogon_profile_path,
6393                 { "Profile Path", "netlogon.profile_path", FT_STRING, BASE_NONE,
6394                 NULL, 0, "Profile Path", HFILL }},
6395
6396         { &hf_netlogon_home_dir,
6397                 { "Home Dir", "netlogon.home_dir", FT_STRING, BASE_NONE,
6398                 NULL, 0, "Home Directory", HFILL }},
6399
6400         { &hf_netlogon_dir_drive,
6401                 { "Dir Drive", "netlogon.dir_drive", FT_STRING, BASE_NONE,
6402                 NULL, 0, "Drive letter for home directory", HFILL }},
6403
6404         { &hf_netlogon_logon_srv,
6405                 { "Server", "netlogon.server", FT_STRING, BASE_NONE,
6406                 NULL, 0, "Server", HFILL }},
6407
6408         { &hf_netlogon_principal,
6409                 { "Principal", "netlogon.principal", FT_STRING, BASE_NONE,
6410                 NULL, 0, "Principal", HFILL }},
6411
6412         { &hf_netlogon_logon_dom,
6413                 { "Domain", "netlogon.domain", FT_STRING, BASE_NONE,
6414                 NULL, 0, "Domain", HFILL }},
6415
6416         { &hf_netlogon_computer_name,
6417                 { "Computer Name", "netlogon.computer_name", FT_STRING, BASE_NONE,
6418                 NULL, 0, "Computer Name", HFILL }},
6419
6420         { &hf_netlogon_site_name,
6421                 { "Site Name", "netlogon.site_name", FT_STRING, BASE_NONE,
6422                 NULL, 0, "Site Name", HFILL }},
6423
6424         { &hf_netlogon_dc_name,
6425                 { "DC Name", "netlogon.dc.name", FT_STRING, BASE_NONE,
6426                 NULL, 0, "DC Name", HFILL }},
6427
6428         { &hf_netlogon_dc_site_name,
6429                 { "DC Site Name", "netlogon.dc.site_name", FT_STRING, BASE_NONE,
6430                 NULL, 0, "DC Site Name", HFILL }},
6431
6432         { &hf_netlogon_dns_forest_name,
6433                 { "DNS Forest Name", "netlogon.dns.forest_name", FT_STRING, BASE_NONE,
6434                 NULL, 0, "DNS Forest Name", HFILL }},
6435
6436         { &hf_netlogon_dc_address,
6437                 { "DC Address", "netlogon.dc.address", FT_STRING, BASE_NONE,
6438                 NULL, 0, "DC Address", HFILL }},
6439
6440         { &hf_netlogon_dc_address_type,
6441                 { "DC Address Type", "netlogon.dc.address_type", FT_UINT32, BASE_DEC,
6442                 VALS(dc_address_types), 0, "DC Address Type", HFILL }},
6443
6444         { &hf_netlogon_client_site_name,
6445                 { "Client Site Name", "netlogon.client.site_name", FT_STRING, BASE_NONE,
6446                 NULL, 0, "Client Site Name", HFILL }},
6447
6448         { &hf_netlogon_workstation_site_name,
6449                 { "Wkst Site Name", "netlogon.wkst.site_name", FT_STRING, BASE_NONE,
6450                 NULL, 0, "Workstation Site Name", HFILL }},
6451
6452         { &hf_netlogon_workstation,
6453                 { "Wkst Name", "netlogon.wkst.name", FT_STRING, BASE_NONE,
6454                 NULL, 0, "Workstation Name", HFILL }},
6455
6456         { &hf_netlogon_workstation_os,
6457                 { "Wkst OS", "netlogon.wkst.os", FT_STRING, BASE_NONE,
6458                 NULL, 0, "Workstation OS", HFILL }},
6459
6460         { &hf_netlogon_workstations,
6461                 { "Workstations", "netlogon.wksts", FT_STRING, BASE_NONE,
6462                 NULL, 0, "Workstations", HFILL }},
6463
6464         { &hf_netlogon_workstation_fqdn,
6465                 { "Wkst FQDN", "netlogon.wkst.fqdn", FT_STRING, BASE_NONE,
6466                 NULL, 0, "Workstation FQDN", HFILL }},
6467
6468         { &hf_netlogon_group_name,
6469                 { "Group Name", "netlogon.group_name", FT_STRING, BASE_NONE,
6470                 NULL, 0, "Group Name", HFILL }},
6471
6472         { &hf_netlogon_alias_name,
6473                 { "Alias Name", "netlogon.alias_name", FT_STRING, BASE_NONE,
6474                 NULL, 0, "Alias Name", HFILL }},
6475
6476         { &hf_netlogon_dns_host,
6477                 { "DNS Host", "netlogon.dns_host", FT_STRING, BASE_NONE,
6478                 NULL, 0, "DNS Host", HFILL }},
6479
6480         { &hf_netlogon_downlevel_domain_name,
6481                 { "Downlevel Domain", "netlogon.downlevel_domain", FT_STRING, BASE_NONE,
6482                 NULL, 0, "Downlevel Domain Name", HFILL }},
6483
6484         { &hf_netlogon_dns_domain_name,
6485                 { "DNS Domain", "netlogon.dns_domain", FT_STRING, BASE_NONE,
6486                 NULL, 0, "DNS Domain Name", HFILL }},
6487
6488         { &hf_netlogon_domain_name,
6489                 { "Domain", "netlogon.domain", FT_STRING, BASE_NONE,
6490                 NULL, 0, "Domain Name", HFILL }},
6491
6492         { &hf_netlogon_oem_info,
6493                 { "OEM Info", "netlogon.oem_info", FT_STRING, BASE_NONE,
6494                 NULL, 0, "OEM Info", HFILL }},
6495
6496         { &hf_netlogon_trusted_dc_name,
6497                 { "Trusted DC", "netlogon.trusted_dc", FT_STRING, BASE_NONE,
6498                 NULL, 0, "Trusted DC", HFILL }},
6499
6500         { &hf_netlogon_logonsrv_handle,
6501                 { "Handle", "netlogon.handle", FT_STRING, BASE_NONE,
6502                 NULL, 0, "Logon Srv Handle", HFILL }},
6503
6504         { &hf_netlogon_dummy,
6505                 { "Dummy", "netlogon.dummy", FT_STRING, BASE_NONE,
6506                 NULL, 0, "Dummy string", HFILL }},
6507
6508         { &hf_netlogon_logon_count16,
6509                 { "Logon Count", "netlogon.logon_count16", FT_UINT16, BASE_DEC,
6510                 NULL, 0x0, "Number of successful logins", HFILL }},
6511
6512         { &hf_netlogon_logon_count,
6513                 { "Logon Count", "netlogon.logon_count", FT_UINT32, BASE_DEC,
6514                 NULL, 0x0, "Number of successful logins", HFILL }},
6515
6516         { &hf_netlogon_bad_pw_count16,
6517                 { "Bad PW Count", "netlogon.bad_pw_count16", FT_UINT16, BASE_DEC,
6518                 NULL, 0x0, "Number of failed logins", HFILL }},
6519
6520         { &hf_netlogon_bad_pw_count,
6521                 { "Bad PW Count", "netlogon.bad_pw_count", FT_UINT32, BASE_DEC,
6522                 NULL, 0x0, "Number of failed logins", HFILL }},
6523
6524         { &hf_netlogon_country,
6525                 { "Country", "netlogon.country", FT_UINT16, BASE_DEC,
6526                 VALS(ms_country_codes), 0x0, "Country setting for this account", HFILL }},
6527
6528         { &hf_netlogon_codepage,
6529                 { "Codepage", "netlogon.codepage", FT_UINT16, BASE_DEC,
6530                 NULL, 0x0, "Codepage setting for this account", HFILL }},
6531
6532         { &hf_netlogon_level16,
6533                 { "Level", "netlogon.level16", FT_UINT16, BASE_DEC,
6534                 NULL, 0x0, "Which option of the union is represented here", HFILL }},
6535
6536         { &hf_netlogon_validation_level,
6537                 { "Validation Level", "netlogon.validation_level", FT_UINT16, BASE_DEC,
6538                 NULL, 0x0, "Requested level of validation", HFILL }},
6539
6540         { &hf_netlogon_minpasswdlen,
6541                 { "Min Password Len", "netlogon.min_passwd_len", FT_UINT16, BASE_DEC,
6542                 NULL, 0x0, "Minimum length of password", HFILL }},
6543
6544         { &hf_netlogon_passwdhistorylen,
6545                 { "Passwd History Len", "netlogon.passwd_history_len", FT_UINT16, BASE_DEC,
6546                 NULL, 0x0, "Length of password history", HFILL }},
6547
6548         { &hf_netlogon_secure_channel_type,
6549                 { "Sec Chan Type", "netlogon.sec_chan_type", FT_UINT16, BASE_DEC,
6550                 VALS(sec_chan_type_vals), 0x0, "Secure Channel Type", HFILL }},
6551
6552         { &hf_netlogon_restart_state,
6553                 { "Restart State", "netlogon.restart_state", FT_UINT16, BASE_DEC,
6554                 NULL, 0x0, "Restart State", HFILL }},
6555
6556         { &hf_netlogon_delta_type,
6557                 { "Delta Type", "netlogon.delta_type", FT_UINT16, BASE_DEC,
6558                 VALS(delta_type_vals), 0x0, "Delta Type", HFILL }},
6559
6560         { &hf_netlogon_blob_size,
6561                 { "Size", "netlogon.blob.size", FT_UINT32, BASE_DEC,
6562                 NULL, 0x0, "Size in bytes of BLOB", HFILL }},
6563
6564         { &hf_netlogon_code,
6565                 { "Code", "netlogon.code", FT_UINT32, BASE_HEX,
6566                 NULL, 0x0, "Code", HFILL }},
6567
6568         { &hf_netlogon_level,
6569                 { "Level", "netlogon.level", FT_UINT32, BASE_DEC,
6570                 NULL, 0x0, "Which option of the union is represented here", HFILL }},
6571
6572         { &hf_netlogon_reference,
6573                 { "Reference", "netlogon.reference", FT_UINT32, BASE_DEC,
6574                 NULL, 0x0, "", HFILL }},
6575
6576         { &hf_netlogon_next_reference,
6577                 { "Next Reference", "netlogon.next_reference", FT_UINT32, BASE_DEC,
6578                 NULL, 0x0, "", HFILL }},
6579
6580         { &hf_netlogon_timestamp,
6581                 { "Timestamp", "netlogon.timestamp", FT_ABSOLUTE_TIME, BASE_NONE,
6582                 NULL, 0, "", HFILL }},
6583
6584         { &hf_netlogon_user_rid,
6585                 { "User RID", "netlogon.rid", FT_UINT32, BASE_DEC,
6586                 NULL, 0x0, "", HFILL }},
6587
6588         { &hf_netlogon_alias_rid,
6589                 { "Alias RID", "netlogon.alias_rid", FT_UINT32, BASE_DEC,
6590                 NULL, 0x0, "", HFILL }},
6591
6592         { &hf_netlogon_group_rid,
6593                 { "Group RID", "netlogon.group_rid", FT_UINT32, BASE_DEC,
6594                 NULL, 0x0, "", HFILL }},
6595
6596         { &hf_netlogon_num_rids,
6597                 { "Num RIDs", "netlogon.num_rids", FT_UINT32, BASE_DEC,
6598                 NULL, 0x0, "Number of RIDs", HFILL }},
6599
6600         { &hf_netlogon_num_controllers,
6601                 { "Num DCs", "netlogon.num_dc", FT_UINT32, BASE_DEC,
6602                 NULL, 0x0, "Number of domain controllers", HFILL }},
6603
6604         { &hf_netlogon_num_other_groups,
6605                 { "Num Other Groups", "netlogon.num_other_groups", FT_UINT32, BASE_DEC,
6606                 NULL, 0x0, "", HFILL }},
6607
6608         { &hf_netlogon_flags,
6609                 { "Flags", "netlogon.flags", FT_UINT32, BASE_HEX,
6610                 NULL, 0x0, "", HFILL }},
6611
6612         { &hf_netlogon_user_flags,
6613                 { "User Flags", "netlogon.user_flags", FT_UINT32, BASE_HEX,
6614                 NULL, 0x0, "", HFILL }},
6615
6616         { &hf_netlogon_auth_flags,
6617                 { "Auth Flags", "netlogon.auth_flags", FT_UINT32, BASE_HEX,
6618                 NULL, 0x0, "", HFILL }},
6619
6620         { &hf_netlogon_systemflags,
6621                 { "System Flags", "netlogon.system_flags", FT_UINT32, BASE_HEX,
6622                 NULL, 0x0, "", HFILL }},
6623
6624         { &hf_netlogon_database_id,
6625                 { "Database Id", "netlogon.database_id", FT_UINT32, BASE_DEC,
6626                 NULL, 0x0, "Database Id", HFILL }},
6627
6628         { &hf_netlogon_sync_context,
6629                 { "Sync Context", "netlogon.sync_context", FT_UINT32, BASE_DEC,
6630                 NULL, 0x0, "Sync Context", HFILL }},
6631
6632         { &hf_netlogon_max_size,
6633                 { "Max Size", "netlogon.max_size", FT_UINT32, BASE_DEC,
6634                 NULL, 0x0, "Max Size of database", HFILL }},
6635
6636         { &hf_netlogon_max_log_size,
6637                 { "Max Log Size", "netlogon.max_log_size", FT_UINT32, BASE_DEC,
6638                 NULL, 0x0, "Max Size of log", HFILL }},
6639
6640         { &hf_netlogon_pac_size,
6641                 { "Pac Size", "netlogon.pac.size", FT_UINT32, BASE_DEC,
6642                 NULL, 0x0, "Size of PacData in bytes", HFILL }},
6643
6644         { &hf_netlogon_auth_size,
6645                 { "Auth Size", "netlogon.auth.size", FT_UINT32, BASE_DEC,
6646                 NULL, 0x0, "Size of AuthData in bytes", HFILL }},
6647
6648         { &hf_netlogon_num_deltas,
6649                 { "Num Deltas", "netlogon.num_deltas", FT_UINT32, BASE_DEC,
6650                 NULL, 0x0, "Number of SAM Deltas in array", HFILL }},
6651
6652         { &hf_netlogon_num_trusts,
6653                 { "Num Trusts", "netlogon.num_trusts", FT_UINT32, BASE_DEC,
6654                 NULL, 0x0, "", HFILL }},
6655
6656         { &hf_netlogon_logon_attempts,
6657                 { "Logon Attempts", "netlogon.logon_attempts", FT_UINT32, BASE_DEC,
6658                 NULL, 0x0, "Number of logon attempts", HFILL }},
6659
6660         { &hf_netlogon_pagefilelimit,
6661                 { "Page File Limit", "netlogon.page_file_limit", FT_UINT32, BASE_DEC,
6662                 NULL, 0x0, "", HFILL }},
6663
6664         { &hf_netlogon_pagedpoollimit,
6665                 { "Paged Pool Limit", "netlogon.paged_pool_limit", FT_UINT32, BASE_DEC,
6666                 NULL, 0x0, "", HFILL }},
6667
6668         { &hf_netlogon_nonpagedpoollimit,
6669                 { "Non-Paged Pool Limit", "netlogon.nonpaged_pool_limit", FT_UINT32, BASE_DEC,
6670                 NULL, 0x0, "", HFILL }},
6671
6672         { &hf_netlogon_minworkingsetsize,
6673                 { "Min Working Set Size", "netlogon.min_working_set_size", FT_UINT32, BASE_DEC,
6674                 NULL, 0x0, "", HFILL }},
6675
6676         { &hf_netlogon_maxworkingsetsize,
6677                 { "Max Working Set Size", "netlogon.max_working_set_size", FT_UINT32, BASE_DEC,
6678                 NULL, 0x0, "", HFILL }},
6679
6680         { &hf_netlogon_serial_number,
6681                 { "Serial Number", "netlogon.serial_number", FT_UINT32, BASE_DEC,
6682                 NULL, 0x0, "", HFILL }},
6683
6684         { &hf_netlogon_neg_flags,
6685                 { "Neg Flags", "netlogon.neg_flags", FT_UINT32, BASE_HEX,
6686                 NULL, 0x0, "Negotiation Flags", HFILL }},
6687
6688         { &hf_netlogon_dc_flags,
6689                 { "Flags", "netlogon.dc.flags", FT_UINT32, BASE_HEX,
6690                 NULL, 0x0, "Domain Controller Flags", HFILL }},
6691
6692         { &hf_netlogon_dc_flags_pdc_flag,
6693                 { "PDC", "netlogon.dc.flags.pdc",
6694                   FT_BOOLEAN, 32, TFS(&dc_flags_pdc_flag), DS_PDC_FLAG,
6695                   "If this server is a PDC", HFILL }},
6696
6697         { &hf_netlogon_dc_flags_gc_flag,
6698                 { "GC", "netlogon.dc.flags.gc",
6699                   FT_BOOLEAN, 32, TFS(&dc_flags_gc_flag), DS_GC_FLAG,
6700                   "If this server is a GC", HFILL }},
6701
6702         { &hf_netlogon_dc_flags_ldap_flag,
6703                 { "LDAP", "netlogon.dc.flags.ldap",
6704                   FT_BOOLEAN, 32, TFS(&dc_flags_ldap_flag), DS_LDAP_FLAG,
6705                   "If this is an LDAP server", HFILL }},
6706
6707         { &hf_netlogon_dc_flags_ds_flag,
6708                 { "DS", "netlogon.dc.flags.ds",
6709                   FT_BOOLEAN, 32, TFS(&dc_flags_ds_flag), DS_DS_FLAG,
6710                   "If this server is a DS", HFILL }},
6711
6712         { &hf_netlogon_dc_flags_kdc_flag,
6713                 { "KDC", "netlogon.dc.flags.kdc",
6714                   FT_BOOLEAN, 32, TFS(&dc_flags_kdc_flag), DS_KDC_FLAG,
6715                   "If this is a KDC", HFILL }},
6716
6717         { &hf_netlogon_dc_flags_timeserv_flag,
6718                 { "Timeserv", "netlogon.dc.flags.timeserv",
6719                   FT_BOOLEAN, 32, TFS(&dc_flags_timeserv_flag), DS_TIMESERV_FLAG,
6720                   "If this server is a TimeServer", HFILL }},
6721
6722         { &hf_netlogon_dc_flags_closest_flag,
6723                 { "Closest", "netlogon.dc.flags.closest",
6724                   FT_BOOLEAN, 32, TFS(&dc_flags_closest_flag), DS_CLOSEST_FLAG,
6725                   "If this is the closest server", HFILL }},
6726
6727         { &hf_netlogon_dc_flags_writable_flag,
6728                 { "Writable", "netlogon.dc.flags.writable",
6729                   FT_BOOLEAN, 32, TFS(&dc_flags_writable_flag), DS_WRITABLE_FLAG,
6730                   "If this server can do updates to the database", HFILL }},
6731
6732         { &hf_netlogon_dc_flags_good_timeserv_flag,
6733                 { "Good Timeserv", "netlogon.dc.flags.good_timeserv",
6734                   FT_BOOLEAN, 32, TFS(&dc_flags_good_timeserv_flag), DS_GOOD_TIMESERV_FLAG,
6735                   "If this is a Good TimeServer", HFILL }},
6736
6737         { &hf_netlogon_dc_flags_ndnc_flag,
6738                 { "NDNC", "netlogon.dc.flags.ndnc",
6739                   FT_BOOLEAN, 32, TFS(&dc_flags_ndnc_flag), DS_NDNC_FLAG,
6740                   "If this is an NDNC server", HFILL }},
6741
6742         { &hf_netlogon_dc_flags_dns_controller_flag,
6743                 { "DNS Controller", "netlogon.dc.flags.dns_controller",
6744                   FT_BOOLEAN, 32, TFS(&dc_flags_dns_controller_flag), DS_DNS_CONTROLLER_FLAG,
6745                   "If this server is a DNS Controller", HFILL }},
6746
6747         { &hf_netlogon_dc_flags_dns_domain_flag,
6748                 { "DNS Domain", "netlogon.dc.flags.dns_domain",
6749                   FT_BOOLEAN, 32, TFS(&dc_flags_dns_domain_flag), DS_DNS_DOMAIN_FLAG,
6750                   "", HFILL }},
6751
6752         { &hf_netlogon_dc_flags_dns_forest_flag,
6753                 { "DNS Forest", "netlogon.dc.flags.dns_forest",
6754                   FT_BOOLEAN, 32, TFS(&dc_flags_dns_forest_flag), DS_DNS_FOREST_FLAG,
6755                   "", HFILL }},
6756
6757         { &hf_netlogon_get_dcname_request_flags,
6758                 { "Flags", "netlogon.get_dcname.request.flags", FT_UINT32, BASE_HEX,
6759                 NULL, 0x0, "Flags for DSGetDCName request", HFILL }},
6760
6761         { &hf_netlogon_get_dcname_request_flags_force_rediscovery,
6762                 { "Force Rediscovery", "netlogon.get_dcname.request.flags.force_rediscovery",
6763                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_force_rediscovery), DS_FORCE_REDISCOVERY,
6764                   "Whether to allow the server to returned cached information or not", HFILL }},
6765
6766         { &hf_netlogon_get_dcname_request_flags_directory_service_required,
6767                 { "DS Required", "netlogon.get_dcname.request.flags.ds_required",
6768                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_directory_service_required), DS_DIRECTORY_SERVICE_REQUIRED,
6769                   "Whether we require that the returned DC supports w2k or not", HFILL }},
6770
6771         { &hf_netlogon_get_dcname_request_flags_directory_service_preferred,
6772                 { "DS Preferred", "netlogon.get_dcname.request.flags.ds_preferred",
6773                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_directory_service_preferred), DS_DIRECTORY_SERVICE_PREFERRED,
6774                   "Whether we prefer the call to return a w2k server (if available)", HFILL }},
6775
6776         { &hf_netlogon_get_dcname_request_flags_gc_server_required,
6777                 { "GC Required", "netlogon.get_dcname.request.flags.gc_server_required",
6778                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_gc_server_required), DS_GC_SERVER_REQUIRED,
6779                   "Whether we require that the returned DC is a Global Catalog server", HFILL }},
6780
6781         { &hf_netlogon_get_dcname_request_flags_pdc_required,
6782                 { "PDC Required", "netlogon.get_dcname.request.flags.pdc_required",
6783                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_pdc_required), DS_PDC_REQUIRED,
6784                   "Whether we require the returned DC to be the PDC", HFILL }},
6785
6786         { &hf_netlogon_get_dcname_request_flags_background_only,
6787                 { "Background Only", "netlogon.get_dcname.request.flags.background_only",
6788                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_background_only), DS_BACKGROUND_ONLY,
6789                   "If we want cached data, even if it may have expired", HFILL }},
6790
6791         { &hf_netlogon_get_dcname_request_flags_ip_required,
6792                 { "IP Required", "netlogon.get_dcname.request.flags.ip_required",
6793                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_ip_required), DS_IP_REQUIRED,
6794                   "If we requre the IP of the DC in the reply", HFILL }},
6795
6796         { &hf_netlogon_get_dcname_request_flags_kdc_required,
6797                 { "KDC Required", "netlogon.get_dcname.request.flags.kdc_required",
6798                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_kdc_required), DS_KDC_REQUIRED,
6799                   "If we require that the returned server is a KDC", HFILL }},
6800
6801         { &hf_netlogon_get_dcname_request_flags_timeserv_required,
6802                 { "Timeserv Required", "netlogon.get_dcname.request.flags.timeserv_required",
6803                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_timeserv_required), DS_TIMESERV_REQUIRED,
6804                   "If we require the retruned server to be a NTP serveruns WindowsTimeServicer", HFILL }},
6805
6806         { &hf_netlogon_get_dcname_request_flags_writable_required,
6807                 { "Writable Required", "netlogon.get_dcname.request.flags.writable_required",
6808                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_writable_required), DS_WRITABLE_REQUIRED,
6809                   "If we require that the return server is writable", HFILL }},
6810
6811         { &hf_netlogon_get_dcname_request_flags_good_timeserv_preferred,
6812                 { "Timeserv Preferred", "netlogon.get_dcname.request.flags.good_timeserv_preferred",
6813                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_good_timeserv_preferred), DS_GOOD_TIMESERV_PREFERRED,
6814                   "If we prefer Windows Time Servers", HFILL }},
6815
6816         { &hf_netlogon_get_dcname_request_flags_avoid_self,
6817                 { "Avoid Self", "netlogon.get_dcname.request.flags.avoid_self",
6818                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_avoid_self), DS_AVOID_SELF,
6819                   "Return another DC than the one we ask", HFILL }},
6820
6821         { &hf_netlogon_get_dcname_request_flags_only_ldap_needed,
6822                 { "Only LDAP Needed", "netlogon.get_dcname.request.flags.only_ldap_needed",
6823                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_only_ldap_needed), DS_ONLY_LDAP_NEEDED,
6824                   "We just want an LDAP server, it does not have to be a DC", HFILL }},
6825
6826         { &hf_netlogon_get_dcname_request_flags_is_flat_name,
6827                 { "Is Flat Name", "netlogon.get_dcname.request.flags.is_flat_name",
6828                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_is_flat_name), DS_IS_FLAT_NAME,
6829                   "If the specified domain name is a NetBIOS name", HFILL }},
6830
6831         { &hf_netlogon_get_dcname_request_flags_is_dns_name,
6832                 { "Is DNS Name", "netlogon.get_dcname.request.flags.is_dns_name",
6833                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_is_dns_name), DS_IS_DNS_NAME,
6834                   "If the specified domain name is a DNS name", HFILL }},
6835
6836         { &hf_netlogon_get_dcname_request_flags_return_dns_name,
6837                 { "Return DNS Name", "netlogon.get_dcname.request.flags.return_dns_name",
6838                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_return_dns_name), DS_RETURN_DNS_NAME,
6839                   "Only return a DNS name (or an error)", HFILL }},
6840
6841         { &hf_netlogon_get_dcname_request_flags_return_flat_name,
6842                 { "Return Flat Name", "netlogon.get_dcname.request.flags.return_flat_name",
6843                   FT_BOOLEAN, 32, TFS(&get_dcname_request_flags_return_flat_name), DS_RETURN_FLAT_NAME,
6844                   "Only return a NetBIOS name (or an error)", HFILL }},
6845
6846         { &hf_netlogon_trust_attribs,
6847                 { "Trust Attributes", "netlogon.trust_attribs", FT_UINT32, BASE_HEX,
6848                 NULL, 0x0, "Trust Attributes", HFILL }},
6849
6850         { &hf_netlogon_trust_type,
6851                 { "Trust Type", "netlogon.trust_type", FT_UINT32, BASE_DEC,
6852                 VALS(trust_type_vals), 0x0, "Trust Type", HFILL }},
6853
6854         { &hf_netlogon_trust_flags,
6855                 { "Trust Flags", "netlogon.trust_flags", FT_UINT32, BASE_HEX,
6856                 NULL, 0x0, "Trust Flags", HFILL }},
6857
6858         { &hf_netlogon_trust_flags_inbound,
6859                 { "Inbound Trust", "netlogon.trust.flags.inbound",
6860                   FT_BOOLEAN, 32, TFS(&trust_inbound), DS_DOMAIN_DIRECT_INBOUND,
6861                   "Inbound trust. Whether the domain directly trusts the queried servers domain", HFILL }},
6862
6863         { &hf_netlogon_trust_flags_outbound,
6864                 { "Outbound Trust", "netlogon.trust.flags.outbound",
6865                   FT_BOOLEAN, 32, TFS(&trust_outbound), DS_DOMAIN_DIRECT_OUTBOUND,
6866                   "Outbound Trust. Whether the domain is directly trusted by the servers domain", HFILL }},
6867
6868         { &hf_netlogon_trust_flags_in_forest,
6869                 { "In Forest", "netlogon.trust.flags.in_forest",
6870                   FT_BOOLEAN, 32, TFS(&trust_in_forest), DS_DOMAIN_IN_FOREST,
6871                   "Whether this domain is a member of the same forest as the servers domain", HFILL }},
6872
6873         { &hf_netlogon_trust_flags_native_mode,
6874                 { "Native Mode", "netlogon.trust.flags.native_mode",
6875                   FT_BOOLEAN, 32, TFS(&trust_native_mode), DS_DOMAIN_NATIVE_MODE,
6876                   "Whether the domain is a w2k native mode domain or not", HFILL }},
6877
6878         { &hf_netlogon_trust_flags_primary,
6879                 { "Primary", "netlogon.trust.flags.primary",
6880                   FT_BOOLEAN, 32, TFS(&trust_primary), DS_DOMAIN_PRIMARY,
6881                   "Whether the domain is the primary domain for the queried server or not", HFILL }},
6882
6883         { &hf_netlogon_trust_flags_tree_root,
6884                 { "Tree Root", "netlogon.trust.flags.tree_root",
6885                   FT_BOOLEAN, 32, TFS(&trust_tree_root), DS_DOMAIN_TREE_ROOT,
6886                   "Whether the domain is the root of the tree for the queried server", HFILL }},
6887
6888         { &hf_netlogon_trust_parent_index,
6889                 { "Parent Index", "netlogon.parent_index", FT_UINT32, BASE_HEX,
6890                 NULL, 0x0, "Parent Index", HFILL }},
6891
6892         { &hf_netlogon_logon_time,
6893                 { "Logon Time", "netlogon.logon_time", FT_ABSOLUTE_TIME, BASE_NONE,
6894                 NULL, 0, "Time for last time this user logged on", HFILL }},
6895
6896         { &hf_netlogon_kickoff_time,
6897                 { "Kickoff Time", "netlogon.kickoff_time", FT_ABSOLUTE_TIME, BASE_NONE,
6898                 NULL, 0, "Time when this user will be kicked off", HFILL }},
6899
6900         { &hf_netlogon_logoff_time,
6901                 { "Logoff Time", "netlogon.logoff_time", FT_ABSOLUTE_TIME, BASE_NONE,
6902                 NULL, 0, "Time for last time this user logged off", HFILL }},
6903
6904         { &hf_netlogon_pwd_last_set_time,
6905                 { "PWD Last Set", "netlogon.pwd_last_set_time", FT_ABSOLUTE_TIME, BASE_NONE,
6906                 NULL, 0, "Last time this users password was changed", HFILL }},
6907
6908         { &hf_netlogon_pwd_can_change_time,
6909                 { "PWD Can Change", "netlogon.pwd_can_change_time", FT_ABSOLUTE_TIME, BASE_NONE,
6910                 NULL, 0, "When this users password may be changed", HFILL }},
6911
6912         { &hf_netlogon_pwd_must_change_time,
6913                 { "PWD Must Change", "netlogon.pwd_must_change_time", FT_ABSOLUTE_TIME, BASE_NONE,
6914                 NULL, 0, "When this users password must be changed", HFILL }},
6915
6916         { &hf_netlogon_domain_create_time,
6917                 { "Domain Create Time", "netlogon.domain_create_time", FT_ABSOLUTE_TIME, BASE_NONE,
6918                 NULL, 0, "Time when this domain was created", HFILL }},
6919
6920         { &hf_netlogon_domain_modify_time,
6921                 { "Domain Modify Time", "netlogon.domain_modify_time", FT_ABSOLUTE_TIME, BASE_NONE,
6922                 NULL, 0, "Time when this domain was last modified", HFILL }},
6923
6924         { &hf_netlogon_db_modify_time,
6925                 { "DB Modify Time", "netlogon.db_modify_time", FT_ABSOLUTE_TIME, BASE_NONE,
6926                 NULL, 0, "Time when last modified", HFILL }},
6927
6928         { &hf_netlogon_db_create_time,
6929                 { "DB Create Time", "netlogon.db_create_time", FT_ABSOLUTE_TIME, BASE_NONE,
6930                 NULL, 0, "Time when created", HFILL }},
6931
6932         { &hf_netlogon_cipher_current_set_time,
6933                 { "Cipher Current Set Time", "netlogon.cipher_current_set_time", FT_ABSOLUTE_TIME, BASE_NONE,
6934                 NULL, 0, "Time when current cipher was initiated", HFILL }},
6935
6936         { &hf_netlogon_cipher_old_set_time,
6937                 { "Cipher Old Set Time", "netlogon.cipher_old_set_time", FT_ABSOLUTE_TIME, BASE_NONE,
6938                 NULL, 0, "Time when previous cipher was initiated", HFILL }},
6939
6940         { &hf_netlogon_audit_retention_period,
6941                 { "Audit Retention Period", "netlogon.audit_retention_period", FT_RELATIVE_TIME, BASE_NONE,
6942                 NULL, 0, "Audit retention period", HFILL }},
6943
6944         { &hf_netlogon_guid,
6945                 { "GUID", "netlogon.guid", FT_STRING, BASE_NONE, 
6946                 NULL, 0x0, "GUID (uuid for groups?)", HFILL }},
6947
6948         { &hf_netlogon_timelimit,
6949                 { "Time Limit", "netlogon.time_limit", FT_RELATIVE_TIME, BASE_NONE,
6950                 NULL, 0, "", HFILL }},
6951
6952         /* Secure channel dissection */
6953
6954         { &hf_netlogon_secchan_bind_unknown1,
6955           { "Unknown1", "netlogon.secchan.bind.unknown1", FT_UINT32, BASE_HEX,
6956             NULL, 0x0, "", HFILL }},
6957
6958         { &hf_netlogon_secchan_bind_unknown2,
6959           { "Unknown2", "netlogon.secchan.bind.unknown2", FT_UINT32, BASE_HEX,
6960             NULL, 0x0, "", HFILL }},
6961
6962         { &hf_netlogon_secchan_domain,
6963           { "Domain", "netlogon.secchan.domain", FT_STRING, BASE_NONE,
6964             NULL, 0, "", HFILL }},
6965
6966         { &hf_netlogon_secchan_host,
6967           { "Host", "netlogon.secchan.host", FT_STRING, BASE_NONE,
6968             NULL, 0, "", HFILL }},
6969
6970         { &hf_netlogon_secchan_bind_ack_unknown1,
6971           { "Unknown1", "netlogon.secchan.bind_ack.unknown1", FT_UINT32, 
6972             BASE_HEX, NULL, 0x0, "", HFILL }},
6973
6974         { &hf_netlogon_secchan_bind_ack_unknown2,
6975           { "Unknown2", "netlogon.secchan.bind_ack.unknown2", FT_UINT32, 
6976             BASE_HEX, NULL, 0x0, "", HFILL }},
6977
6978         { &hf_netlogon_secchan_bind_ack_unknown3,
6979           { "Unknown3", "netlogon.secchan.bind_ack.unknown3", FT_UINT32, 
6980             BASE_HEX, NULL, 0x0, "", HFILL }},
6981
6982         { &hf_netlogon_secchan_verf,
6983           { "Secure Channel Verifier", "netlogon.secchan.verifier", FT_NONE, BASE_NONE, 
6984             NULL, 0x0, "Verifier", HFILL }},
6985
6986         { &hf_netlogon_secchan_verf_sig,
6987           { "Signature", "netlogon.secchan.sig", FT_BYTES, BASE_HEX, NULL, 
6988             0x0, "Signature", HFILL }}, 
6989
6990         { &hf_netlogon_secchan_verf_unk,
6991           { "Unknown", "netlogon.secchan.unk", FT_BYTES, BASE_HEX, NULL, 
6992           0x0, "Unknown", HFILL }}, 
6993
6994         { &hf_netlogon_secchan_verf_seq,
6995           { "Sequence No", "netlogon.secchan.seq", FT_BYTES, BASE_HEX, NULL, 
6996           0x0, "Sequence No", HFILL }}, 
6997
6998         { &hf_netlogon_secchan_verf_nonce,
6999           { "Nonce", "netlogon.secchan.nonce", FT_BYTES, BASE_HEX, NULL, 
7000           0x0, "Nonce", HFILL }}, 
7001         };
7002
7003         static gint *ett[] = {
7004                 &ett_dcerpc_netlogon,
7005                 &ett_CYPHER_VALUE,
7006                 &ett_QUOTA_LIMITS,
7007                 &ett_IDENTITY_INFO,
7008                 &ett_DELTA_ENUM,
7009                 &ett_UNICODE_MULTI,
7010                 &ett_DOMAIN_CONTROLLER_INFO,
7011                 &ett_UNICODE_STRING_512,
7012                 &ett_TYPE_50,
7013                 &ett_TYPE_52,
7014                 &ett_DELTA_ID_UNION,
7015                 &ett_TYPE_44,
7016                 &ett_DELTA_UNION,
7017                 &ett_LM_OWF_PASSWORD,
7018                 &ett_NT_OWF_PASSWORD,
7019                 &ett_GROUP_MEMBERSHIP,
7020                 &ett_DS_DOMAIN_TRUSTS,
7021                 &ett_BLOB,
7022                 &ett_DOMAIN_TRUST_INFO,
7023                 &ett_trust_flags,
7024                 &ett_get_dcname_request_flags,
7025                 &ett_dc_flags,
7026                 &ett_secchan_bind_creds,
7027                 &ett_secchan_bind_ack_creds,
7028                 &ett_secchan_verf
7029         };
7030
7031         proto_dcerpc_netlogon = proto_register_protocol(
7032                 "Microsoft Network Logon", "RPC_NETLOGON", "rpc_netlogon");
7033
7034         proto_register_field_array(proto_dcerpc_netlogon, hf,
7035                                    array_length(hf));
7036         proto_register_subtree_array(ett, array_length(ett));
7037 }
7038
7039 static dcerpc_auth_subdissector_fns secchan_auth_fns = {
7040         dissect_secchan_bind_creds,             /* Bind */
7041         dissect_secchan_bind_ack_creds,         /* Bind ACK */
7042         NULL,                                   /* AUTH3 */
7043         dissect_secchan_verf,                   /* Request verifier */
7044         dissect_secchan_verf,                   /* Response verifier */
7045         NULL,                                   /* Request data */
7046         NULL                                    /* Response data */
7047 };
7048
7049 void
7050 proto_reg_handoff_dcerpc_netlogon(void)
7051 {
7052         /* Register protocol as dcerpc */
7053
7054         dcerpc_init_uuid(proto_dcerpc_netlogon, ett_dcerpc_netlogon,
7055                          &uuid_dcerpc_netlogon, ver_dcerpc_netlogon,
7056                          dcerpc_netlogon_dissectors, hf_netlogon_opnum);
7057
7058         register_dcerpc_auth_subdissector(DCE_C_AUTHN_LEVEL_PKT_INTEGRITY,
7059                                           DCE_C_RPC_AUTHN_PROTOCOL_SEC_CHAN,
7060                                           &secchan_auth_fns);   
7061         register_dcerpc_auth_subdissector(DCE_C_AUTHN_LEVEL_PKT_PRIVACY,
7062                                           DCE_C_RPC_AUTHN_PROTOCOL_SEC_CHAN,
7063                                           &secchan_auth_fns);   
7064 }