| 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/netlogon.h", "../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 | typedef [flag(LIBNDR_PRINT_ARRAY_HEX),nopush] struct { | 
|---|
| 176 | nbt_name   name; | 
|---|
| 177 | nbt_qtype  rr_type; | 
|---|
| 178 | nbt_qclass rr_class; | 
|---|
| 179 | uint32     ttl; | 
|---|
| 180 | [switch_is(rr_type)] nbt_rdata rdata; | 
|---|
| 181 | } nbt_res_rec; | 
|---|
| 182 |  | 
|---|
| 183 | typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct { | 
|---|
| 184 | uint16            name_trn_id; | 
|---|
| 185 | nbt_operation     operation; | 
|---|
| 186 | uint16            qdcount; | 
|---|
| 187 | uint16            ancount; | 
|---|
| 188 | uint16            nscount; | 
|---|
| 189 | uint16            arcount; | 
|---|
| 190 | nbt_name_question questions[qdcount]; | 
|---|
| 191 | nbt_res_rec       answers[ancount]; | 
|---|
| 192 | nbt_res_rec       nsrecs[nscount]; | 
|---|
| 193 | nbt_res_rec       additional[arcount]; | 
|---|
| 194 | [flag(NDR_REMAINING)] DATA_BLOB padding; | 
|---|
| 195 | } nbt_name_packet; | 
|---|
| 196 |  | 
|---|
| 197 |  | 
|---|
| 198 | /* | 
|---|
| 199 | NBT DGRAM packets (UDP/138) | 
|---|
| 200 | */ | 
|---|
| 201 |  | 
|---|
| 202 | typedef [enum8bit] enum { | 
|---|
| 203 | DGRAM_DIRECT_UNIQUE  = 0x10, | 
|---|
| 204 | DGRAM_DIRECT_GROUP   = 0x11, | 
|---|
| 205 | DGRAM_BCAST          = 0x12, | 
|---|
| 206 | DGRAM_ERROR          = 0x13, | 
|---|
| 207 | DGRAM_QUERY          = 0x14, | 
|---|
| 208 | DGRAM_QUERY_POSITIVE = 0x15, | 
|---|
| 209 | DGRAM_QUERY_NEGATIVE = 0x16 | 
|---|
| 210 | } dgram_msg_type; | 
|---|
| 211 |  | 
|---|
| 212 | typedef [bitmap8bit] bitmap { | 
|---|
| 213 | DGRAM_FLAG_MORE         = 0x01, | 
|---|
| 214 | DGRAM_FLAG_FIRST        = 0x02, | 
|---|
| 215 | DGRAM_FLAG_NODE_TYPE    = 0x0C | 
|---|
| 216 | } dgram_flags; | 
|---|
| 217 |  | 
|---|
| 218 | typedef [enum8bit] enum { | 
|---|
| 219 | DGRAM_NODE_B    = 0x00, | 
|---|
| 220 | DGRAM_NODE_P    = 0x04, | 
|---|
| 221 | DGRAM_NODE_M    = 0x08, | 
|---|
| 222 | DGRAM_NODE_NBDD = 0x0C | 
|---|
| 223 | } dgram_node_type; | 
|---|
| 224 |  | 
|---|
| 225 | /* a dgram_message is the main dgram body in general use */ | 
|---|
| 226 |  | 
|---|
| 227 | /* the most common datagram type is a SMB_TRANSACTION | 
|---|
| 228 | operation, where a SMB packet is used in the data section | 
|---|
| 229 | of a dgram_message to hold a trans request, which in turn | 
|---|
| 230 | holds a small command structure. It's a very strange beast | 
|---|
| 231 | indeed. To make the code cleaner we define a basic SMB | 
|---|
| 232 | packet in IDL here. This is not a general purpose SMB | 
|---|
| 233 | packet, and won't be used in the core SMB client/server | 
|---|
| 234 | code, but it does make working with these types of dgrams | 
|---|
| 235 | easier */ | 
|---|
| 236 |  | 
|---|
| 237 | const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON"; | 
|---|
| 238 | const string NBT_MAILSLOT_NTLOGON  = "\\MAILSLOT\\NET\\NTLOGON"; | 
|---|
| 239 | const string NBT_MAILSLOT_GETDC    = "\\MAILSLOT\\NET\\GETDC"; | 
|---|
| 240 | const string NBT_MAILSLOT_BROWSE   = "\\MAILSLOT\\BROWSE"; | 
|---|
| 241 |  | 
|---|
| 242 | typedef [enum8bit] enum { | 
|---|
| 243 | SMB_TRANSACTION = 0x25 | 
|---|
| 244 | } smb_command; | 
|---|
| 245 |  | 
|---|
| 246 | typedef struct { | 
|---|
| 247 | [range(17,17),value(17)] uint8 wct; | 
|---|
| 248 | uint16                      total_param_count; | 
|---|
| 249 | uint16                      total_data_count; | 
|---|
| 250 | uint16                      max_param_count; | 
|---|
| 251 | uint16                      max_data_count; | 
|---|
| 252 | uint8                       max_setup_count; | 
|---|
| 253 | uint8                       pad; | 
|---|
| 254 | uint16                      trans_flags; | 
|---|
| 255 | uint32                      timeout; | 
|---|
| 256 | uint16                      reserved; | 
|---|
| 257 | uint16                      param_count; | 
|---|
| 258 | uint16                      param_offset; | 
|---|
| 259 | uint16                      data_count; | 
|---|
| 260 | uint16                      data_offset; | 
|---|
| 261 | [range(3,3),value(3)] uint8 setup_count; | 
|---|
| 262 | uint8                       pad2; | 
|---|
| 263 | uint16                      opcode; | 
|---|
| 264 | uint16                      priority; | 
|---|
| 265 | uint16                      _class; | 
|---|
| 266 | [value(strlen(mailslot_name)+1+data.length)] | 
|---|
| 267 | uint16                byte_count; | 
|---|
| 268 | astring                     mailslot_name; | 
|---|
| 269 | [flag(NDR_REMAINING)]       DATA_BLOB data; | 
|---|
| 270 | } smb_trans_body; | 
|---|
| 271 |  | 
|---|
| 272 | typedef [nodiscriminant] union { | 
|---|
| 273 | [case(SMB_TRANSACTION)] smb_trans_body trans; | 
|---|
| 274 | } smb_body; | 
|---|
| 275 |  | 
|---|
| 276 |  | 
|---|
| 277 | typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct { | 
|---|
| 278 | smb_command                smb_command; | 
|---|
| 279 | uint8                      err_class; | 
|---|
| 280 | uint8                      pad; | 
|---|
| 281 | uint16                     err_code; | 
|---|
| 282 | uint8                      flags; | 
|---|
| 283 | uint16                     flags2; | 
|---|
| 284 | uint16                     pid_high; | 
|---|
| 285 | uint8                      signature[8]; | 
|---|
| 286 | uint16                     reserved; | 
|---|
| 287 | uint16                     tid; | 
|---|
| 288 | uint16                     pid; | 
|---|
| 289 | uint16                     vuid; | 
|---|
| 290 | uint16                     mid; | 
|---|
| 291 | [switch_is(smb_command)]   smb_body body; | 
|---|
| 292 | } dgram_smb_packet; | 
|---|
| 293 |  | 
|---|
| 294 | const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */ | 
|---|
| 295 |  | 
|---|
| 296 | typedef [nodiscriminant] union { | 
|---|
| 297 | [case(DGRAM_SMB)] dgram_smb_packet smb; | 
|---|
| 298 | } dgram_message_body; | 
|---|
| 299 |  | 
|---|
| 300 | typedef struct { | 
|---|
| 301 | uint16          length; | 
|---|
| 302 | uint16          offset; | 
|---|
| 303 | nbt_name        source_name; | 
|---|
| 304 | nbt_name        dest_name; | 
|---|
| 305 | uint32          dgram_body_type; | 
|---|
| 306 | [switch_is(dgram_body_type)] dgram_message_body body; | 
|---|
| 307 | } dgram_message; | 
|---|
| 308 |  | 
|---|
| 309 | typedef [enum8bit] enum { | 
|---|
| 310 | DGRAM_ERROR_NAME_NOT_PRESENT = 0x82, | 
|---|
| 311 | DGRAM_ERROR_INVALID_SOURCE   = 0x83, | 
|---|
| 312 | DGRAM_ERROR_INVALID_DEST     = 0x84 | 
|---|
| 313 | } dgram_err_code; | 
|---|
| 314 |  | 
|---|
| 315 | typedef [nodiscriminant] union { | 
|---|
| 316 | [case(DGRAM_DIRECT_UNIQUE)]   dgram_message  msg; | 
|---|
| 317 | [case(DGRAM_DIRECT_GROUP)]    dgram_message  msg; | 
|---|
| 318 | [case(DGRAM_BCAST)]           dgram_message  msg; | 
|---|
| 319 | [case(DGRAM_ERROR)]           dgram_err_code error; | 
|---|
| 320 | [case(DGRAM_QUERY)]           nbt_name       dest_name; | 
|---|
| 321 | [case(DGRAM_QUERY_POSITIVE)]  nbt_name       dest_name; | 
|---|
| 322 | [case(DGRAM_QUERY_NEGATIVE)]  nbt_name       dest_name; | 
|---|
| 323 | } dgram_data; | 
|---|
| 324 |  | 
|---|
| 325 | typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct { | 
|---|
| 326 | dgram_msg_type msg_type; | 
|---|
| 327 | dgram_flags    flags; | 
|---|
| 328 | uint16         dgram_id; | 
|---|
| 329 | ipv4address    src_addr; | 
|---|
| 330 | uint16         src_port; | 
|---|
| 331 | [switch_is(msg_type)] dgram_data data; | 
|---|
| 332 | } nbt_dgram_packet; | 
|---|
| 333 |  | 
|---|
| 334 |  | 
|---|
| 335 | /****************************************** | 
|---|
| 336 | * \MAILSLOT\NET\NETLOGON mailslot requests | 
|---|
| 337 | * and | 
|---|
| 338 | * \MAILSLOT\NET\NTLOGON mailslot requests | 
|---|
| 339 | */ | 
|---|
| 340 |  | 
|---|
| 341 | typedef [public,gensize] struct { | 
|---|
| 342 | uint32                  sockaddr_family; | 
|---|
| 343 | [flag(NDR_BIG_ENDIAN)]  ipv4address pdc_ip; | 
|---|
| 344 | [flag(NDR_REMAINING)]   DATA_BLOB remaining; | 
|---|
| 345 | } nbt_sockaddr; | 
|---|
| 346 |  | 
|---|
| 347 | typedef [bitmap32bit,public] bitmap { | 
|---|
| 348 | NBT_SERVER_PDC                          = 0x00000001, | 
|---|
| 349 | NBT_SERVER_GC                           = 0x00000004, | 
|---|
| 350 | NBT_SERVER_LDAP                         = 0x00000008, | 
|---|
| 351 | NBT_SERVER_DS                           = 0x00000010, | 
|---|
| 352 | NBT_SERVER_KDC                          = 0x00000020, | 
|---|
| 353 | NBT_SERVER_TIMESERV                     = 0x00000040, | 
|---|
| 354 | NBT_SERVER_CLOSEST                      = 0x00000080, | 
|---|
| 355 | NBT_SERVER_WRITABLE                     = 0x00000100, | 
|---|
| 356 | NBT_SERVER_GOOD_TIMESERV                = 0x00000200, | 
|---|
| 357 | NBT_SERVER_NDNC                         = 0x00000400, | 
|---|
| 358 | NBT_SERVER_SELECT_SECRET_DOMAIN_6       = 0x00000800, | 
|---|
| 359 | NBT_SERVER_FULL_SECRET_DOMAIN_6         = 0x00001000, | 
|---|
| 360 | NBT_SERVER_DNS_FOREST                   = 0x01000000 | 
|---|
| 361 | } nbt_server_type; | 
|---|
| 362 |  | 
|---|
| 363 | typedef [bitmap32bit,public] bitmap { | 
|---|
| 364 | NETLOGON_NT_VERSION_1                   = 0x00000001, | 
|---|
| 365 | NETLOGON_NT_VERSION_5                   = 0x00000002, | 
|---|
| 366 | NETLOGON_NT_VERSION_5EX                 = 0x00000004, | 
|---|
| 367 | NETLOGON_NT_VERSION_5EX_WITH_IP         = 0x00000008, | 
|---|
| 368 | NETLOGON_NT_VERSION_WITH_CLOSEST_SITE   = 0x00000010, | 
|---|
| 369 | NETLOGON_NT_VERSION_AVIOD_NT4EMUL       = 0x01000000, | 
|---|
| 370 | NETLOGON_NT_VERSION_PDC                 = 0x10000000, | 
|---|
| 371 | NETLOGON_NT_VERSION_IP                  = 0x20000000, | 
|---|
| 372 | NETLOGON_NT_VERSION_LOCAL               = 0x40000000, | 
|---|
| 373 | NETLOGON_NT_VERSION_GC                  = 0x80000000 | 
|---|
| 374 | } netlogon_nt_version_flags; | 
|---|
| 375 |  | 
|---|
| 376 | typedef [enum16bit,public] enum { | 
|---|
| 377 | LOGON_PRIMARY_QUERY               = 7,  /* Was also NETLOGON_QUERY_FOR_PDC */ | 
|---|
| 378 | NETLOGON_ANNOUNCE_UAS             = 10, | 
|---|
| 379 | NETLOGON_RESPONSE_FROM_PDC        = 12, | 
|---|
| 380 | LOGON_SAM_LOGON_REQUEST           = 18, /* Was also NETLOGON_QUERY_FOR_PDC2, NTLOGON_SAM_LOGON */ | 
|---|
| 381 | LOGON_SAM_LOGON_RESPONSE          = 19, /* Was also NTLOGON_SAM_LOGON_REPLY */ | 
|---|
| 382 | LOGON_SAM_LOGON_PAUSE_RESPONSE    = 20, | 
|---|
| 383 | LOGON_SAM_LOGON_USER_UNKNOWN      = 21, /* Was also NTLOGON_SAM_LOGON_REPLY15 */ | 
|---|
| 384 | LOGON_SAM_LOGON_RESPONSE_EX       = 23,  /* was NETLOGON_RESPONSE_FROM_PDC2     */ | 
|---|
| 385 | LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24, | 
|---|
| 386 | LOGON_SAM_LOGON_USER_UNKNOWN_EX   = 25 /* was NETLOGON_RESPONSE_FROM_PDC_USER */ | 
|---|
| 387 | } netlogon_command; | 
|---|
| 388 |  | 
|---|
| 389 | typedef bitmap samr_AcctFlags samr_AcctFlags; | 
|---|
| 390 |  | 
|---|
| 391 | /* query to dc hand marshaled, as it has 'optional' | 
|---|
| 392 | * parts */ | 
|---|
| 393 | typedef [nopull,nopush] struct { | 
|---|
| 394 | uint16               request_count; | 
|---|
| 395 | nstring              computer_name; | 
|---|
| 396 | nstring              user_name; | 
|---|
| 397 | astring              mailslot_name; | 
|---|
| 398 | samr_AcctFlags       acct_control; | 
|---|
| 399 | [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; | 
|---|
| 400 | /* The manual alignment is required because this | 
|---|
| 401 | * structure is marked flag(NDR_NOALIGN) via the | 
|---|
| 402 | * nbt_netlogon_packet below. | 
|---|
| 403 | * | 
|---|
| 404 | * However, both MUST only be present if sid_size > 0 | 
|---|
| 405 | */ | 
|---|
| 406 | [flag(NDR_ALIGN4)]   DATA_BLOB _pad; | 
|---|
| 407 | [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; | 
|---|
| 408 | netlogon_nt_version_flags               nt_version; | 
|---|
| 409 | uint16               lmnt_token; | 
|---|
| 410 | uint16               lm20_token; | 
|---|
| 411 | } NETLOGON_SAM_LOGON_REQUEST; | 
|---|
| 412 |  | 
|---|
| 413 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 414 | netlogon_command command; | 
|---|
| 415 | nstring              server; | 
|---|
| 416 | nstring              user_name; | 
|---|
| 417 | nstring              domain; | 
|---|
| 418 | netlogon_nt_version_flags               nt_version; | 
|---|
| 419 | uint16               lmnt_token; | 
|---|
| 420 | uint16               lm20_token; | 
|---|
| 421 | } NETLOGON_SAM_LOGON_RESPONSE_NT40; | 
|---|
| 422 |  | 
|---|
| 423 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 424 | netlogon_command command; | 
|---|
| 425 | nstring              pdc_name; | 
|---|
| 426 | nstring              user_name; | 
|---|
| 427 | nstring              domain_name; | 
|---|
| 428 | GUID                 domain_uuid; | 
|---|
| 429 | GUID                 zero_uuid; | 
|---|
| 430 | nbt_string           forest; | 
|---|
| 431 | nbt_string           dns_domain; | 
|---|
| 432 | nbt_string           pdc_dns_name; | 
|---|
| 433 | ipv4address          pdc_ip; | 
|---|
| 434 | nbt_server_type      server_type; | 
|---|
| 435 | netlogon_nt_version_flags    nt_version; | 
|---|
| 436 | uint16               lmnt_token; | 
|---|
| 437 | uint16               lm20_token; | 
|---|
| 438 | } NETLOGON_SAM_LOGON_RESPONSE; | 
|---|
| 439 |  | 
|---|
| 440 | /* response from pdc hand marshaled (we have an additional | 
|---|
| 441 | * function that uses this structure), as it has 'optional' | 
|---|
| 442 | * parts */ | 
|---|
| 443 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 444 | netlogon_command command; | 
|---|
| 445 | uint16               sbz; /* From the docs */ | 
|---|
| 446 | nbt_server_type      server_type; | 
|---|
| 447 | GUID                 domain_uuid; | 
|---|
| 448 | nbt_string           forest; | 
|---|
| 449 | nbt_string           dns_domain; | 
|---|
| 450 | nbt_string           pdc_dns_name; | 
|---|
| 451 | nbt_string           domain; | 
|---|
| 452 | nbt_string           pdc_name; | 
|---|
| 453 | nbt_string           user_name; | 
|---|
| 454 | nbt_string           server_site; | 
|---|
| 455 | nbt_string           client_site; | 
|---|
| 456 |  | 
|---|
| 457 | /* Optional on NETLOGON_NT_VERSION_5EX_WITH_IP */ | 
|---|
| 458 | [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->iconv_convenience, ndr->flags))] uint8 sockaddr_size; | 
|---|
| 459 | [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr; | 
|---|
| 460 |  | 
|---|
| 461 | /* Optional on NETLOGON_NT_VERSION_WITH_CLOSEST_SITE */ | 
|---|
| 462 | nbt_string           next_closest_site; | 
|---|
| 463 |  | 
|---|
| 464 | netlogon_nt_version_flags               nt_version; | 
|---|
| 465 | uint16               lmnt_token; | 
|---|
| 466 | uint16               lm20_token; | 
|---|
| 467 | } NETLOGON_SAM_LOGON_RESPONSE_EX; | 
|---|
| 468 |  | 
|---|
| 469 | /* query for pdc request */ | 
|---|
| 470 | typedef struct { | 
|---|
| 471 | astring              computer_name; | 
|---|
| 472 | astring              mailslot_name; | 
|---|
| 473 | [flag(NDR_ALIGN2)]   DATA_BLOB _pad; | 
|---|
| 474 | nstring              unicode_name; | 
|---|
| 475 | netlogon_nt_version_flags               nt_version; | 
|---|
| 476 | uint16               lmnt_token; | 
|---|
| 477 | uint16               lm20_token; | 
|---|
| 478 | } nbt_netlogon_query_for_pdc; | 
|---|
| 479 |  | 
|---|
| 480 | /* response from pdc */ | 
|---|
| 481 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 482 | netlogon_command command; | 
|---|
| 483 | astring pdc_name; | 
|---|
| 484 | [flag(NDR_ALIGN2)]   DATA_BLOB _pad; | 
|---|
| 485 | nstring              unicode_pdc_name; | 
|---|
| 486 | nstring              domain_name; | 
|---|
| 487 | netlogon_nt_version_flags               nt_version; | 
|---|
| 488 | uint16               lmnt_token; | 
|---|
| 489 | uint16               lm20_token; | 
|---|
| 490 | } nbt_netlogon_response_from_pdc; | 
|---|
| 491 |  | 
|---|
| 492 | typedef enum netr_SamDatabaseID netr_SamDatabaseID; | 
|---|
| 493 |  | 
|---|
| 494 | /* used to announce SAM changes - MS-NRPC 2.2.1.5.1 */ | 
|---|
| 495 | typedef struct { | 
|---|
| 496 | netr_SamDatabaseID   db_index; | 
|---|
| 497 | hyper                serial; | 
|---|
| 498 | NTTIME               timestamp; | 
|---|
| 499 | } nbt_db_change_info; | 
|---|
| 500 |  | 
|---|
| 501 | typedef struct { | 
|---|
| 502 | uint32           serial_lo; | 
|---|
| 503 | time_t           timestamp; | 
|---|
| 504 | uint32           pulse; | 
|---|
| 505 | uint32           random; | 
|---|
| 506 | astring          pdc_name; | 
|---|
| 507 | astring          domain; | 
|---|
| 508 | [flag(NDR_ALIGN2)] DATA_BLOB _pad; | 
|---|
| 509 | nstring          unicode_pdc_name; | 
|---|
| 510 | nstring          unicode_domain; | 
|---|
| 511 | uint32           db_count; | 
|---|
| 512 | nbt_db_change_info    dbchange[db_count]; | 
|---|
| 513 | [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; | 
|---|
| 514 | [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; | 
|---|
| 515 | uint32           message_format_version; | 
|---|
| 516 | uint32           message_token; | 
|---|
| 517 | } NETLOGON_DB_CHANGE; | 
|---|
| 518 |  | 
|---|
| 519 | typedef [nodiscriminant] union { | 
|---|
| 520 | [case(LOGON_SAM_LOGON_REQUEST)]       NETLOGON_SAM_LOGON_REQUEST logon; | 
|---|
| 521 | [case(LOGON_PRIMARY_QUERY)] nbt_netlogon_query_for_pdc pdc; | 
|---|
| 522 | [case(NETLOGON_ANNOUNCE_UAS)] NETLOGON_DB_CHANGE uas; | 
|---|
| 523 | } nbt_netlogon_request; | 
|---|
| 524 |  | 
|---|
| 525 | #if 0 | 
|---|
| 526 | [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response; | 
|---|
| 527 | [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2; | 
|---|
| 528 |  | 
|---|
| 529 | [case(LOGON_SAM_LOGON_PAUSE_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply; | 
|---|
| 530 | [case(LOGON_SAM_LOGON_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply; | 
|---|
| 531 | [case(LOGON_SAM_LOGON_USER_UNKNOWN)] NETLOGON_SAM_LOGON_RESPONSE reply; | 
|---|
| 532 | [case(LOGON_SAM_LOGON_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; | 
|---|
| 533 | [case(LOGON_SAM_LOGON_PAUSE_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; | 
|---|
| 534 | [case(LOGON_SAM_LOGON_USER_UNKNOWN_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; | 
|---|
| 535 | #endif | 
|---|
| 536 |  | 
|---|
| 537 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 538 | netlogon_command command; | 
|---|
| 539 | [switch_is(command)] nbt_netlogon_request req; | 
|---|
| 540 | } nbt_netlogon_packet; | 
|---|
| 541 |  | 
|---|
| 542 | /********************************************************/ | 
|---|
| 543 | /* \MAILSLOT\BROWSE mailslot requests                   */ | 
|---|
| 544 | /* for details see http://ubiqx.org/cifs/Browsing.html  */ | 
|---|
| 545 | /********************************************************/ | 
|---|
| 546 | typedef bitmap svcctl_ServerType svcctl_ServerType; | 
|---|
| 547 |  | 
|---|
| 548 | typedef [enum8bit] enum { | 
|---|
| 549 | HostAnnouncement        = 1, | 
|---|
| 550 | AnnouncementRequest     = 2, | 
|---|
| 551 | Election                = 8, | 
|---|
| 552 | GetBackupListReq        = 9, | 
|---|
| 553 | GetBackupListResp       = 10, | 
|---|
| 554 | BecomeBackup            = 11, | 
|---|
| 555 | DomainAnnouncement      = 12, | 
|---|
| 556 | MasterAnnouncement      = 13, | 
|---|
| 557 | ResetBrowserState       = 14, | 
|---|
| 558 | LocalMasterAnnouncement = 15 | 
|---|
| 559 | } nbt_browse_opcode; | 
|---|
| 560 |  | 
|---|
| 561 | typedef struct { | 
|---|
| 562 | uint8 UpdateCount; | 
|---|
| 563 | uint32 Periodicity; | 
|---|
| 564 | [charset(DOS)] uint8 ServerName[16]; | 
|---|
| 565 | uint8 OSMajor; | 
|---|
| 566 | uint8 OSMinor; | 
|---|
| 567 | svcctl_ServerType ServerType; | 
|---|
| 568 | uint8 BroMajorVer; | 
|---|
| 569 | uint8 BroMinorVer; | 
|---|
| 570 | uint16 Signature; | 
|---|
| 571 | astring Comment; | 
|---|
| 572 | } nbt_browse_host_announcement; | 
|---|
| 573 |  | 
|---|
| 574 | typedef struct { | 
|---|
| 575 | uint8 Unused; | 
|---|
| 576 | astring ResponseName; | 
|---|
| 577 | } nbt_browse_announcement_request; | 
|---|
| 578 |  | 
|---|
| 579 | typedef struct { | 
|---|
| 580 | uint8 Version; | 
|---|
| 581 | uint32 Criteria; | 
|---|
| 582 | uint32 UpTime; /* In milliseconds */ | 
|---|
| 583 | uint32 Reserved; /* Must be zero */ | 
|---|
| 584 | astring ServerName; | 
|---|
| 585 | } nbt_browse_election_request; | 
|---|
| 586 |  | 
|---|
| 587 | typedef struct { | 
|---|
| 588 | uint8 ReqCount; | 
|---|
| 589 | uint32 Token; | 
|---|
| 590 | } nbt_browse_backup_list_request; | 
|---|
| 591 |  | 
|---|
| 592 | typedef struct { | 
|---|
| 593 | uint8 BackupCount; | 
|---|
| 594 | uint32 Token; | 
|---|
| 595 | nbt_name BackupServerList[BackupCount];/* TODO: this is wrong */ | 
|---|
| 596 | } nbt_browse_backup_list_response; | 
|---|
| 597 |  | 
|---|
| 598 | typedef struct { | 
|---|
| 599 | astring BrowserName; | 
|---|
| 600 | } nbt_browse_become_backup; | 
|---|
| 601 |  | 
|---|
| 602 | typedef struct { | 
|---|
| 603 | uint8 UpdateCount; | 
|---|
| 604 | uint32 Periodicity; | 
|---|
| 605 | [charset(DOS)] uint8 ServerName[16]; | 
|---|
| 606 | uint8 OSMajor; | 
|---|
| 607 | uint8 OSMinor; | 
|---|
| 608 | svcctl_ServerType ServerType; | 
|---|
| 609 | uint32 MysteriousField; | 
|---|
| 610 | astring Comment; | 
|---|
| 611 | } nbt_browse_domain_announcement; | 
|---|
| 612 |  | 
|---|
| 613 | typedef struct { | 
|---|
| 614 | astring ServerName; | 
|---|
| 615 | } nbt_browse_master_announcement; | 
|---|
| 616 |  | 
|---|
| 617 | typedef struct { | 
|---|
| 618 | uint8 Command; | 
|---|
| 619 | } nbt_browse_reset_state; | 
|---|
| 620 |  | 
|---|
| 621 | typedef struct { | 
|---|
| 622 | uint8 UpdateCount; | 
|---|
| 623 | uint32 Periodicity; | 
|---|
| 624 | [charset(DOS)] uint8 ServerName[16]; | 
|---|
| 625 | uint8 OSMajor; | 
|---|
| 626 | uint8 OSMinor; | 
|---|
| 627 | svcctl_ServerType ServerType; | 
|---|
| 628 | uint8 BroMajorVer; | 
|---|
| 629 | uint8 BroMinorVer; | 
|---|
| 630 | uint16 Signature; | 
|---|
| 631 | astring Comment; | 
|---|
| 632 | } nbt_browse_local_master_announcement; | 
|---|
| 633 |  | 
|---|
| 634 | typedef [nodiscriminant] union { | 
|---|
| 635 | [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement; | 
|---|
| 636 | [case(AnnouncementRequest)] nbt_browse_announcement_request announcement_request; | 
|---|
| 637 | [case(Election)] nbt_browse_election_request election_request; | 
|---|
| 638 | [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request; | 
|---|
| 639 | [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response; | 
|---|
| 640 | [case(BecomeBackup)] nbt_browse_become_backup become_backup; | 
|---|
| 641 | [case(DomainAnnouncement)] nbt_browse_domain_announcement domain_announcement; | 
|---|
| 642 | [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement; | 
|---|
| 643 | [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state; | 
|---|
| 644 | [case(LocalMasterAnnouncement)] nbt_browse_local_master_announcement local_master_announcement; | 
|---|
| 645 | } nbt_browse_payload; | 
|---|
| 646 |  | 
|---|
| 647 | typedef [public,flag(NDR_NOALIGN)] struct { | 
|---|
| 648 | nbt_browse_opcode opcode; | 
|---|
| 649 | [switch_is(opcode)] nbt_browse_payload payload; | 
|---|
| 650 | } nbt_browse_packet; | 
|---|
| 651 | } | 
|---|