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
69 typedef [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(r->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_GETDC = "\\MAILSLOT\\GETDC";
232 const string NBT_MAILSLOT_BROWSE = "\\MAILSLOT\\BROWSE";
234 typedef [enum8bit] enum {
235 SMB_TRANSACTION = 0x25
239 [range(17,17),value(17)] uint8 wct;
240 uint16 total_param_count;
241 uint16 total_data_count;
242 uint16 max_param_count;
243 uint16 max_data_count;
244 uint8 max_setup_count;
253 [range(3,3),value(3)] uint8 setup_count;
258 [value(strlen(r->mailslot_name)+1+r->data.length)]
260 astring mailslot_name;
261 [flag(NDR_REMAINING)] DATA_BLOB data;
264 typedef [nodiscriminant] union {
265 [case(SMB_TRANSACTION)] smb_trans_body trans;
269 typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct {
270 smb_command smb_command;
283 [switch_is(smb_command)] smb_body body;
286 typedef [v1_enum] enum {
287 DGRAM_SMB = 0xff534d42 /* 0xffSMB */
290 typedef [nodiscriminant] union {
291 [case(DGRAM_SMB)] dgram_smb_packet smb;
292 } dgram_message_body;
297 nbt_name source_name;
299 dgram_body_type dgram_body_type;
300 [switch_is(dgram_body_type)] dgram_message_body body;
303 typedef [enum8bit] enum {
304 DGRAM_ERROR_NAME_NOT_PRESENT = 0x82,
305 DGRAM_ERROR_INVALID_SOURCE = 0x83,
306 DGRAM_ERROR_INVALID_DEST = 0x84
309 typedef [nodiscriminant] union {
310 [case(DGRAM_DIRECT_UNIQUE)] dgram_message msg;
311 [case(DGRAM_DIRECT_GROUP)] dgram_message msg;
312 [case(DGRAM_BCAST)] dgram_message msg;
313 [case(DGRAM_ERROR)] dgram_err_code error;
314 [case(DGRAM_QUERY)] nbt_name dest_name;
315 [case(DGRAM_QUERY_POSITIVE)] nbt_name dest_name;
316 [case(DGRAM_QUERY_NEGATIVE)] nbt_name dest_name;
319 typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
320 dgram_msg_type msg_type;
325 [switch_is(msg_type)] dgram_data data;
329 /* \MAILSLOT\NET\NETLOGON mailslot requests */
331 NETLOGON_QUERY_FOR_PDC = 0x7,
332 NETLOGON_ANNOUNCE_UAS = 0xa,
333 NETLOGON_RESPONSE_FROM_PDC = 0xc
334 } nbt_netlogon_command;
336 /* query for pdc request */
338 astring computer_name;
339 astring mailslot_name;
340 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
341 nstring unicode_name;
345 } nbt_netlogon_query_for_pdc;
347 /* response from request */
350 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
351 nstring unicode_pdc_name;
356 } nbt_netlogon_response_from_pdc;
358 /* announce change to UAS or SAM */
365 /* used to announce SAM changes */
373 [flag(NDR_ALIGN2)] DATA_BLOB _pad;
374 nstring unicode_pdc_name;
375 nstring unicode_domain;
377 nbt_db_change dbchange[db_count];
378 [value(ndr_size_dom_sid(&r->sid))] uint32 sid_size;
384 } nbt_netlogon_announce_uas;
386 typedef [nodiscriminant] union {
387 [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
388 [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas;
389 [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
390 } nbt_netlogon_request;
392 typedef [flag(NDR_NOALIGN),public] struct {
393 nbt_netlogon_command command;
394 [switch_is(command)] nbt_netlogon_request req;
395 } nbt_netlogon_packet;