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
13 const int NBT_NAME_SERVICE_PORT = 137;
14 const int NBT_DGRAM_SERVICE_PORT = 138;
16 typedef [bitmap16bit] bitmap {
18 NBT_FLAG_BROADCAST = 0x0010,
19 NBT_FLAG_RECURSION_AVAIL = 0x0080,
20 NBT_FLAG_RECURSION_DESIRED = 0x0100,
21 NBT_FLAG_TRUNCATION = 0x0200,
22 NBT_FLAG_AUTHORITIVE = 0x0400,
24 NBT_FLAG_REPLY = 0x8000
27 /* the opcodes are in the operation field, masked with
30 NBT_OPCODE_QUERY = (0x0<<11),
31 NBT_OPCODE_REGISTER = (0x5<<11),
32 NBT_OPCODE_RELEASE = (0x6<<11),
33 NBT_OPCODE_WACK = (0x7<<11),
34 NBT_OPCODE_REFRESH = (0x8<<11),
35 NBT_OPCODE_REFRESH2 = (0x9<<11),
36 NBT_OPCODE_MULTI_HOME_REG = (0xf<<11)
51 /* we support any 8bit name type, but by defining the common
52 ones here we get better debug displays */
53 typedef [enum8bit] enum {
54 NBT_NAME_CLIENT = 0x00,
57 NBT_NAME_SERVER = 0x20,
59 NBT_NAME_LOGON = 0x1C,
60 NBT_NAME_MASTER = 0x1D,
61 NBT_NAME_BROWSER = 0x1E
64 /* the ndr parser for nbt_name is separately defined in
66 typedef [nopull,nopush] struct {
72 typedef [enum16bit] enum {
76 typedef [enum16bit] enum {
77 NBT_QTYPE_ADDRESS = 0x0001,
78 NBT_QTYPE_NAMESERVICE = 0x0002,
79 NBT_QTYPE_NULL = 0x000A,
80 NBT_QTYPE_NETBIOS = 0x0020,
81 NBT_QTYPE_STATUS = 0x0021
86 nbt_qtype question_type;
87 nbt_qclass question_class;
90 /* these are the possible values of the NBT_NM_OWNER_TYPE
99 typedef [bitmap16bit] bitmap {
100 NBT_NM_PERMANENT = 0x0200,
101 NBT_NM_ACTIVE = 0x0400,
102 NBT_NM_CONFLICT = 0x0800,
103 NBT_NM_DEREGISTER = 0x1000,
104 NBT_NM_OWNER_TYPE = 0x6000,
105 NBT_NM_GROUP = 0x8000
115 nbt_rdata_address addresses[length/6];
122 uint16 version_number;
123 uint16 period_of_statistics;
124 uint16 number_of_crcs;
125 uint16 number_alignment_errors;
126 uint16 number_of_collisions;
127 uint16 number_send_aborts;
128 uint32 number_good_sends;
129 uint32 number_good_receives;
130 uint16 number_retransmits;
131 uint16 number_no_resource_conditions;
132 uint16 number_free_command_blocks;
133 uint16 total_number_command_blocks;
134 uint16 max_total_number_command_blocks;
135 uint16 number_pending_sessions;
136 uint16 max_number_pending_sessions;
137 uint16 max_total_sessions_possible;
138 uint16 session_data_packet_size;
148 [value(r->num_names * 18 + 47)] uint16 length;
150 nbt_status_name names[num_names];
151 nbt_statistics statistics;
159 typedef [nodiscriminant] union {
160 [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
161 [case(NBT_QTYPE_STATUS)] nbt_rdata_status status;
162 [default] nbt_rdata_data data;
165 typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
170 [switch_is(rr_type)] nbt_rdata rdata;
173 typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
175 nbt_operation operation;
180 nbt_name_question questions[qdcount];
181 nbt_res_rec answers[ancount];
182 nbt_res_rec nsrecs[nscount];
183 nbt_res_rec additional[arcount];
184 [flag(NDR_REMAINING)] DATA_BLOB padding;
189 NBT DGRAM packets (UDP/138)
192 typedef [enum8bit] enum {
193 DGRAM_DIRECT_UNIQUE = 0x10,
194 DGRAM_DIRECT_GROUP = 0x11,
198 DGRAM_QUERY_POSITIVE = 0x15,
199 DGRAM_QUERY_NEGATIVE = 0x16
202 typedef [bitmap8bit] bitmap {
203 DGRAM_FLAG_MORE = 0x80,
204 DGRAM_FLAG_FIRST = 0x40,
205 DGRAM_FLAG_NODE_TYPE = 0x30
208 typedef [enum8bit] enum {
212 DGRAM_NODE_NBDD = 0x30
215 /* a dgram_message is the main dgram body in general use */
217 /* the most common datagram type is a SMB_TRANSACTION
218 operation, where a SMB packet is used in the data section
219 of a dgram_message to hold a trans request, which in turn
220 holds a small command structure. It's a very strange beast
221 indeed. To make the code cleaner we define a basic SMB
222 packet in IDL here. This is not a general purpose SMB
223 packet, and won't be used in the core SMB client/server
224 code, but it does make working with these types of dgrams
227 typedef [enum8bit] enum {
228 SMB_TRANSACTION = 0x25
232 [range(17,17),value(17)] uint8 wct;
233 uint16 total_param_count;
234 uint16 total_data_count;
235 uint16 max_param_count;
236 uint16 max_data_count;
237 uint8 max_setup_count;
246 [range(3,3),value(3)] uint8 setup_count;
251 [value(strlen(r->mailslot_name)+1+r->data.length)]
253 astring mailslot_name;
254 [flag(NDR_REMAINING)] DATA_BLOB data;
257 typedef [nodiscriminant] union {
258 [case(SMB_TRANSACTION)] smb_trans_body trans;
262 typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct {
263 smb_command smb_command;
276 [switch_is(smb_command)] smb_body body;
279 typedef [v1_enum] enum {
280 DGRAM_SMB = 0xff534d42 /* 0xffSMB */
283 typedef [nodiscriminant] union {
284 [case(DGRAM_SMB)] dgram_smb_packet smb;
285 } dgram_message_body;
290 nbt_name source_name;
292 dgram_body_type dgram_body_type;
293 [switch_is(dgram_body_type)] dgram_message_body body;
296 typedef [enum8bit] enum {
297 DGRAM_ERROR_NAME_NOT_PRESENT = 0x82,
298 DGRAM_ERROR_INVALID_SOURCE = 0x83,
299 DGRAM_ERROR_INVALID_DEST = 0x84
302 typedef [nodiscriminant] union {
303 [case(DGRAM_DIRECT_UNIQUE)] dgram_message msg;
304 [case(DGRAM_DIRECT_GROUP)] dgram_message msg;
305 [case(DGRAM_BCAST)] dgram_message msg;
306 [case(DGRAM_ERROR)] dgram_err_code error;
307 [case(DGRAM_QUERY)] nbt_name dest_name;
308 [case(DGRAM_QUERY_POSITIVE)] nbt_name dest_name;
309 [case(DGRAM_QUERY_NEGATIVE)] nbt_name dest_name;
312 typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
313 dgram_msg_type msg_type;
318 [switch_is(msg_type)] dgram_data data;