Merge branch 'master' of ssh://git.samba.org/data/git/samba
[gd/samba/.git] / source3 / librpc / idl / nbt.idl
1 #include "idl_types.h"
2
3 /*
4    IDL structures for NBT operations
5
6    NBT is not traditionally encoded using IDL/NDR. This is a bit of an
7    experiment, and I may well switch us back to a more traditional
8    encoding if it doesn't work out
9 */
10
11 import "misc.idl", "security.idl", "svcctl.idl", "samr.idl";
12 [
13 helper("../libcli/nbt/libnbt.h")
14 ]
15 interface nbt
16 {
17         const int NBT_NAME_SERVICE_PORT  = 137;
18         const int NBT_DGRAM_SERVICE_PORT = 138;
19
20         typedef [bitmap16bit] bitmap {
21                 NBT_RCODE                   = 0x000F,
22                 NBT_FLAG_BROADCAST          = 0x0010,
23                 NBT_FLAG_RECURSION_AVAIL    = 0x0080,
24                 NBT_FLAG_RECURSION_DESIRED  = 0x0100,
25                 NBT_FLAG_TRUNCATION         = 0x0200,
26                 NBT_FLAG_AUTHORITIVE        = 0x0400,
27                 NBT_OPCODE                  = 0x7800,
28                 NBT_FLAG_REPLY              = 0x8000
29         } nbt_operation;
30
31         /* the opcodes are in the operation field, masked with
32            NBT_OPCODE */
33         typedef enum {
34                 NBT_OPCODE_QUERY          =  (0x0<<11),
35                 NBT_OPCODE_REGISTER       =  (0x5<<11),
36                 NBT_OPCODE_RELEASE        =  (0x6<<11),
37                 NBT_OPCODE_WACK           =  (0x7<<11),
38                 NBT_OPCODE_REFRESH        =  (0x8<<11),
39                 NBT_OPCODE_REFRESH2       =  (0x9<<11),
40                 NBT_OPCODE_MULTI_HOME_REG =  (0xf<<11)
41         } nbt_opcode;
42
43         /* rcode values */
44         typedef enum {
45                 NBT_RCODE_OK  = 0x0,
46                 NBT_RCODE_FMT = 0x1,
47                 NBT_RCODE_SVR = 0x2,
48                 NBT_RCODE_NAM = 0x3,
49                 NBT_RCODE_IMP = 0x4,
50                 NBT_RCODE_RFS = 0x5,
51                 NBT_RCODE_ACT = 0x6,
52                 NBT_RCODE_CFT = 0x7
53         } nbt_rcode;
54
55         /* we support any 8bit name type, but by defining the common
56            ones here we get better debug displays */
57         typedef [enum8bit] enum {
58                 NBT_NAME_CLIENT   = 0x00,
59                 NBT_NAME_MS       = 0x01,
60                 NBT_NAME_USER     = 0x03,
61                 NBT_NAME_SERVER   = 0x20,
62                 NBT_NAME_PDC      = 0x1B,
63                 NBT_NAME_LOGON    = 0x1C,
64                 NBT_NAME_MASTER   = 0x1D,
65                 NBT_NAME_BROWSER  = 0x1E
66         } nbt_name_type;
67
68         /* the ndr parser for nbt_name is separately defined in
69            nbtname.c (along with the parsers for nbt_string) */
70         typedef [public,nopull,nopush] struct {
71                 string        name;
72                 string        scope;
73                 nbt_name_type type;
74         } nbt_name;
75
76         typedef [public,enum16bit] enum {
77                 NBT_QCLASS_IP = 0x01
78         } nbt_qclass;
79
80         typedef [public,enum16bit] enum {
81                 NBT_QTYPE_ADDRESS     = 0x0001,
82                 NBT_QTYPE_NAMESERVICE = 0x0002,
83                 NBT_QTYPE_NULL        = 0x000A,
84                 NBT_QTYPE_NETBIOS     = 0x0020,
85                 NBT_QTYPE_STATUS      = 0x0021
86         } nbt_qtype;
87
88         typedef struct {
89                 nbt_name   name;
90                 nbt_qtype  question_type;
91                 nbt_qclass question_class;
92         } nbt_name_question;
93
94         /* these are the possible values of the NBT_NM_OWNER_TYPE
95            field */
96         typedef enum {
97                 NBT_NODE_B = 0x0000,
98                 NBT_NODE_P = 0x2000,
99                 NBT_NODE_M = 0x4000,
100                 NBT_NODE_H = 0x6000
101         } nbt_node_type;
102
103         typedef [bitmap16bit] bitmap {
104                 NBT_NM_PERMANENT        = 0x0200,
105                 NBT_NM_ACTIVE           = 0x0400,
106                 NBT_NM_CONFLICT         = 0x0800,
107                 NBT_NM_DEREGISTER       = 0x1000,
108                 NBT_NM_OWNER_TYPE       = 0x6000,
109                 NBT_NM_GROUP            = 0x8000
110         } nb_flags;
111
112         typedef struct {
113                 nb_flags nb_flags;
114                 ipv4address ipaddr;
115         } nbt_rdata_address;
116
117         typedef struct {
118                 uint16 length;
119                 nbt_rdata_address addresses[length/6];
120         } nbt_rdata_netbios;
121
122         typedef struct {
123                 uint8 unit_id[6];
124                 uint8 jumpers;
125                 uint8 test_result;
126                 uint16 version_number;
127                 uint16 period_of_statistics;
128                 uint16 number_of_crcs;
129                 uint16 number_alignment_errors;
130                 uint16 number_of_collisions;
131                 uint16 number_send_aborts;
132                 uint32 number_good_sends;
133                 uint32 number_good_receives;
134                 uint16 number_retransmits;
135                 uint16 number_no_resource_conditions;
136                 uint16 number_free_command_blocks;
137                 uint16 total_number_command_blocks;
138                 uint16 max_total_number_command_blocks;
139                 uint16 number_pending_sessions;
140                 uint16 max_number_pending_sessions;
141                 uint16 max_total_sessions_possible;
142                 uint16 session_data_packet_size;
143         } nbt_statistics;
144
145         typedef struct {
146                 [charset(DOS)] uint8 name[15];
147                 nbt_name_type type;
148                 nb_flags  nb_flags;
149         } nbt_status_name;
150
151         typedef struct {
152                 [value(num_names * 18 + 47)] uint16 length;
153                 uint8 num_names;
154                 nbt_status_name names[num_names];
155                 nbt_statistics  statistics;
156         } nbt_rdata_status;
157
158         typedef struct {
159                 uint16 length;
160                 uint8  data[length];
161         } nbt_rdata_data;
162
163         typedef [nodiscriminant,public] union {
164                 [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
165                 [case(NBT_QTYPE_STATUS)]  nbt_rdata_status status;
166                 [default]                 nbt_rdata_data   data;
167         } nbt_rdata;
168
169 /*
170  * this macro works around the problem
171  * that we need to use nbt_rdata_data
172  * together with NBT_QTYPE_NETBIOS
173  * for WACK replies
174  */
175 #define NBT_RES_REC_LEVEL(rr_type, rdata) (\
176         (((rr_type) == NBT_QTYPE_NETBIOS) && \
177         talloc_check_name(ndr, "struct ndr_push") && \
178         ((rdata).data.length == 2)) \
179         ? 0 : rr_type)
180
181         typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
182                 nbt_name   name;
183                 nbt_qtype  rr_type;
184                 nbt_qclass rr_class;
185                 uint32     ttl;
186                 [switch_is(NBT_RES_REC_LEVEL(rr_type, rdata))] nbt_rdata rdata;
187         } nbt_res_rec;
188
189         typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
190                 uint16            name_trn_id;
191                 nbt_operation     operation;
192                 uint16            qdcount;
193                 uint16            ancount;
194                 uint16            nscount;
195                 uint16            arcount;
196                 nbt_name_question questions[qdcount];
197                 nbt_res_rec       answers[ancount];
198                 nbt_res_rec       nsrecs[nscount];
199                 nbt_res_rec       additional[arcount];
200                 [flag(NDR_REMAINING)] DATA_BLOB padding;
201         } nbt_name_packet;
202
203
204         /*
205           NBT DGRAM packets (UDP/138)
206         */
207
208         typedef [enum8bit] enum {
209                 DGRAM_DIRECT_UNIQUE  = 0x10,
210                 DGRAM_DIRECT_GROUP   = 0x11,
211                 DGRAM_BCAST          = 0x12,
212                 DGRAM_ERROR          = 0x13,
213                 DGRAM_QUERY          = 0x14,
214                 DGRAM_QUERY_POSITIVE = 0x15,
215                 DGRAM_QUERY_NEGATIVE = 0x16
216         } dgram_msg_type;
217
218         typedef [bitmap8bit] bitmap {
219                 DGRAM_FLAG_MORE         = 0x01,
220                 DGRAM_FLAG_FIRST        = 0x02,
221                 DGRAM_FLAG_NODE_TYPE    = 0x0C
222         } dgram_flags;
223
224         typedef [enum8bit] enum {
225                 DGRAM_NODE_B    = 0x00,
226                 DGRAM_NODE_P    = 0x04,
227                 DGRAM_NODE_M    = 0x08,
228                 DGRAM_NODE_NBDD = 0x0C
229         } dgram_node_type;
230
231         /* a dgram_message is the main dgram body in general use */
232
233         /* the most common datagram type is a SMB_TRANSACTION
234            operation, where a SMB packet is used in the data section
235            of a dgram_message to hold a trans request, which in turn
236            holds a small command structure. It's a very strange beast
237            indeed. To make the code cleaner we define a basic SMB
238            packet in IDL here. This is not a general purpose SMB
239            packet, and won't be used in the core SMB client/server
240            code, but it does make working with these types of dgrams
241            easier */
242
243         const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON";
244         const string NBT_MAILSLOT_NTLOGON  = "\\MAILSLOT\\NET\\NTLOGON";
245         const string NBT_MAILSLOT_GETDC    = "\\MAILSLOT\\NET\\GETDC";
246         const string NBT_MAILSLOT_BROWSE   = "\\MAILSLOT\\BROWSE";
247
248         typedef [enum8bit] enum {
249                 SMB_TRANSACTION = 0x25
250         } smb_command;
251
252         typedef struct {
253                 [range(17,17),value(17)] uint8 wct;
254                 uint16                      total_param_count;
255                 uint16                      total_data_count;
256                 uint16                      max_param_count;
257                 uint16                      max_data_count;
258                 uint8                       max_setup_count;
259                 uint8                       pad;
260                 uint16                      trans_flags;
261                 uint32                      timeout;
262                 uint16                      reserved;
263                 uint16                      param_count;
264                 uint16                      param_offset;
265                 uint16                      data_count;
266                 uint16                      data_offset;
267                 [range(3,3),value(3)] uint8 setup_count;
268                 uint8                       pad2;
269                 uint16                      opcode;
270                 uint16                      priority;
271                 uint16                      _class;
272                 [value(strlen(mailslot_name)+1+data.length)]
273                       uint16                byte_count;
274                 astring                     mailslot_name;
275                 [flag(NDR_REMAINING)]       DATA_BLOB data;
276         } smb_trans_body;
277
278         typedef [nodiscriminant] union {
279                 [case(SMB_TRANSACTION)] smb_trans_body trans;
280         } smb_body;
281
282
283         typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct {
284                 smb_command                smb_command;
285                 uint8                      err_class;
286                 uint8                      pad;
287                 uint16                     err_code;
288                 uint8                      flags;
289                 uint16                     flags2;
290                 uint16                     pid_high;
291                 uint8                      signature[8];
292                 uint16                     reserved;
293                 uint16                     tid;
294                 uint16                     pid;
295                 uint16                     vuid;
296                 uint16                     mid;
297                 [switch_is(smb_command)]   smb_body body;
298         } dgram_smb_packet;
299
300         const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */
301
302         typedef [nodiscriminant] union {
303                 [case(DGRAM_SMB)] dgram_smb_packet smb;
304         } dgram_message_body;
305
306         typedef struct {
307                 uint16          length;
308                 uint16          offset;
309                 nbt_name        source_name;
310                 nbt_name        dest_name;
311                 uint32          dgram_body_type;
312                 [switch_is(dgram_body_type)] dgram_message_body body;
313         } dgram_message;
314
315         typedef [enum8bit] enum {
316                 DGRAM_ERROR_NAME_NOT_PRESENT = 0x82,
317                 DGRAM_ERROR_INVALID_SOURCE   = 0x83,
318                 DGRAM_ERROR_INVALID_DEST     = 0x84
319         } dgram_err_code;
320
321         typedef [nodiscriminant] union {
322                 [case(DGRAM_DIRECT_UNIQUE)]   dgram_message  msg;
323                 [case(DGRAM_DIRECT_GROUP)]    dgram_message  msg;
324                 [case(DGRAM_BCAST)]           dgram_message  msg;
325                 [case(DGRAM_ERROR)]           dgram_err_code error;
326                 [case(DGRAM_QUERY)]           nbt_name       dest_name;
327                 [case(DGRAM_QUERY_POSITIVE)]  nbt_name       dest_name;
328                 [case(DGRAM_QUERY_NEGATIVE)]  nbt_name       dest_name;
329         } dgram_data;
330
331         typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
332                 dgram_msg_type msg_type;
333                 dgram_flags    flags;
334                 uint16         dgram_id;
335                 ipv4address    src_addr;
336                 uint16         src_port;
337                 [switch_is(msg_type)] dgram_data data;
338         } nbt_dgram_packet;
339
340
341         /*******************************************/
342         /* \MAILSLOT\NET\NETLOGON mailslot requests */
343         typedef enum {
344                 NETLOGON_QUERY_FOR_PDC           = 0x7,
345                 NETLOGON_ANNOUNCE_UAS            = 0xa,
346                 NETLOGON_RESPONSE_FROM_PDC       = 0xc,
347                 NETLOGON_QUERY_FOR_PDC2          = 0x12,
348                 NETLOGON_RESPONSE_FROM_PDC2      = 0x17,
349                 NETLOGON_RESPONSE_FROM_PDC_USER  = 0x19
350         } nbt_netlogon_command;
351
352         typedef [flag(NDR_LITTLE_ENDIAN),bitmap32bit] bitmap {
353                 NETLOGON_VERSION_1                      = 0x00000001,
354                 NETLOGON_VERSION_5                      = 0x00000002,
355                 NETLOGON_VERSION_5EX                    = 0x00000004,
356                 NETLOGON_VERSION_5EX_WITH_IP            = 0x00000008,
357                 NETLOGON_VERSION_WITH_CLOSEST_SITE      = 0x00000010,
358                 NETLOGON_VERSION_AVOID_NT4_EMUL         = 0x01000000,
359                 NETLOGON_VERSION_PDC                    = 0x10000000,
360                 NETLOGON_VERSION_IP                     = 0x20000000,
361                 NETLOGON_VERSION_LOCAL                  = 0x40000000,
362                 NETLOGON_VERSION_GC                     = 0x80000000
363         } nbt_netlogon_version;
364
365         /* query for pdc request */
366         typedef struct {
367                 astring              computer_name;
368                 astring              mailslot_name;
369                 [flag(NDR_ALIGN2)]   DATA_BLOB _pad;
370                 nstring              unicode_name;
371                 nbt_netlogon_version nt_version;
372                 uint16               lmnt_token;
373                 uint16               lm20_token;
374         } nbt_netlogon_query_for_pdc;
375
376         /* query for pdc request - new style */
377         typedef struct {
378                 uint16               request_count;
379                 nstring              computer_name;
380                 nstring              user_name;
381                 astring              mailslot_name;
382                 uint32               unknown[2];
383                 nbt_netlogon_version nt_version;
384                 uint16               lmnt_token;
385                 uint16               lm20_token;
386         } nbt_netlogon_query_for_pdc2;
387
388         /* response from pdc */
389         typedef struct {
390                 astring pdc_name;
391                 [flag(NDR_ALIGN2)]   DATA_BLOB _pad;
392                 nstring              unicode_pdc_name;
393                 nstring              domain_name;
394                 nbt_netlogon_version nt_version;
395                 uint16               lmnt_token;
396                 uint16               lm20_token;
397         } nbt_netlogon_response_from_pdc;
398
399         typedef [bitmap32bit] bitmap {
400                 NBT_SERVER_PDC                          = 0x00000001,
401                 NBT_SERVER_GC                           = 0x00000004,
402                 NBT_SERVER_LDAP                         = 0x00000008,
403                 NBT_SERVER_DS                           = 0x00000010,
404                 NBT_SERVER_KDC                          = 0x00000020,
405                 NBT_SERVER_TIMESERV                     = 0x00000040,
406                 NBT_SERVER_CLOSEST                      = 0x00000080,
407                 NBT_SERVER_WRITABLE                     = 0x00000100,
408                 NBT_SERVER_GOOD_TIMESERV                = 0x00000200,
409                 NBT_SERVER_NDNC                         = 0x00000400,
410                 NBT_SERVER_SELECT_SECRET_DOMAIN_6       = 0x00000800,
411                 NBT_SERVER_FULL_SECRET_DOMAIN_6         = 0x00001000
412         } nbt_server_type;
413
414         typedef struct {
415                 uint32                  family;
416                 [flag(NDR_BIG_ENDIAN)]  ipv4address pdc_ip;
417                 [flag(NDR_REMAINING)]   DATA_BLOB remaining;
418         } nbt_dc_sock_addr;
419
420         /* response from pdc - type2 */
421         typedef struct {
422                 [flag(NDR_ALIGN4)]   DATA_BLOB _pad;
423                 nbt_server_type      server_type;
424                 GUID                 domain_uuid;
425                 nbt_string           forest;
426                 nbt_string           dns_domain;
427                 nbt_string           pdc_dns_name;
428                 nbt_string           domain;
429                 nbt_string           pdc_name;
430                 nbt_string           user_name;
431                 nbt_string           server_site;
432                 nbt_string           client_site;
433                 uint8                dc_sock_addr_size;
434                 [subcontext(0),subcontext_size(dc_sock_addr_size)] nbt_dc_sock_addr dc_sock_addr;
435                 nbt_netlogon_version nt_version;
436                 uint16               lmnt_token;
437                 uint16               lm20_token;
438         } nbt_netlogon_response_from_pdc2;
439
440         typedef enum netr_SamDatabaseID netr_SamDatabaseID;
441
442         /* announce change to UAS or SAM */
443         typedef struct {
444                 netr_SamDatabaseID   db_index;
445                 hyper                serial;
446                 NTTIME               timestamp;
447         } nbt_db_change;
448
449         /* used to announce SAM changes */
450         typedef struct {
451                 uint32           serial_lo;
452                 time_t           timestamp;
453                 uint32           pulse;
454                 uint32           random;
455                 astring          pdc_name;
456                 astring          domain;
457                 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
458                 nstring          unicode_pdc_name;
459                 nstring          unicode_domain;
460                 uint32           db_count;
461                 nbt_db_change    dbchange[db_count];
462                 [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
463                 [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
464                 nbt_netlogon_version nt_version;
465                 uint16           lmnt_token;
466                 uint16           lm20_token;
467         } nbt_netlogon_announce_uas;
468
469         typedef [nodiscriminant] union {
470                 [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
471                 [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2;
472                 [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas;
473                 [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
474                 [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2;
475                 [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
476         } nbt_netlogon_request;
477
478         typedef [flag(NDR_NOALIGN),public] struct {
479                 nbt_netlogon_command command;
480                 [switch_is(command)] nbt_netlogon_request req;
481         } nbt_netlogon_packet;
482
483         /*******************************************/
484         /* CLDAP netlogon response                 */
485
486         /* note that these structures are very similar to, but not
487            quite identical to, the netlogon structures above */
488
489         typedef struct {
490                 nbt_netlogon_command type;
491                 nstring              pdc_name;
492                 nstring              user_name;
493                 nstring              domain_name;
494                 [value(1)] nbt_netlogon_version nt_version;
495                 uint16               lmnt_token;
496                 uint16               lm20_token;
497         } nbt_cldap_netlogon_1;
498
499         typedef struct {
500                 nbt_netlogon_command type;
501                 nstring              pdc_name;
502                 nstring              user_name;
503                 nstring              domain_name;
504                 GUID                 domain_uuid;
505                 GUID                 unknown_uuid;
506                 nbt_string           forest;
507                 nbt_string           dns_domain;
508                 nbt_string           pdc_dns_name;
509                 ipv4address          pdc_ip;
510                 nbt_server_type      server_type;
511                 [value(3)] nbt_netlogon_version nt_version;
512                 uint16               lmnt_token;
513                 uint16               lm20_token;
514         } nbt_cldap_netlogon_3;
515
516         typedef [public] struct {
517                 nbt_netlogon_command type;
518                 uint16               sbz;
519                 nbt_server_type      server_type;
520                 GUID                 domain_uuid;
521                 nbt_string           forest;
522                 nbt_string           dns_domain;
523                 nbt_string           pdc_dns_name;
524                 nbt_string           domain;
525                 nbt_string           pdc_name;
526                 nbt_string           user_name;
527                 nbt_string           server_site;
528                 nbt_string           client_site;
529                 [value(5)] nbt_netlogon_version nt_version;
530                 uint16               lmnt_token;
531                 uint16               lm20_token;
532         } nbt_cldap_netlogon_5;
533
534         typedef struct {
535                 nbt_netlogon_command type;
536                 uint16               sbz;
537                 nbt_server_type      server_type;
538                 GUID                 domain_uuid;
539                 nbt_string           forest;
540                 nbt_string           dns_domain;
541                 nbt_string           pdc_dns_name;
542                 nbt_string           domain;
543                 nbt_string           pdc_name;
544                 nbt_string           user_name;
545                 nbt_string           server_site;
546                 nbt_string           client_site;
547                 uint8                dc_sock_addr_size;
548                 [subcontext(0),subcontext_size(dc_sock_addr_size)] nbt_dc_sock_addr dc_sock_addr;
549                 [value(13)] nbt_netlogon_version nt_version;
550                 uint16               lmnt_token;
551                 uint16               lm20_token;
552         } nbt_cldap_netlogon_13;
553
554         typedef [public] struct {
555                 nbt_netlogon_command type;
556                 uint16               sbz;
557                 nbt_server_type      server_type;
558                 GUID                 domain_uuid;
559                 nbt_string           forest;
560                 nbt_string           dns_domain;
561                 nbt_string           pdc_dns_name;
562                 nbt_string           domain;
563                 nbt_string           pdc_name;
564                 nbt_string           user_name;
565                 nbt_string           server_site;
566                 nbt_string           client_site;
567                 nbt_string           next_closest_site;
568                 [value(15)] nbt_netlogon_version nt_version;
569                 uint16               lmnt_token;
570                 uint16               lm20_token;
571         } nbt_cldap_netlogon_15;
572
573         typedef [public] struct {
574                 nbt_netlogon_command type;
575                 uint16               sbz;
576                 nbt_server_type      server_type;
577                 GUID                 domain_uuid;
578                 nbt_string           forest;
579                 nbt_string           dns_domain;
580                 nbt_string           pdc_dns_name;
581                 nbt_string           domain;
582                 nbt_string           pdc_name;
583                 nbt_string           user_name;
584                 nbt_string           server_site;
585                 nbt_string           client_site;
586                 uint8                dc_sock_addr_size;
587                 [subcontext(0),subcontext_size(dc_sock_addr_size)] nbt_dc_sock_addr dc_sock_addr;
588                 nbt_string           next_closest_site;
589                 [value(29)] nbt_netlogon_version nt_version;
590                 uint16               lmnt_token;
591                 uint16               lm20_token;
592         } nbt_cldap_netlogon_29;
593
594         typedef [flag(NDR_NOALIGN),public,nodiscriminant] union {
595                 [case(0)]  nbt_cldap_netlogon_1 logon1;
596                 [case(1)]  nbt_cldap_netlogon_1 logon1;
597                 [case(2)]  nbt_cldap_netlogon_3 logon3;
598                 [case(3)]  nbt_cldap_netlogon_3 logon3;
599                 [case(4)]  nbt_cldap_netlogon_5 logon5;
600                 [case(5)]  nbt_cldap_netlogon_5 logon5;
601                 [case(6)]  nbt_cldap_netlogon_5 logon5;
602                 [case(7)]  nbt_cldap_netlogon_5 logon5;
603                 [case(8)]  nbt_cldap_netlogon_13 logon13;
604                 [case(9)]  nbt_cldap_netlogon_13 logon13;
605                 [case(10)] nbt_cldap_netlogon_13 logon13;
606                 [case(11)] nbt_cldap_netlogon_13 logon13;
607                 [case(12)] nbt_cldap_netlogon_13 logon13;
608                 [case(13)] nbt_cldap_netlogon_13 logon13;
609                 [case(14)] nbt_cldap_netlogon_13 logon13;
610                 [case(15)] nbt_cldap_netlogon_13 logon13;
611                 [case(16)] nbt_cldap_netlogon_1 logon1;
612                 [case(17)] nbt_cldap_netlogon_1 logon1;
613                 [case(18)] nbt_cldap_netlogon_3 logon3;
614                 [case(19)] nbt_cldap_netlogon_3 logon3;
615                 [case(20)] nbt_cldap_netlogon_15 logon15;
616                 [case(21)] nbt_cldap_netlogon_15 logon15;
617                 [case(22)] nbt_cldap_netlogon_15 logon15;
618                 [case(23)] nbt_cldap_netlogon_15 logon15;
619                 [case(24)] nbt_cldap_netlogon_15 logon15;
620                 [case(25)] nbt_cldap_netlogon_15 logon15;
621                 [case(26)] nbt_cldap_netlogon_15 logon15;
622                 [case(27)] nbt_cldap_netlogon_15 logon15;
623                 [case(28)] nbt_cldap_netlogon_15 logon15;
624                 [case(29)] nbt_cldap_netlogon_29 logon29;
625                 [case(30)] nbt_cldap_netlogon_29 logon29;
626                 [case(31)] nbt_cldap_netlogon_29 logon29;
627         } nbt_cldap_netlogon;
628
629         /*******************************************/
630         /* \MAILSLOT\NET\NTLOGON mailslot requests */
631         typedef enum {
632                 NTLOGON_SAM_LOGON         = 0x12,
633                 NTLOGON_SAM_LOGON_REPLY   = 0x13,
634                 NTLOGON_SAM_LOGON_REPLY15 = 0x15,
635                 NTLOGON_RESPONSE_FROM_PDC2 = 0x17
636         } nbt_ntlogon_command;
637
638         typedef struct {
639                 uint16               request_count;
640                 nstring              computer_name;
641                 nstring              user_name;
642                 astring              mailslot_name;
643                 samr_AcctFlags       acct_control;
644                 [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
645                 [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
646                 nbt_netlogon_version nt_version;
647                 uint16               lmnt_token;
648                 uint16               lm20_token;
649         } nbt_ntlogon_sam_logon;
650
651         typedef struct {
652                 nstring              server;
653                 nstring              user_name;
654                 nstring              domain;
655                 nbt_netlogon_version nt_version;
656                 uint16               lmnt_token;
657                 uint16               lm20_token;
658         } nbt_ntlogon_sam_logon_reply;
659
660         typedef [nodiscriminant] union {
661                 [case(NTLOGON_SAM_LOGON)]       nbt_ntlogon_sam_logon logon;
662                 [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply;
663                 [case(NTLOGON_SAM_LOGON_REPLY15)] nbt_ntlogon_sam_logon_reply reply;
664                 [case(NTLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 reply2;
665         } nbt_ntlogon_request;
666
667         typedef [flag(NDR_NOALIGN),public] struct {
668                 nbt_ntlogon_command command;
669                 [switch_is(command)] nbt_ntlogon_request req;
670         } nbt_ntlogon_packet;
671
672         /********************************************************/
673         /* \MAILSLOT\BROWSE mailslot requests                   */
674         /* for details see http://ubiqx.org/cifs/Browsing.html  */
675         /********************************************************/
676         typedef bitmap svcctl_ServerType svcctl_ServerType;
677
678         typedef [enum8bit] enum {
679                 HostAnnouncement        = 1,
680                 AnnouncementRequest     = 2,
681                 Election                = 8,
682                 GetBackupListReq        = 9,
683                 GetBackupListResp       = 10,
684                 BecomeBackup            = 11,
685                 DomainAnnouncement      = 12,
686                 MasterAnnouncement      = 13,
687                 ResetBrowserState       = 14,
688                 LocalMasterAnnouncement = 15
689         } nbt_browse_opcode;
690
691         typedef struct {
692                 uint8 UpdateCount;
693                 uint32 Periodicity;
694                 [charset(DOS)] uint8 ServerName[16];
695                 uint8 OSMajor;
696                 uint8 OSMinor;
697                 svcctl_ServerType ServerType;
698                 uint8 BroMajorVer;
699                 uint8 BroMinorVer;
700                 uint16 Signature;
701                 astring Comment;
702         } nbt_browse_host_announcement;
703
704         typedef struct {
705                 uint8 Unused;
706                 astring ResponseName;
707         } nbt_browse_announcement_request;
708
709         typedef struct {
710                 uint8 Version;
711                 uint32 Criteria;
712                 uint32 UpTime; /* In milliseconds */
713                 uint32 Reserved; /* Must be zero */
714                 astring ServerName;
715         } nbt_browse_election_request;
716
717         typedef struct {
718                 uint8 ReqCount;
719                 uint32 Token;
720         } nbt_browse_backup_list_request;
721
722         typedef struct {
723                 uint8 BackupCount;
724                 uint32 Token;
725                 nbt_name BackupServerList[BackupCount];/* TODO: this is wrong */
726         } nbt_browse_backup_list_response;
727
728         typedef struct {
729                 astring BrowserName;
730         } nbt_browse_become_backup;
731
732         typedef struct {
733                 uint8 UpdateCount;
734                 uint32 Periodicity;
735                 [charset(DOS)] uint8 ServerName[16];
736                 uint8 OSMajor;
737                 uint8 OSMinor;
738                 svcctl_ServerType ServerType;
739                 uint32 MysteriousField;
740                 astring Comment;
741         } nbt_browse_domain_announcement;
742
743         typedef struct {
744                 astring ServerName;
745         } nbt_browse_master_announcement;
746
747         typedef struct {
748                 uint8 Command;
749         } nbt_browse_reset_state;
750
751         typedef struct {
752                 uint8 UpdateCount;
753                 uint32 Periodicity;
754                 [charset(DOS)] uint8 ServerName[16];
755                 uint8 OSMajor;
756                 uint8 OSMinor;
757                 svcctl_ServerType ServerType;
758                 uint8 BroMajorVer;
759                 uint8 BroMinorVer;
760                 uint16 Signature;
761                 astring Comment;
762         } nbt_browse_local_master_announcement;
763
764         typedef [nodiscriminant] union {
765                 [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement;
766                 [case(AnnouncementRequest)] nbt_browse_announcement_request announcement_request;
767                 [case(Election)] nbt_browse_election_request election_request;
768                 [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request;
769                 [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response;
770                 [case(BecomeBackup)] nbt_browse_become_backup become_backup;
771                 [case(DomainAnnouncement)] nbt_browse_domain_announcement domain_announcement;
772                 [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement;
773                 [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state;
774                 [case(LocalMasterAnnouncement)] nbt_browse_local_master_announcement local_master_announcement;
775         } nbt_browse_payload;
776
777         typedef [public,flag(NDR_NOALIGN)] struct {
778                 nbt_browse_opcode opcode;
779                 [switch_is(opcode)] nbt_browse_payload payload;
780         } nbt_browse_packet;
781 }