4 IDL structures for NBT operations
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
16 const int NBT_NAME_SERVICE_PORT = 137;
17 const int NBT_DGRAM_SERVICE_PORT = 138;
19 typedef [bitmap16bit] bitmap {
21 NBT_FLAG_BROADCAST = 0x0010,
22 NBT_FLAG_RECURSION_AVAIL = 0x0080,
23 NBT_FLAG_RECURSION_DESIRED = 0x0100,
24 NBT_FLAG_TRUNCATION = 0x0200,
25 NBT_FLAG_AUTHORITIVE = 0x0400,
27 NBT_FLAG_REPLY = 0x8000
30 /* the opcodes are in the operation field, masked with
33 NBT_OPCODE_QUERY = (0x0<<11),
34 NBT_OPCODE_REGISTER = (0x5<<11),
35 NBT_OPCODE_RELEASE = (0x6<<11),
36 NBT_OPCODE_WACK = (0x7<<11),
37 NBT_OPCODE_REFRESH = (0x8<<11),
38 NBT_OPCODE_REFRESH2 = (0x9<<11),
39 NBT_OPCODE_MULTI_HOME_REG = (0xf<<11)
54 /* we support any 8bit name type, but by defining the common
55 ones here we get better debug displays */
56 typedef [enum8bit] enum {
57 NBT_NAME_CLIENT = 0x00,
60 NBT_NAME_SERVER = 0x20,
62 NBT_NAME_LOGON = 0x1C,
63 NBT_NAME_MASTER = 0x1D,
64 NBT_NAME_BROWSER = 0x1E
67 /* the ndr parser for nbt_name is separately defined in
68 nbtname.c (along with the parsers for nbt_string) */
69 typedef [public,nopull,nopush] struct {
75 typedef [enum16bit] enum {
79 typedef [enum16bit] enum {
80 NBT_QTYPE_ADDRESS = 0x0001,
81 NBT_QTYPE_NAMESERVICE = 0x0002,
82 NBT_QTYPE_NULL = 0x000A,
83 NBT_QTYPE_NETBIOS = 0x0020,
84 NBT_QTYPE_STATUS = 0x0021
89 nbt_qtype question_type;
90 nbt_qclass question_class;
93 /* these are the possible values of the NBT_NM_OWNER_TYPE
102 typedef [bitmap16bit] bitmap {
103 NBT_NM_PERMANENT = 0x0200,
104 NBT_NM_ACTIVE = 0x0400,
105 NBT_NM_CONFLICT = 0x0800,
106 NBT_NM_DEREGISTER = 0x1000,
107 NBT_NM_OWNER_TYPE = 0x6000,
108 NBT_NM_GROUP = 0x8000
118 nbt_rdata_address addresses[length/6];
125 uint16 version_number;
126 uint16 period_of_statistics;
127 uint16 number_of_crcs;
128 uint16 number_alignment_errors;
129 uint16 number_of_collisions;
130 uint16 number_send_aborts;
131 uint32 number_good_sends;
132 uint32 number_good_receives;
133 uint16 number_retransmits;
134 uint16 number_no_resource_conditions;
135 uint16 number_free_command_blocks;
136 uint16 total_number_command_blocks;
137 uint16 max_total_number_command_blocks;
138 uint16 number_pending_sessions;
139 uint16 max_number_pending_sessions;
140 uint16 max_total_sessions_possible;
141 uint16 session_data_packet_size;
151 [value(num_names * 18 + 47)] uint16 length;
153 nbt_status_name names[num_names];
154 nbt_statistics statistics;
162 typedef [nodiscriminant] union {
163 [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
164 [case(NBT_QTYPE_STATUS)] nbt_rdata_status status;
165 [default] nbt_rdata_data data;
168 typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
173 [switch_is(rr_type)] nbt_rdata rdata;
176 typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
178 nbt_operation operation;
183 nbt_name_question questions[qdcount];
184 nbt_res_rec answers[ancount];
185 nbt_res_rec nsrecs[nscount];
186 nbt_res_rec additional[arcount];
187 [flag(NDR_REMAINING)] DATA_BLOB padding;
192 NBT DGRAM packets (UDP/138)
195 typedef [enum8bit] enum {
196 DGRAM_DIRECT_UNIQUE = 0x10,
197 DGRAM_DIRECT_GROUP = 0x11,
201 DGRAM_QUERY_POSITIVE = 0x15,
202 DGRAM_QUERY_NEGATIVE = 0x16
205 typedef [bitmap8bit] bitmap {
206 DGRAM_FLAG_MORE = 0x01,
207 DGRAM_FLAG_FIRST = 0x02,
208 DGRAM_FLAG_NODE_TYPE = 0x0C
211 typedef [enum8bit] enum {
215 DGRAM_NODE_NBDD = 0x0C
218 /* a dgram_message is the main dgram body in general use */
220 /* the most common datagram type is a SMB_TRANSACTION
221 operation, where a SMB packet is used in the data section
222 of a dgram_message to hold a trans request, which in turn
223 holds a small command structure. It's a very strange beast
224 indeed. To make the code cleaner we define a basic SMB
225 packet in IDL here. This is not a general purpose SMB
226 packet, and won't be used in the core SMB client/server
227 code, but it does make working with these types of dgrams
230 const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON";
231 const string NBT_MAILSLOT_NTLOGON = "\\MAILSLOT\\NET\\NTLOGON";
232 const string NBT_MAILSLOT_GETDC = "\\MAILSLOT\\GETDC";
233 const string NBT_MAILSLOT_BROWSE = "\\MAILSLOT\\BROWSE";
235 typedef [enum8bit] enum {
236 SMB_TRANSACTION = 0x25
240 [range(17,17),value(17)] uint8 wct;
241 uint16 total_param_count;
242 uint16 total_data_count;
243 uint16 max_param_count;
244 uint16 max_data_count;
245 uint8 max_setup_count;
254 [range(3,3),value(3)] uint8 setup_count;
259 [value(strlen(mailslot_name)+1+r->data.length)]
261 astring mailslot_name;
262 [flag(NDR_REMAINING)] DATA_BLOB data;
265 typedef [nodiscriminant] union {
266 [case(SMB_TRANSACTION)] smb_trans_body trans;
270 typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct {
271 smb_command smb_command;
284 [switch_is(smb_command)] smb_body body;
287 const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */
289 typedef [nodiscriminant] union {
290 [case(DGRAM_SMB)] dgram_smb_packet smb;
291 } dgram_message_body;
296 nbt_name source_name;
298 uint32 dgram_body_type;
299 [switch_is(dgram_body_type)] dgram_message_body body;
302 typedef [enum8bit] enum {
303 DGRAM_ERROR_NAME_NOT_PRESENT = 0x82,
304 DGRAM_ERROR_INVALID_SOURCE = 0x83,
305 DGRAM_ERROR_INVALID_DEST = 0x84
308 typedef [nodiscriminant] union {
309 [case(DGRAM_DIRECT_UNIQUE)] dgram_message msg;
310 [case(DGRAM_DIRECT_GROUP)] dgram_message msg;
311 [case(DGRAM_BCAST)] dgram_message msg;
312 [case(DGRAM_ERROR)] dgram_err_code error;
313 [case(DGRAM_QUERY)] nbt_name dest_name;
314 [case(DGRAM_QUERY_POSITIVE)] nbt_name dest_name;
315 [case(DGRAM_QUERY_NEGATIVE)] nbt_name dest_name;
318 typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
319 dgram_msg_type msg_type;
322 ipv4address src_addr;
324 [switch_is(msg_type)] dgram_data data;
328 /*******************************************/
329 /* \MAILSLOT\NET\NETLOGON mailslot requests */
331 NETLOGON_QUERY_FOR_PDC = 0x7,
332 NETLOGON_ANNOUNCE_UAS = 0xa,
333 NETLOGON_RESPONSE_FROM_PDC = 0xc,
334 NETLOGON_QUERY_FOR_PDC2 = 0x12,
335 NETLOGON_RESPONSE_FROM_PDC2 = 0x17,
336 NETLOGON_RESPONSE_FROM_PDC_USER = 0x19
337 } nbt_netlogon_command;
339 /* query for pdc request */
341 astring computer_name;
342 astring mailslot_name;
343 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
344 nstring unicode_name;
348 } nbt_netlogon_query_for_pdc;
350 /* query for pdc request - new style */
352 uint16 request_count;
353 nstring computer_name;
355 astring mailslot_name;
360 } nbt_netlogon_query_for_pdc2;
362 /* response from pdc */
365 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
366 nstring unicode_pdc_name;
371 } nbt_netlogon_response_from_pdc;
373 typedef [bitmap32bit] bitmap {
374 NBT_SERVER_PDC = 0x00000001,
375 NBT_SERVER_GC = 0x00000004,
376 NBT_SERVER_LDAP = 0x00000008,
377 NBT_SERVER_DS = 0x00000010,
378 NBT_SERVER_KDC = 0x00000020,
379 NBT_SERVER_TIMESERV = 0x00000040,
380 NBT_SERVER_CLOSEST = 0x00000080,
381 NBT_SERVER_WRITABLE = 0x00000100,
382 NBT_SERVER_GOOD_TIMESERV = 0x00000200
385 /* response from pdc - type2 */
387 [flag(NDR_ALIGN4)] DATA_BLOB _pad;
388 nbt_server_type server_type;
391 nbt_string dns_domain;
392 nbt_string pdc_dns_name;
395 nbt_string user_name;
396 nbt_string site_name;
397 nbt_string site_name2;
400 [flag(NDR_BIG_ENDIAN)]
406 } nbt_netlogon_response_from_pdc2;
408 declare enum netr_SamDatabaseID;
410 /* announce change to UAS or SAM */
412 netr_SamDatabaseID db_index;
417 /* used to announce SAM changes */
425 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
426 nstring unicode_pdc_name;
427 nstring unicode_domain;
429 nbt_db_change dbchange[db_count];
430 [value(ndr_size_dom_sid(&sid))] uint32 sid_size;
431 [flag(NDR_ALIGN4)] DATA_BLOB _pad2;
436 } nbt_netlogon_announce_uas;
438 typedef [nodiscriminant] union {
439 [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
440 [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2;
441 [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas;
442 [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
443 [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2;
444 [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
445 } nbt_netlogon_request;
447 typedef [flag(NDR_NOALIGN),public] struct {
448 nbt_netlogon_command command;
449 [switch_is(command)] nbt_netlogon_request req;
450 } nbt_netlogon_packet;
452 /*******************************************/
453 /* CLDAP netlogon response */
455 /* note that these structures are very similar to, but not
456 quite identical to, the netlogon structures above */
463 [value(1)] uint32 nt_version;
466 } nbt_cldap_netlogon_1;
476 nbt_string dns_domain;
477 nbt_string pdc_dns_name;
479 nbt_server_type server_type;
480 [value(3)] uint32 nt_version;
483 } nbt_cldap_netlogon_3;
487 nbt_server_type server_type;
490 nbt_string dns_domain;
491 nbt_string pdc_dns_name;
494 nbt_string user_name;
495 nbt_string site_name;
496 nbt_string site_name2;
497 [value(5)] uint32 nt_version;
500 } nbt_cldap_netlogon_5;
504 nbt_server_type server_type;
507 nbt_string dns_domain;
508 nbt_string pdc_dns_name;
511 nbt_string user_name;
512 nbt_string site_name;
513 nbt_string site_name2;
516 [flag(NDR_BIG_ENDIAN)]
519 [value(13)] uint32 nt_version;
522 } nbt_cldap_netlogon_13;
524 typedef [flag(NDR_NOALIGN),public,nodiscriminant] union {
525 [case(0)] nbt_cldap_netlogon_1 logon1;
526 [case(1)] nbt_cldap_netlogon_1 logon1;
527 [case(2)] nbt_cldap_netlogon_3 logon3;
528 [case(3)] nbt_cldap_netlogon_3 logon3;
529 [case(4)] nbt_cldap_netlogon_5 logon5;
530 [case(5)] nbt_cldap_netlogon_5 logon5;
531 [case(6)] nbt_cldap_netlogon_5 logon5;
532 [case(7)] nbt_cldap_netlogon_5 logon5;
533 [default] nbt_cldap_netlogon_13 logon13;
534 } nbt_cldap_netlogon;
536 /*******************************************/
537 /* \MAILSLOT\NET\NTLOGON mailslot requests */
539 NTLOGON_SAM_LOGON = 0x12,
540 NTLOGON_SAM_LOGON_REPLY = 0x13
541 } nbt_ntlogon_command;
544 uint16 request_count;
545 nstring computer_name;
547 astring mailslot_name;
549 [value(ndr_size_dom_sid(&sid))] uint32 sid_size;
550 [flag(NDR_ALIGN4)] DATA_BLOB _pad;
555 } nbt_ntlogon_sam_logon;
564 } nbt_ntlogon_sam_logon_reply;
566 typedef [nodiscriminant] union {
567 [case(NTLOGON_SAM_LOGON)] nbt_ntlogon_sam_logon logon;
568 [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply;
569 } nbt_ntlogon_request;
571 typedef [flag(NDR_NOALIGN),public] struct {
572 nbt_ntlogon_command command;
573 [switch_is(command)] nbt_ntlogon_request req;
574 } nbt_ntlogon_packet;
576 /*******************************************/
577 /* \MAILSLOT\BROWSE mailslot requests */
580 HostAnnouncement = 1,
581 AnnouncementRequest = 2,
583 GetBackupListReq = 9,
584 GetBackupListResp = 10,
586 DomainAnnouncement = 12,
587 MasterAnnouncement = 13,
588 ResetBrowserState = 14,
589 LocalMasterAnnouncement = 15
600 } nbt_browse_host_announcement;
604 astring ResponseComputerName;
605 } nbt_browse_request_announcement;
610 } nbt_browse_backup_list_request;
615 nbt_name BackupServerList[count];
616 } nbt_browse_backup_list_response;
619 astring BrowserToPromote;
620 } nbt_browse_become_backup;
625 uint32 time_up; /* In milliseconds */
626 uint32 reserved; /* Must be zero */
628 } nbt_browse_election_request;
632 } nbt_browse_reset_state;
635 astring MasterBrowserServerName;
636 } nbt_browse_master_announcement;
638 typedef [nodiscriminant] union {
639 [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement;
640 [case(AnnouncementRequest)] nbt_browse_request_announcement announcement_request;
641 [case(Election)] nbt_browse_election_request election_request;
642 [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request;
643 [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response;
644 [case(BecomeBackup)] nbt_browse_become_backup become_backup;
645 [case(DomainAnnouncement)] nbt_browse_master_announcement domain_announcement;
646 [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement;
647 [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state;
648 [case(LocalMasterAnnouncement)] nbt_browse_master_announcement local_master_announcement;
649 } nbt_browse_payload;
651 typedef [public,flag(NDR_NOALIGN)] struct {
652 nbt_browse_opcode opcode;
653 nbt_browse_payload payload;