It turns out that the Netlogon PAC verification is encrypted.
[kai/samba.git] / source4 / librpc / idl / nbt.idl
index b9061778bfad62f4c508baacd2541323f3646f30..63be489e0d9c5c7d7d3b1de7a689d72beedb9ff5 100644 (file)
@@ -8,10 +8,11 @@
    encoding if it doesn't work out
 */
 
-[ uuid("1-2-3-4"),
-  version(1.0),
-  depends(security)
-] interface nbt
+import "misc.idl", "security.idl", "svcctl.idl", "samr.idl";
+[
+       helper("libcli/netlogon.h", "libcli/nbt/libnbt.h")
+]
+interface nbt
 {
        const int NBT_NAME_SERVICE_PORT  = 137;
        const int NBT_DGRAM_SERVICE_PORT = 138;
                nbt_name_type type;
        } nbt_name;
 
-       typedef [enum16bit] enum {
+       typedef [public,enum16bit] enum {
                NBT_QCLASS_IP = 0x01
        } nbt_qclass;
 
-       typedef [enum16bit] enum {
+       typedef [public,enum16bit] enum {
                NBT_QTYPE_ADDRESS     = 0x0001,
                NBT_QTYPE_NAMESERVICE = 0x0002,
                NBT_QTYPE_NULL        = 0x000A,
        } nbt_statistics;
 
        typedef struct {
-               astring15 name;
+               [charset(DOS)] uint8 name[15];
                nbt_name_type type;
                nb_flags  nb_flags;
        } nbt_status_name;
 
        typedef struct {
-               [value(r->num_names * 18 + 47)] uint16 length;
+               [value(num_names * 18 + 47)] uint16 length;
                uint8 num_names;
                nbt_status_name names[num_names];
                nbt_statistics  statistics;
                uint8  data[length];
        } nbt_rdata_data;
 
-       typedef [nodiscriminant] union {
+       typedef [nodiscriminant,public] union {
                [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
                [case(NBT_QTYPE_STATUS)]  nbt_rdata_status status;
                [default]                 nbt_rdata_data   data;
        } nbt_rdata;
 
-       typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
+/*
+ * this macro works around the problem
+ * that we need to use nbt_rdata_data
+ * together with NBT_QTYPE_NETBIOS
+ * for WACK replies
+ */
+       typedef [flag(LIBNDR_PRINT_ARRAY_HEX),nopush] struct {
                nbt_name   name;
                nbt_qtype  rr_type;
                nbt_qclass rr_class;
 
        const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON";
        const string NBT_MAILSLOT_NTLOGON  = "\\MAILSLOT\\NET\\NTLOGON";
-       const string NBT_MAILSLOT_GETDC    = "\\MAILSLOT\\GETDC";
+       const string NBT_MAILSLOT_GETDC    = "\\MAILSLOT\\NET\\GETDC";
        const string NBT_MAILSLOT_BROWSE   = "\\MAILSLOT\\BROWSE";
 
        typedef [enum8bit] enum {
                uint16                      opcode;
                uint16                      priority;
                uint16                      class;
-               [value(strlen(r->mailslot_name)+1+r->data.length)] 
+               [value(strlen(mailslot_name)+1+data.length)] 
                      uint16                byte_count;
                astring                     mailslot_name;
                [flag(NDR_REMAINING)]       DATA_BLOB data;
                [switch_is(smb_command)]   smb_body body;
        } dgram_smb_packet;
 
-       typedef [v1_enum] enum {
-               DGRAM_SMB = 0xff534d42 /* 0xffSMB */
-       } dgram_body_type;
+       const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */
 
        typedef [nodiscriminant] union {
                [case(DGRAM_SMB)] dgram_smb_packet smb;
                uint16          offset;
                nbt_name        source_name;
                nbt_name        dest_name;
-               dgram_body_type dgram_body_type;
+               uint32          dgram_body_type;
                [switch_is(dgram_body_type)] dgram_message_body body;
        } dgram_message;
 
                dgram_msg_type msg_type;
                dgram_flags    flags;
                uint16         dgram_id;
-               ipv4address    source;
+               ipv4address    src_addr;
                uint16         src_port;
                [switch_is(msg_type)] dgram_data data;
        } nbt_dgram_packet;
 
 
-       /*******************************************/
-       /* \MAILSLOT\NET\NETLOGON mailslot requests */
-       typedef enum {
-               NETLOGON_QUERY_FOR_PDC           = 0x7, 
-               NETLOGON_ANNOUNCE_UAS            = 0xa,
-               NETLOGON_RESPONSE_FROM_PDC       = 0xc,
-               NETLOGON_QUERY_FOR_PDC2          = 0x12,
-               NETLOGON_RESPONSE_FROM_PDC2      = 0x17,
-               NETLOGON_RESPONSE_FROM_PDC_USER  = 0x19
-       } nbt_netlogon_command;
-
-       /* query for pdc request */
-       typedef struct {
-               astring              computer_name;
-               astring              mailslot_name;
-               [flag(NDR_ALIGN2)]   DATA_BLOB _pad;
-               nstring              unicode_name;
-               uint32               nt_version;
-               uint16               lmnt_token;
-               uint16               lm20_token;
-       } nbt_netlogon_query_for_pdc;
-
-       /* query for pdc request - new style */
-       typedef struct {
-               uint16               request_count;
-               nstring              computer_name;
-               nstring              user_name;
-               astring              mailslot_name;
-               uint32               unknown[2];
-               uint32               nt_version;
-               uint16               lmnt_token;
-               uint16               lm20_token;
-       } nbt_netlogon_query_for_pdc2;
+       /******************************************
+        * \MAILSLOT\NET\NETLOGON mailslot requests
+        * and 
+        * \MAILSLOT\NET\NTLOGON mailslot requests 
+        */
 
-       /* response from pdc */
-       typedef struct {
-               astring pdc_name;
-               [flag(NDR_ALIGN2)]   DATA_BLOB _pad;
-               nstring              unicode_pdc_name;
-               nstring              domain_name;
-               uint32               nt_version;
-               uint16               lmnt_token;
-               uint16               lm20_token;
-       } nbt_netlogon_response_from_pdc;
+       typedef [public,gensize] struct {
+               uint32                  sa_family;
+               [flag(NDR_BIG_ENDIAN)]  ipv4address pdc_ip;
+               [flag(NDR_REMAINING)]   DATA_BLOB remaining;
+       } nbt_sockaddr;
 
-       typedef [bitmap32bit] bitmap {
+       typedef [bitmap32bit,public] bitmap {
                NBT_SERVER_PDC           = 0x00000001,
                NBT_SERVER_GC            = 0x00000004,
                NBT_SERVER_LDAP          = 0x00000008,
                NBT_SERVER_TIMESERV      = 0x00000040,
                NBT_SERVER_CLOSEST       = 0x00000080,
                NBT_SERVER_WRITABLE      = 0x00000100, 
-               NBT_SERVER_GOOD_TIMESERV = 0x00000200
+               NBT_SERVER_GOOD_TIMESERV = 0x00000200,
+               NBT_SERVER_NDNC          = 0x00000400,
+               NBT_SERVER_SEL_SEC_DOM_6 = 0x00000800,
+               NBT_SERVER_FUL_SEC_DOM_6 = 0x00001000,
+               NBT_SERVER_DS_DNS_CONTR  = 0x04000000,
+               NBT_SERVER_DS_DNS_DOMAIN = 0x02000000,
+               NBT_SERVER_DS_DNS_FOREST = 0x01000000
        } nbt_server_type;
 
-       /* response from pdc - type2 */
-       typedef struct {
-               [flag(NDR_ALIGN4)]   DATA_BLOB _pad;
-               nbt_server_type      server_type;
-               GUID                 domain_uuid;
-               nbt_string           forest;
-               nbt_string           dns_domain;
-               nbt_string           pdc_dns_name;
-               nbt_string           domain;
-               nbt_string           pdc_name;
-               nbt_string           user_name;
-               nbt_string           site_name;
-               nbt_string           site_name2;
-               uint8                unknown;
-               uint32               unknown2;
-               [flag(NDR_BIG_ENDIAN)] 
-                 ipv4address          pdc_ip;
-               uint32               unknown3[2];
-               uint32               nt_version;
+       typedef [bitmap32bit,public] bitmap {
+               NETLOGON_NT_VERSION_1   =  0x00000001,
+               NETLOGON_NT_VERSION_5   =  0x00000002,
+               NETLOGON_NT_VERSION_5EX =  0x00000004,
+               NETLOGON_NT_VERSION_5EX_WITH_IP = 0x00000008,
+               NETLOGON_NT_VERSION_WITH_CLOSEST_SITE = 0x00000010,
+               NETLOGON_NT_VERSION_AVIOD_NT4EMUL = 0x01000000,
+               NETLOGON_NT_VERSION_PDC = 0x10000000,
+               NETLOGON_NT_VERSION_IP = 0x20000000,
+               NETLOGON_NT_VERSION_LOCAL = 0x40000000,
+               NETLOGON_NT_VERSION_GC = 0x80000000
+       } netlogon_nt_version_flags;
+
+
+       typedef [enum16bit,public] enum {
+               LOGON_PRIMARY_QUERY               = 7,  /* Was also NETLOGON_QUERY_FOR_PDC */
+               NETLOGON_ANNOUNCE_UAS             = 10,
+               NETLOGON_RESPONSE_FROM_PDC        = 12,
+               LOGON_SAM_LOGON_REQUEST           = 18, /* Was also NETLOGON_QUERY_FOR_PDC2, NTLOGON_SAM_LOGON */
+               LOGON_SAM_LOGON_RESPONSE          = 19, /* Was also NTLOGON_SAM_LOGON_REPLY */
+               LOGON_SAM_LOGON_PAUSE_RESPONSE    = 20, 
+               LOGON_SAM_LOGON_USER_UNKNOWN      = 21, /* Was also NTLOGON_SAM_LOGON_REPLY15 */
+               LOGON_SAM_LOGON_RESPONSE_EX       = 23,  /* was NETLOGON_RESPONSE_FROM_PDC2     */
+               LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24, 
+               LOGON_SAM_LOGON_USER_UNKNOWN_EX   = 25 /* was NETLOGON_RESPONSE_FROM_PDC_USER */
+       } netlogon_command;
+
+       typedef bitmap samr_AcctFlags samr_AcctFlags;
+
+       /* query to dc hand marshaled, as it has 'optional'
+        * parts */
+       typedef [nopull,nopush] struct {
+               uint16               request_count;
+               nstring              computer_name;
+               nstring              user_name;
+               astring              mailslot_name;
+               samr_AcctFlags       acct_control;
+               [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
+               /* The manual alignment is required because this
+                * structure is marked flag(NDR_NOALIGN) via the
+                * nbt_netlogon_packet below.  
+                *
+                * However, both MUST only be present if sid_size > 0 
+                */
+                [flag(NDR_ALIGN4)]   DATA_BLOB _pad;
+                [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
+               netlogon_nt_version_flags               nt_version;
                uint16               lmnt_token;
                uint16               lm20_token;
-       } nbt_netlogon_response_from_pdc2;
-
-       /* announce change to UAS or SAM */
-       typedef struct {
-               uint32           db_index;
-               hyper            serial;
-               NTTIME           timestamp;
-       } nbt_db_change;
-
-       /* used to announce SAM changes */
-       typedef struct {
-               uint32           serial_lo;
-               time_t           timestamp;
-               uint32           pulse;
-               uint32           random;
-               astring          pdc_name;
-               astring          domain;
-               [flag(NDR_ALIGN2)] DATA_BLOB _pad;
-               nstring          unicode_pdc_name;
-               nstring          unicode_domain;
-               uint32           db_count;
-               nbt_db_change    dbchange[db_count];
-               [value(ndr_size_dom_sid(&r->sid))] uint32 sid_size;
-               [flag(NDR_ALIGN4)] DATA_BLOB _pad2;
-               dom_sid          sid;
-               uint32           nt_version;
-               uint16           lmnt_token;
-               uint16           lm20_token;
-       } nbt_netlogon_announce_uas;
-
-       typedef [nodiscriminant] union {
-               [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
-               [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2;
-               [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas;
-               [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
-               [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2;
-               [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
-       } nbt_netlogon_request;
+       } NETLOGON_SAM_LOGON_REQUEST;
 
        typedef [flag(NDR_NOALIGN),public] struct {
-               nbt_netlogon_command command;
-               [switch_is(command)] nbt_netlogon_request req;
-       } nbt_netlogon_packet;
-
-       /*******************************************/
-       /* CLDAP netlogon response                 */
-
-       /* note that these structures are very similar to, but not
-          quite identical to, the netlogon structures above */
-
-       typedef struct {
-               [value(19)] uint16   type;
-               nstring              pdc_name;
+               netlogon_command command;
+               nstring              server;
                nstring              user_name;
-               nstring              domain_name;
-               uint32               nt_version;
+               nstring              domain;
+               netlogon_nt_version_flags               nt_version;
                uint16               lmnt_token;
-               uint16               lm20_token;                
-       } nbt_cldap_netlogon_1;
+               uint16               lm20_token;
+       } NETLOGON_SAM_LOGON_RESPONSE_NT40;
 
-       typedef struct {
-               [value(19)] uint16   type;
+       typedef [flag(NDR_NOALIGN),public] struct {
+               netlogon_command command;
                nstring              pdc_name;
                nstring              user_name;
                nstring              domain_name;
                GUID                 domain_uuid;
-               GUID                 unknown_uuid;
+               GUID                 zero_uuid;
                nbt_string           forest;
                nbt_string           dns_domain;
                nbt_string           pdc_dns_name;
                ipv4address          pdc_ip;
                nbt_server_type      server_type;
-               uint32               nt_version;
+               netlogon_nt_version_flags    nt_version;
                uint16               lmnt_token;
                uint16               lm20_token;                
-       } nbt_cldap_netlogon_2;
+       } NETLOGON_SAM_LOGON_RESPONSE;
 
-       typedef struct {
-               [value(23)] uint32   type;
+       /* response from pdc hand marshaled (we have an additional
+        * function that uses this structure), as it has 'optional'
+        * parts */
+       typedef [flag(NDR_NOALIGN),public] struct {
+               netlogon_command command;
+               uint16               sbz; /* From the docs */
                nbt_server_type      server_type;
                GUID                 domain_uuid;
                nbt_string           forest;
                nbt_string           domain;
                nbt_string           pdc_name;
                nbt_string           user_name;
-               nbt_string           site_name;
-               nbt_string           site_name2;
-               uint32               nt_version;
-               uint16               lmnt_token;
-               uint16               lm20_token;
-       } nbt_cldap_netlogon_3;
+               nbt_string           server_site;
+               nbt_string           client_site;
 
-       typedef struct {
-               [value(23)] uint32   type;
-               nbt_server_type      server_type;
-               GUID                 domain_uuid;
-               nbt_string           forest;
-               nbt_string           dns_domain;
-               nbt_string           pdc_dns_name;
-               nbt_string           domain;
-               nbt_string           pdc_name;
-               nbt_string           user_name;
-               nbt_string           site_name;
-               nbt_string           site_name2;
-               uint8                unknown;
-               uint32               unknown2;
-               [flag(NDR_BIG_ENDIAN)] 
-                 ipv4address          pdc_ip;
-               uint32               unknown3[2];
-               uint32               nt_version;
+               /* Optional on NETLOGON_NT_VERSION_5EX_WITH_IP */
+                [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->flags))] uint8 sockaddr_size; 
+                [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr;
+               
+               /* Optional on NETLOGON_NT_VERSION_WITH_CLOSEST_SITE */
+                nbt_string           next_closest_site;
+
+               netlogon_nt_version_flags               nt_version;
                uint16               lmnt_token;
                uint16               lm20_token;
-       } nbt_cldap_netlogon_4;
-
-       typedef [flag(NDR_NOALIGN),public,nodiscriminant] union {
-               [case(0)]  nbt_cldap_netlogon_1 logon1;
-               [case(1)]  nbt_cldap_netlogon_1 logon1;
-               [case(2)]  nbt_cldap_netlogon_2 logon2;
-               [case(3)]  nbt_cldap_netlogon_2 logon2;
-               [case(4)]  nbt_cldap_netlogon_3 logon3;
-               [case(5)]  nbt_cldap_netlogon_3 logon3;
-               [case(6)]  nbt_cldap_netlogon_3 logon3;
-               [case(7)]  nbt_cldap_netlogon_3 logon3;
-               [default]  nbt_cldap_netlogon_4 logon4;
-       } nbt_cldap_netlogon;
-
-       /*******************************************/
-       /* \MAILSLOT\NET\NTLOGON mailslot requests */
-       typedef enum {
-               NTLOGON_SAM_LOGON       = 0x12,
-               NTLOGON_SAM_LOGON_REPLY = 0x13
-       } nbt_ntlogon_command;
+       } NETLOGON_SAM_LOGON_RESPONSE_EX;
 
+       /* query for pdc request */
        typedef struct {
-               uint16               request_count;
-               nstring              computer_name;
-               nstring              user_name;
+               astring              computer_name;
                astring              mailslot_name;
-               uint32               acct_control;
-               [value(ndr_size_dom_sid(&r->sid))] uint32 sid_size;
-               [flag(NDR_ALIGN4)]   DATA_BLOB _pad;
-               dom_sid              sid;
-               uint32               nt_version;
+               [flag(NDR_ALIGN2)]   DATA_BLOB _pad;
+               nstring              unicode_name;
+               netlogon_nt_version_flags               nt_version;
                uint16               lmnt_token;
                uint16               lm20_token;
-       } nbt_ntlogon_sam_logon;
+       } nbt_netlogon_query_for_pdc;
 
-       typedef struct {
-               nstring              server;
-               nstring              user_name;
-               nstring              domain;
-               uint32               nt_version;
+       /* response from pdc */
+       typedef [flag(NDR_NOALIGN),public] struct {
+               netlogon_command command;
+               astring pdc_name;
+               [flag(NDR_ALIGN2)]   DATA_BLOB _pad;
+               nstring              unicode_pdc_name;
+               nstring              domain_name;
+               netlogon_nt_version_flags               nt_version;
                uint16               lmnt_token;
                uint16               lm20_token;
-       } nbt_ntlogon_sam_logon_reply;
+       } nbt_netlogon_response_from_pdc;
+
+       typedef enum netr_SamDatabaseID netr_SamDatabaseID;
+
+       /* used to announce SAM changes - MS-NRPC 2.2.1.5.1 */
+       typedef struct {
+               netr_SamDatabaseID   db_index;
+               hyper                serial;
+               NTTIME               timestamp;
+       } nbt_db_change_info;
+
+       typedef struct {
+               uint32           serial_lo;
+               time_t           timestamp;
+               uint32           pulse;
+               uint32           random;
+               astring          pdc_name;
+               astring          domain;
+               [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+               nstring          unicode_pdc_name;
+               nstring          unicode_domain;
+               uint32           db_count;
+               nbt_db_change_info    dbchange[db_count];
+               [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
+               [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
+               uint32           message_format_version;
+               uint32           message_token;
+       } NETLOGON_DB_CHANGE;
 
        typedef [nodiscriminant] union {
-               [case(NTLOGON_SAM_LOGON)]       nbt_ntlogon_sam_logon logon;
-               [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply;
-       } nbt_ntlogon_request;
+               [case(LOGON_SAM_LOGON_REQUEST)]       NETLOGON_SAM_LOGON_REQUEST logon;
+               [case(LOGON_PRIMARY_QUERY)] nbt_netlogon_query_for_pdc pdc;
+               [case(NETLOGON_ANNOUNCE_UAS)] NETLOGON_DB_CHANGE uas;
+       } nbt_netlogon_request;
+
+#if 0
+               [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
+               [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
+
+               [case(LOGON_SAM_LOGON_PAUSE_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply;
+               [case(LOGON_SAM_LOGON_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply;
+               [case(LOGON_SAM_LOGON_USER_UNKNOWN)] NETLOGON_SAM_LOGON_RESPONSE reply;
+               [case(LOGON_SAM_LOGON_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex;
+               [case(LOGON_SAM_LOGON_PAUSE_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex;
+               [case(LOGON_SAM_LOGON_USER_UNKNOWN_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex;
+#endif
 
        typedef [flag(NDR_NOALIGN),public] struct {
-               nbt_ntlogon_command command;
-               [switch_is(command)] nbt_ntlogon_request req;
-       } nbt_ntlogon_packet;
-
-       /*******************************************/
-       /* \MAILSLOT\BROWSE mailslot requests */
-
-       typedef enum { 
-               HostAnnouncement                        = 1,
-               AnnouncementRequest             = 2,
-               Election                                        = 8,
-               GetBackupListReq                        = 9,
-               GetBackupListResp                       = 10,
-               BecomeBackup                            = 11,
-               DomainAnnouncement                      = 12,
-               MasterAnnouncement                      = 13,
-               ResetBrowserState                       = 14,
-               LocalMasterAnnouncement         = 15
-       } nbt_browse_opcode;
+               netlogon_command command;
+               [switch_is(command)] nbt_netlogon_request req;
+       } nbt_netlogon_packet;
 
-       typedef bitmap {
-               SV_TYPE_WORKSTATION             = 0x00000001,
-               SV_TYPE_SERVER                  = 0x00000002,
-               SV_TYPE_SQLSERVER               = 0x00000004,
-               SV_TYPE_DOMAIN_CTRL             = 0x00000008,
-               SV_TYPE_DOMAIN_BAKCTRL          = 0x00000010,
-               SV_TYPE_TIME_SOURCE             = 0x00000020,
-               SV_TYPE_AFP                     = 0x00000040,
-               SV_TYPE_NOVELL                  = 0x00000080,
-               SV_TYPE_DOMAIN_MEMBER           = 0x00000100,
-               SV_TYPE_PRINTQ_SERVER           = 0x00000200,
-               SV_TYPE_DIALIN_SERVER           = 0x00000400,
-               SV_TYPE_XENIX_SERVER            = 0x00000800,
-               SV_TYPE_NT                      = 0x00001000,
-               SV_TYPE_POTENTIAL_BROWSER       = 0x00010000,
-               SV_TYPE_BACKUP_BROWSER          = 0x00020000,
-               SV_TYPE_MASTER_BROWSER          = 0x00040000,
-               SV_TYPE_DOMAIN_MASTER           = 0x00080000,
-               SV_TYPE_LOCAL_LIST_ONLY         = 0x40000000,
-               SV_TYPE_DOMAIN_ENUM             = 0x80000000
-       } nbt_browse_server_type;
+       /********************************************************/
+       /* \MAILSLOT\BROWSE mailslot requests                   */
+       /* for details see http://ubiqx.org/cifs/Browsing.html  */
+       /********************************************************/
+       typedef bitmap svcctl_ServerType svcctl_ServerType;
+
+       typedef [enum8bit] enum { 
+               HostAnnouncement        = 1,
+               AnnouncementRequest     = 2,
+               Election                = 8,
+               GetBackupListReq        = 9,
+               GetBackupListResp       = 10,
+               BecomeBackup            = 11,
+               DomainAnnouncement      = 12,
+               MasterAnnouncement      = 13,
+               ResetBrowserState       = 14,
+               LocalMasterAnnouncement = 15
+       } nbt_browse_opcode;
 
        typedef struct {
-               uint8 update_count;
-               uint32 ttl;
-               uint8 name[16];
-               uint8 os_major;
-               uint8 os_minor;
-               uint32 server_type;
-               astring comment;
+               uint8 UpdateCount;
+               uint32 Periodicity;
+               [charset(DOS)] uint8 ServerName[16];
+               uint8 OSMajor;
+               uint8 OSMinor;
+               svcctl_ServerType ServerType;
+               uint8 BroMajorVer;
+               uint8 BroMinorVer;
+               uint16 Signature;
+               astring Comment;
        } nbt_browse_host_announcement;
 
        typedef struct {
-               uint8 unknown;
-               astring ResponseComputerName; 
-       } nbt_browse_request_announcement;
+               uint8 Unused;
+               astring ResponseName; 
+       } nbt_browse_announcement_request;
+
+       typedef struct {
+               uint8 Version;
+               uint32 Criteria;
+               uint32 UpTime; /* In milliseconds */
+               uint32 Reserved; /* Must be zero */
+               astring ServerName; 
+       } nbt_browse_election_request;
 
        typedef struct {
-               uint8 count;
-               uint32 token;
+               uint8 ReqCount;
+               uint32 Token;
        } nbt_browse_backup_list_request;
 
        typedef struct {
-               uint8 count;
-               uint32 token;
-               nbt_name BackupServerList[count];
+               uint8 BackupCount;
+               uint32 Token;
+               nbt_name BackupServerList[BackupCount];/* TODO: this is wrong */
        } nbt_browse_backup_list_response;
 
        typedef struct {
-               astring BrowserToPromote;
+               astring BrowserName;
        } nbt_browse_become_backup;
 
        typedef struct {
-               uint8 version;
-               uint32 criteria;
-               uint32 time_up; /* In milliseconds */
-               uint32 reserved; /* Must be zero */
-               astring ServerName; 
-       } nbt_browse_election_request;
+               uint8 UpdateCount;
+               uint32 Periodicity;
+               [charset(DOS)] uint8 ServerName[16];
+               uint8 OSMajor;
+               uint8 OSMinor;
+               svcctl_ServerType ServerType;
+               uint32 MysteriousField;
+               astring Comment;
+       } nbt_browse_domain_announcement;
 
        typedef struct {
-               uint8 options;
+               astring ServerName;
+       } nbt_browse_master_announcement;
+
+       typedef struct {
+               uint8 Command;
        } nbt_browse_reset_state;
 
        typedef struct {
-               astring MasterBrowserServerName; 
-       } nbt_browse_master_announcement;
+               uint8 UpdateCount;
+               uint32 Periodicity;
+               [charset(DOS)] uint8 ServerName[16];
+               uint8 OSMajor;
+               uint8 OSMinor;
+               svcctl_ServerType ServerType;
+               uint8 BroMajorVer;
+               uint8 BroMinorVer;
+               uint16 Signature;
+               astring Comment;
+       } nbt_browse_local_master_announcement;
 
        typedef [nodiscriminant] union {
                [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement;
-               [case(AnnouncementRequest)] nbt_browse_request_announcement announcement_request;
+               [case(AnnouncementRequest)] nbt_browse_announcement_request announcement_request;
                [case(Election)] nbt_browse_election_request election_request;
                [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request;
                [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response;
                [case(BecomeBackup)] nbt_browse_become_backup become_backup;
-               [case(DomainAnnouncement)] nbt_browse_master_announcement domain_announcement;
+               [case(DomainAnnouncement)] nbt_browse_domain_announcement domain_announcement;
                [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement;
                [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state;
-               [case(LocalMasterAnnouncement)] nbt_browse_master_announcement local_master_announcement;
+               [case(LocalMasterAnnouncement)] nbt_browse_local_master_announcement local_master_announcement;
        } nbt_browse_payload;
 
        typedef [public,flag(NDR_NOALIGN)] struct {
                nbt_browse_opcode opcode;
-               nbt_browse_payload payload;     
+               [switch_is(opcode)] nbt_browse_payload payload; 
        } nbt_browse_packet;
 }