home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sysmgmt / sms / netmon / browser / hostannc.h < prev    next >
C/C++ Source or Header  |  1996-10-15  |  12KB  |  374 lines

  1. /*++
  2.  
  3. Copyright (c) 1990 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     hostannc.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the data structures related to host announcements.
  12.  
  13. Author:
  14.  
  15.     Larry Osterman (LarryO) 22-Oct-1990
  16.  
  17. Revision History:
  18.  
  19.     22-Oct-1991  LarryO
  20.  
  21.         Created
  22.  
  23. --*/
  24.  
  25. #ifndef _HOSTANNC_
  26. #define _HOSTANNC_
  27.  
  28.  
  29. typedef enum _MailslotType {
  30.     MailslotTransaction = -2,
  31.     OtherTransaction = -1,
  32.     Illegal = 0,
  33.     HostAnnouncement = 1,
  34.     AnnouncementRequest = 2,
  35.     InterrogateInfoRequest = 3,
  36.     RelogonRequest = 4,
  37.     Election = 8,
  38.     GetBackupListReq = 9,
  39.     GetBackupListResp = 10,
  40.     BecomeBackupServer = 11,
  41.     WkGroupAnnouncement = 12,
  42.     MasterAnnouncement = 13,
  43.     ResetBrowserState = 14,
  44.     LocalMasterAnnouncement = 15,
  45.     MaximumMailslotType
  46. } MAILSLOTTYPE, *PMAILSLOTTYPE;
  47.  
  48. #define WORKSTATION_SIGNATURE       '\0'
  49. #define SERVER_SIGNATURE            ' '
  50. #define PRIMARY_DOMAIN_SIGNATURE    '\0'
  51. #define PRIMARY_CONTROLLER_SIGNATURE '\x1B'
  52. #define DOMAIN_CONTROLLER_SIGNATURE '\x1C'
  53. #define MASTER_BROWSER_SIGNATURE    '\x1D'
  54. #define BROWSER_ELECTION_SIGNATURE  '\x1E'
  55. #define DOMAIN_ANNOUNCEMENT_NAME    "\x01\x02__MSBROWSE__\x02\x01"
  56. //
  57. //  The following values should be the minimum and maximum of the
  58. //  mailslot transaction opcodes defined above.
  59. //
  60.  
  61. #define MIN_TRANSACT_MS_OPCODE          MailslotTransaction
  62. #define MAX_TRANSACT_MS_OPCODE          RelogonRequest
  63.  
  64. //
  65. //  Common name for reserved, `internal' transactions
  66. //
  67.  
  68. #define MAILSLOT_LANMAN_NAME SMB_MAILSLOT_PREFIX "\\LANMAN"
  69. #define MAILSLOT_BROWSER_NAME SMB_MAILSLOT_PREFIX "\\BROWSE"
  70. #define ANNOUNCEMENT_MAILSLOT_NAME     "\\\\*" ITRANS_MS_NAME
  71.  
  72.  
  73. #include <packon.h>
  74. //
  75. // Each visible server on the net periodically emits a host announcement.
  76. // This is a SMB TRANSACTION REQUEST on a reserved, "internal" name.
  77. //
  78.  
  79. //
  80. //  There are two versions of each of these structures defined.  The first,
  81. //  is the actual "meat" of the structure, the second includes the announcement
  82. //  type.
  83. //
  84.  
  85. //
  86. // Lan Manager announcement message.  This is used for opcodes:
  87. //
  88. //  HostAnnouncement to \MAILSLOT\LANMAN on the LANMAN domain name.
  89. //
  90.  
  91. typedef struct _HOST_ANNOUNCE_PACKET_1 {
  92.     UCHAR       CompatibilityPad;
  93.     ULONG       Type;
  94.     UCHAR       VersionMajor;   /* version of LM running on host */
  95.     UCHAR       VersionMinor;   /*  "  "   "   "    "    "    "   */
  96.     USHORT      Periodicity;   /* announcement cycle in secs   */
  97.     CHAR        NameComment[LM20_CNLEN+1+LM20_MAXCOMMENTSZ+1];
  98. } HOST_ANNOUNCE_PACKET_1, *PHOST_ANNOUNCE_PACKET_1;
  99.  
  100. typedef struct _HOST_ANNOUNCE_PACKET {
  101.     UCHAR       AnnounceType;
  102.     HOST_ANNOUNCE_PACKET_1 HostAnnouncement;
  103. } HOST_ANNOUNCE_PACKET, *PHOST_ANNOUNCE_PACKET;
  104.  
  105. //
  106. // General announcement message.  This is used for opcodes:
  107. //
  108. //  HostAnnouncement, WkGroupAnnouncement, and LocalMasterAnnouncement
  109. //
  110.  
  111. typedef struct _BROWSE_ANNOUNCE_PACKET_1 {
  112.     UCHAR       UpdateCount;    // Inc'ed when announce data changed.
  113.     ULONG       Periodicity;    // announcement cycle in milliseconds
  114.  
  115.     UCHAR       ServerName[LM20_CNLEN+1];
  116.     UCHAR       VersionMajor;
  117.     UCHAR       VersionMinor;   /*  "  "   "   "    "    "    "   */
  118.     ULONG       Type;           // Server type.
  119.     CHAR        *CommentPointer;
  120.     CHAR        Comment[LM20_MAXCOMMENTSZ+1];
  121. } BROWSE_ANNOUNCE_PACKET_1, *PBROWSE_ANNOUNCE_PACKET_1;
  122.  
  123. typedef struct _BROWSE_ANNOUNCE_PACKET {
  124.     UCHAR       BrowseType;
  125.     BROWSE_ANNOUNCE_PACKET_1 BrowseAnnouncement;
  126. } BROWSE_ANNOUNCE_PACKET, *PBROWSE_ANNOUNCE_PACKET;
  127. //
  128. //  The request announcement packet is sent by clients to request that
  129. //  remote servers announce themselves.
  130. //
  131.  
  132. typedef struct _REQUEST_ANNOUNCE_PACKET_1 {      // Contents of request announcement
  133.     UCHAR    Flags;                 // Unused Flags
  134.     CHAR     Reply[LM20_CNLEN+1];
  135. }  REQUEST_ANNOUNCE_PACKET_1, *PREQUEST_ANNOUNCE_PACKET_1;
  136.  
  137. typedef struct _REQUEST_ANNOUNCE_PACKET {        /* Request announcement struct */
  138.     UCHAR   Type;
  139.     REQUEST_ANNOUNCE_PACKET_1    RequestAnnouncement;
  140. } REQUEST_ANNOUNCE_PACKET, *PREQUEST_ANNOUNCE_PACKET;
  141.  
  142. #define HOST_ANNC_NAME(xx)     ((xx)->NameComment)
  143. #define HOST_ANNC_COMMENT(xx)  ((xx)->NameComment + (strlen(HOST_ANNC_NAME(xx))+1))
  144.  
  145. #define BROWSE_ANNC_NAME(xx)     ((xx)->ServerName)
  146. #define BROWSE_ANNC_COMMENT(xx)  ((xx)->Comment)
  147.  
  148. //
  149. //  Definitions for Windows Browser
  150. //
  151.  
  152. //
  153. //  Request to retrieve a backup server list.
  154. //
  155.  
  156. typedef struct _BACKUP_LIST_REQUEST_1 {
  157.     UCHAR       RequestedCount;
  158.     ULONG       Token;
  159. } BACKUP_LIST_REQUEST_1, *PBACKUP_LIST_REQUEST_1;
  160.  
  161.  
  162. typedef struct _BACKUP_LIST_REQUEST {
  163.     UCHAR  Type;
  164.     BACKUP_LIST_REQUEST_1 BackupListRequest;
  165. } BACKUP_LIST_REQUEST, *PBACKUP_LIST_REQUEST;
  166.  
  167. //
  168. //  Response containing a backup server list.
  169. //
  170.  
  171. typedef struct _BACKUP_LIST_RESPONSE_1 {
  172.     UCHAR       BackupServerCount;
  173.     ULONG       Token;
  174.     UCHAR       BackupServerList[1];
  175. } BACKUP_LIST_RESPONSE_1, *PBACKUP_LIST_RESPONSE_1;
  176.  
  177. typedef struct _BACKUP_LIST_RESPONSE {
  178.     UCHAR Type;
  179.     BACKUP_LIST_RESPONSE_1 BackupListResponse;
  180. } BACKUP_LIST_RESPONSE, *PBACKUP_LIST_RESPONSE;
  181.  
  182.  
  183. //
  184. //  Message indicating that a potential browser server should become a backup
  185. //  server.
  186. //
  187.  
  188. typedef struct _BECOME_BACKUP_1 {
  189.     UCHAR       BrowserToPromote[1];
  190. } BECOME_BACKUP_1, *PBECOME_BACKUP_1;
  191.  
  192. typedef struct _BECOME_BACKUP {
  193.     UCHAR Type;
  194.     BECOME_BACKUP_1 BecomeBackup;
  195. } BECOME_BACKUP, *PBECOME_BACKUP;
  196.  
  197.  
  198. //
  199. //  Sent during the election process.
  200. //
  201.  
  202. typedef struct _REQUEST_ELECTION_1 {
  203.     UCHAR       Version;
  204.     ULONG       Criteria;
  205.     ULONG       TimeUp;
  206.     ULONG       MustBeZero;
  207.     UCHAR       ServerName[1];
  208. } REQUEST_ELECTION_1, *PREQUEST_ELECTION_1;
  209.  
  210. typedef struct _REQUEST_ELECTION {
  211.     UCHAR Type;
  212.     REQUEST_ELECTION_1 ElectionRequest;
  213. } REQUEST_ELECTION, *PREQUEST_ELECTION;
  214.  
  215. #define ELECTION_CR_OSTYPE      0xFF000000L // Native OS running on server
  216. #define ELECTION_CR_OSWFW       0x01000000L //  Windows for workgroups server
  217. #define ELECTION_CR_WIN_NT      0x10000000L //  Windows/NT Server
  218. #define ELECTION_CR_LM_NT       0x20000000L //  Lan Manager for Windows/NT
  219.  
  220. #define ELECTION_CR_REVISION    0x00FFFF00L // Browser software revision
  221. #define ELECTION_MAKE_REV(major, minor) (((major)&0xffL)<<16|((minor)&0xFFL)<<8)
  222.  
  223. #define ELECTION_CR_DESIRE      0x000000FFL // Desirability of becoming master.
  224.  
  225. //
  226. //  Election desirability within criteria.
  227. //
  228. //  Most important is a running PDC, next is a configured domain master.
  229. //
  230. //  After that come running masters, then configured backups, then existing
  231. //  running backups.
  232. //
  233.  
  234. #define ELECTION_DESIRE_AM_BACKUP  0x00000001L // Currently is backup
  235. //                                     00000001
  236. #define ELECTION_DESIRE_AM_CFG_BKP 0x00000002L // Always want to be
  237. //                                     00000010
  238.                                                //  master - set if backup &&
  239.                                                //  MaintainServerList==YES
  240. #define ELECTION_DESIRE_AM_MASTER  0x00000004L // Currently is master
  241. //                            00000100
  242. #define ELECTION_DESIRE_AM_DOMMSTR 0x00000008L // Configured as domain master
  243. //                                     00001000
  244.  
  245. #define ELECTION_DESIRE_AM_PDC     0x00000080L // Machine is a lanman NT server.
  246. //                                     10000000
  247. //
  248. //  "Tickle" packet - sent to change state of browser.
  249. //
  250.  
  251. typedef struct _RESET_STATE_1 {
  252.     UCHAR       Options;
  253. } RESET_STATE_1, *PRESET_STATE_1;
  254.  
  255. typedef struct _RESET_STATE {
  256.     UCHAR Type;
  257.     RESET_STATE_1 ResetStateRequest;
  258. } RESET_STATE, *PRESET_STATE;
  259.  
  260. #define RESET_STATE_STOP_MASTER 0x01    // Stop being master
  261. #define RESET_STATE_CLEAR_ALL   0x02    // Clear all browser state.
  262. #define RESET_STATE_STOP        0x04    // Stop the browser service.
  263.  
  264. //
  265. //  Master Announcement - Send from master to domain master.
  266. //
  267.  
  268. typedef struct _MASTER_ANNOUNCEMENT_1 {
  269.     UCHAR       MasterName[1];
  270. } MASTER_ANNOUNCEMENT_1, *PMASTER_ANNOUNCEMENT_1;
  271.  
  272. typedef struct _MASTER_ANNOUNCEMENT {
  273.     UCHAR Type;
  274.     MASTER_ANNOUNCEMENT_1 MasterAnnouncement;
  275. } MASTER_ANNOUNCEMENT, *PMASTER_ANNOUNCEMENT;
  276.  
  277.  
  278. //
  279. //  Definitions for Workstation interrogation and revalidation transactions
  280. //
  281.  
  282. typedef struct _WKSTA_INFO_INTERROGATE_PACKET {
  283.     UCHAR   CompatibilityPad;
  284.     ULONG   Delay ;             // Number of milliseconds to wait before replying
  285.     CHAR    ReturnMailslot[1] ; // Mailslot to reply to.
  286. } WKSTA_INFO_INTERROGATE_PACKET, *PWKSTA_INFO_INTERROGATE_PACKET;
  287.  
  288. typedef struct _WKSTA_INFO_RESPONSE_PACKET {
  289.     UCHAR   CompatibilityPad;
  290.     UCHAR   VersionMajor;
  291.     UCHAR   VersionMinor;
  292.     USHORT  OsVersion ;
  293.     CHAR    ComputerName[1] ;       // var-length ASCIIZ string */
  294. #if 0
  295. //
  296. //  The following two ASCIIZ strings are not defined in the structure
  297. //  but are concatenated to the end of the structure.
  298. //
  299.     CHAR        UserName[] ;
  300.     CHAR        LogonDomain[] ;
  301. #endif
  302. } WKSTA_INFO_RESPONSE_PACKET, *PWKSTA_INFO_RESPONSE_PACKET;
  303.  
  304. typedef struct _WKSTA_RELOGON_REQUEST_PACKET {
  305.     UCHAR   CompatibilityPad;
  306.     ULONG   Delay ;
  307.     ULONG   Flags ;
  308.     CHAR    ReturnMailslot[1] ; // var-length ASCIIZ string
  309. #if 0
  310. //
  311. //  The following ASCIIZ string is not defined in the structure
  312. //  but is concatenated to the end of the structure.
  313. //
  314.  
  315.     CHAR    DC_Name[] ;
  316. #endif
  317. } WKSTA_RELOGON_REQUEST_PACKET, *PWKSTA_RELOGON_REQUEST_PACKET;
  318.  
  319. //
  320. //  Values for <wkrrq_flags> field */
  321. //
  322.  
  323. #define WKRRQ_FLAG_LOGON_SERVER      0x1    // I'm your official logon server;
  324.                                             // do a relogon to me.
  325.                                             //
  326.  
  327. typedef struct _WKSTA_RELOGON_RESPONSE_PACKET {
  328.     UCHAR   CompatibilityPad;
  329.     USHORT  Status ;
  330.     CHAR    ComputerName[1] ;   // var-length ASCIIZ string
  331. } WKSTA_RELOGON_RESPONSE_PACKET, *PWKSTA_RELOGON_RESPONSE_PACKET;
  332.  
  333.  
  334. //
  335. //  Values for <wkrrs_status> field
  336. //
  337.  
  338. #define WKRRS_STATUS_SUCCEEDED      0       // Operation succeeded
  339. #define WKRRS_STATUS_DENIED         1       // Operation denied to caller
  340. #define WKRRS_STATUS_FAILED         2       // Operation tried but failed
  341.  
  342. #define EXCESS_NAME_LEN (sizeof(ITRANS_MS_NAME) - \
  343.                             FIELD_OFFSET(SMB_TRANSACTION_MAILSLOT, Buffer) )
  344.  
  345. //
  346. //  This structure defines all of the types of requests that appear in messages
  347. //  to the internal mailslot.
  348. //
  349.  
  350. typedef struct _INTERNAL_TRANSACTION {
  351.     UCHAR   Type;                               // Type of request.
  352.     union {
  353.         HOST_ANNOUNCE_PACKET_1           Announcement ;
  354.         BROWSE_ANNOUNCE_PACKET_1         BrowseAnnouncement ;
  355.         REQUEST_ANNOUNCE_PACKET_1        RequestAnnounce ;
  356.         BACKUP_LIST_RESPONSE_1           GetBackupListResp ;
  357.         BACKUP_LIST_REQUEST_1            GetBackupListRequest ;
  358.         BECOME_BACKUP_1                  BecomeBackup ;
  359.         REQUEST_ELECTION_1               RequestElection ;
  360.         MASTER_ANNOUNCEMENT_1            MasterAnnouncement ;
  361.         RESET_STATE_1                    ResetState ;
  362.  
  363.         WKSTA_INFO_INTERROGATE_PACKET    InterrogateRequest ;
  364.         WKSTA_INFO_RESPONSE_PACKET       InterrogateResponse ;
  365.         WKSTA_RELOGON_REQUEST_PACKET     RelogonRequest ;
  366.         WKSTA_RELOGON_RESPONSE_PACKET    RelogonResponse ;
  367.     } Union;
  368. } INTERNAL_TRANSACTION, *PINTERNAL_TRANSACTION ;
  369.  
  370. #include <packoff.h>
  371.  
  372. #endif // _HOSTANNC_
  373.  
  374.