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 / browser.h < prev    next >
C/C++ Source or Header  |  1996-10-15  |  11KB  |  357 lines

  1.  
  2. //==========================================================================================================================
  3. //  MODULE: browser.h
  4. //
  5. //  Description:
  6. //
  7. //  Bloodhound parser DLL for MS Browser
  8. //
  9. //  Modification History
  10. //  Written by Scottji 6/94
  11. //
  12. //
  13. //==========================================================================================================================
  14.  
  15. // question:  need to look at bh.h and inilib.h
  16. #include <windows.h>
  17. #include <string.h>
  18. #include <bh.h>
  19. #include <parser.h>
  20. #include <inilib.h>
  21. #include <malloc.h>
  22. #include <stdlib.h>
  23.  
  24. //question:
  25. #pragma pack(1)
  26.  
  27. //
  28. // Browser Commands
  29. //
  30. #define HostAnnouncement                1   //  done
  31. #define AnnouncementRequest                2   //  done
  32. #define Election                    8   //
  33. #define GetBackupListReq                9   //  done
  34. #define GetBackupListResp                10  //a done
  35. #define BecomeBackup                    11  //b done
  36. #define WkGroupAnnouncement                12  //c change
  37. #define MasterAnnouncement                13  //d done
  38. #define ResetBrowserState                14  //e
  39. #define LocalMasterAnnouncement                15  //f done
  40.  
  41. //
  42. // Struct for Recognize Function
  43. //
  44. typedef struct _BrowserFRAME
  45. {
  46.     BYTE        command;
  47.     CHAR        data;
  48. } BrowserFRAME;
  49.  
  50. typedef BrowserFRAME UNALIGNED *LPBrowserFRAME;
  51.  
  52.  
  53. //
  54. // Lanman names from lmcons.h
  55. //
  56. #define CNLEN       15                  // Computer name length
  57. #define LM20_CNLEN  15                  // LM 2.0 Computer name length
  58. #define DNLEN       CNLEN               // Maximum domain name length
  59. #define LM20_DNLEN  LM20_CNLEN          // LM 2.0 Maximum domain name length
  60.  
  61.  
  62. //
  63. // Mailslot name strings.
  64. //
  65. #define SMB_MAILSLOT_PREFIX "\\MAILSLOT"
  66. #define UNICODE_SMB_MAILSLOT_PREFIX L"\\MAILSLOT"
  67. #define SMB_MAILSLOT_PREFIX_LENGTH (sizeof(SMB_MAILSLOT_PREFIX) - 1)
  68. #define UNICODE_SMB_MAILSLOT_PREFIX_LENGTH \
  69.                     (sizeof(UNICODE_SMB_MAILSLOT_PREFIX) - sizeof(WCHAR))
  70.  
  71. #define MAILSLOT_LANMAN_NAME SMB_MAILSLOT_PREFIX "\\LANMAN"
  72. #define MAILSLOT_BROWSER_NAME SMB_MAILSLOT_PREFIX "\\BROWSE"
  73. //#define ANNOUNCEMENT_MAILSLOT_NAME     "\\\\*" ITRANS_MS_NAME
  74. #define MAXCOMMENTSZ 256                // Multipurpose comment length
  75. #define LM20_MAXCOMMENTSZ 48            // LM 2.0 Multipurpose comment length
  76.  
  77.  
  78. //
  79. //Browser netbios name extensions.
  80. //
  81. #define WORKSTATION_SIGNATURE       '\0'
  82. #define SERVER_SIGNATURE            ' '
  83. #define PRIMARY_DOMAIN_SIGNATURE    '\0'
  84. #define PRIMARY_CONTROLLER_SIGNATURE '\x1B'
  85. #define DOMAIN_CONTROLLER_SIGNATURE '\x1C'
  86. #define MASTER_BROWSER_SIGNATURE    '\x1D'
  87. #define BROWSER_ELECTION_SIGNATURE  '\x1E'
  88. #define DOMAIN_ANNOUNCEMENT_NAME    "\x01\x02__MSBROWSE__\x02\x01"
  89.  
  90.  
  91. //
  92. //  AnnouncementRequest
  93. //
  94. //  The request announcement packet is sent by clients to request that
  95. //  remote servers announce themselves.
  96. //
  97.  
  98. typedef struct _REQUEST_ANNOUNCE_PACKET_1 {      // Contents of request announcement
  99.     UCHAR    Type;
  100.     UCHAR    Flags;                 // Unused Flags
  101.     CHAR     Reply[LM20_CNLEN+1];
  102. }  REQUEST_ANNOUNCE_PACKET_1, UNALIGNED *LP_ANNC_REQ;
  103.  
  104. //typedef REQUEST_ANNOUNCE_PACKET_1 UNALIGNED *LP_ANNC_REQ;
  105.  
  106.  
  107. //  HostAnnouncement and LocalMasterAnnouncement
  108. //
  109. // General announcement message.  This is used for opcodes:
  110. //
  111. //
  112.  
  113. typedef struct _BROWSE_ANNOUNCE_PACKET_1 {
  114.     UCHAR       BrowseType;
  115.     UCHAR       UpdateCount;    // Inc'ed when announce data changed.
  116.     ULONG       Periodicity;    // announcement cycle in milliseconds
  117.  
  118.     UCHAR       ServerName[LM20_CNLEN+1];
  119.     UCHAR       VersionMajor;
  120.     UCHAR       VersionMinor;   /*  "  "   "   "    "    "    "   */
  121.     ULONG       Type;           // Server type.
  122.     WORD        HAElectionVersion;
  123.     WORD    HAConstant;
  124.     CHAR        Comment[LM20_MAXCOMMENTSZ+1];
  125. } BROWSE_ANNOUNCE_PACKET, UNALIGNED *LP_HA_FRAME;
  126.  
  127. // WkGroupAnnouncement
  128. //
  129. //
  130. typedef struct _WKGRP_ANNOUNCE_PACKET_1 {
  131.     UCHAR       BrowseType;
  132.     UCHAR       UpdateCount;    // Inc'ed when announce data changed.
  133.     ULONG       Periodicity;    // announcement cycle in milliseconds
  134.  
  135.     UCHAR       ServerName[LM20_CNLEN+1];
  136.     UCHAR       VersionMajor;
  137.     UCHAR       VersionMinor;   /*  "  "   "   "    "    "    "   */
  138.     ULONG       Type;           // Server type.
  139.     ULONG       CommentPtr;
  140.     CHAR        Comment[LM20_MAXCOMMENTSZ+1];
  141. } WKGRP_ANNOUNCE_PACKET, UNALIGNED *LP_WKGRP_FRAME;
  142.  
  143.  
  144. // GetBackupListReq
  145. //
  146. //
  147. typedef struct _BACKUP_LIST_REQUEST_1 {
  148.     UCHAR    Type;
  149.     UCHAR       RequestedCount;
  150.     ULONG       Token;
  151. } BACKUP_LIST_REQUEST_1, UNALIGNED *LP_BACK_REQ_FRAME;
  152.  
  153.  
  154.  
  155. //  BackupListResp
  156. //  Response containing a backup server list.
  157. //
  158.  
  159. typedef struct _BACKUP_LIST_RESPONSE_1 {
  160.     UCHAR     Type;
  161.     UCHAR       BackupServerCount;
  162.     ULONG       Token;
  163.     UCHAR       BackupServerList[51];
  164. } BACKUP_LIST_RESPONSE_1, UNALIGNED *LP_BACK_RESP;
  165.  
  166.  
  167.  
  168. //  BecomeBackup
  169. //  Message indicating that a potential browser server should become a backup
  170. //  server.
  171. //
  172. typedef struct _BECOME_BACKUP_1 {
  173.     UCHAR     Type;
  174.     UCHAR       BrowserToPromote[1];
  175. } BECOME_BACKUP_1;
  176.  
  177. typedef BECOME_BACKUP_1 UNALIGNED *LP_BECOME_BACKUP;
  178.  
  179.  
  180.  
  181. //  MasterAnnouncement
  182. //  Send from master to domain master.
  183. //
  184.  
  185. typedef struct _MASTER_ANNOUNCEMENT_1 {
  186.     UCHAR     Type;
  187.     UCHAR       MasterName[16];
  188. } MASTER_ANNOUNCEMENT_1, UNALIGNED *LP_MASTER_ANNC;
  189.  
  190.  
  191.  
  192. //  Election
  193. //  Sent during the election process.
  194. //
  195.  
  196. typedef struct _REQUEST_ELECTION_1 {
  197.     UCHAR     Type;
  198.     UCHAR       Version;
  199.     ULONG       Criteria;
  200.     ULONG       TimeUp;
  201.     ULONG       MustBeZero;
  202.     UCHAR       ServerName[1];
  203. } REQUEST_ELECTION_1, UNALIGNED *LP_ELECTION;
  204.  
  205.  
  206. #define ELECTION_CR_OSTYPE      0xFF000000L // Native OS running on server
  207. #define ELECTION_CR_OSWFW       0x01000000L //  Windows for workgroups server
  208. #define ELECTION_CR_WIN_NT      0x10000000L //  Windows/NT Server
  209. #define ELECTION_CR_LM_NT       0x20000000L //  Lan Manager for Windows/NT
  210.  
  211. #define ELECTION_CR_REVISION    0x00FFFF00L // Browser software revision
  212. #define ELECTION_MAKE_REV(major, minor) (((major)&0xffL)<<16|((minor)&0xFFL)<<8)
  213.  
  214. #define ELECTION_CR_DESIRE      0x000000FFL // Desirability of becoming master.
  215.  
  216. //
  217. //  Election desirability within criteria.
  218. //
  219. //  Most important is a running PDC, next is a configured domain master.
  220. //
  221. //  After that come running masters, then configured backups, then existing
  222. //  running backups.
  223. //
  224.  
  225. #define ELECTION_DESIRE_AM_BACKUP  0x00000001L // Currently is backup
  226. #define ELECTION_DESIRE_AM_CFG_BKP 0x00000002L // Always want to be
  227.                                                //  master - set if backup &&
  228.                                                //  MaintainServerList==YES
  229. #define ELECTION_DESIRE_AM_MASTER  0x00000004L // Currently is master
  230. #define ELECTION_DESIRE_AM_DOMMSTR 0x00000008L // Configured as domain master
  231.  
  232. #define ELECTION_DESIRE_AM_PDC     0x00000080L // Machine is a lanman NT server.
  233.  
  234. // Machines running WINS client are important because they are more capable
  235. // of connecting to a PDC who's address was configured via DHCP.
  236.  
  237. #define ELECTION_DESIRE_WINS_CLIENT 0x00000020L // Transport running WINS client
  238.  
  239.  
  240. // ResetBrowserState
  241. //  "Tickle" packet - sent to change state of browser.
  242. //
  243.  
  244. typedef struct _RESET_STATE_1 {
  245.         UCHAR     Type;
  246.         UCHAR   Options;
  247. } RESET_STATE_1, *LP_RESET;
  248.  
  249. #define RESET_STATE_STOP_MASTER 0x01    // Stop being master
  250. #define RESET_STATE_CLEAR_ALL   0x02    // Clear all browser state.
  251. #define RESET_STATE_STOP        0x04    // Stop the browser service.
  252.  
  253.  
  254. //
  255. // Type Server
  256. //
  257. #define    SV_TYPE_WORKSTATION        0x00000001
  258. #define    SV_TYPE_SERVER            0x00000002
  259. #define    SV_TYPE_SQLSERVER        0x00000004
  260. #define    SV_TYPE_DOMAIN_CTRL        0x00000008
  261. #define    SV_TYPE_DOMAIN_BAKCTRL        0x00000010
  262. #define    SV_TYPE_TIME_SOURCE        0x00000020
  263. #define    SV_TYPE_AFP            0x00000040
  264. #define    SV_TYPE_NOVELL            0x00000080
  265. #define    SV_TYPE_DOMAIN_MEMBER        0x00000100
  266. #define    SV_TYPE_PRINTQ_SERVER        0x00000200
  267. #define    SV_TYPE_DIALIN_SERVER        0x00000400
  268. #define    SV_TYPE_XENIX_SERVER        0x00000800
  269. #define    SV_TYPE_NT            0x00001000
  270. #define    SV_TYPE_POTENTIAL_BROWSER    0x00010000
  271. #define    SV_TYPE_BACKUP_BROWSER        0x00020000
  272. #define    SV_TYPE_MASTER_BROWSER        0x00040000
  273. #define    SV_TYPE_DOMAIN_MASTER        0x00080000
  274. #define    SV_TYPE_LOCAL_LIST_ONLY        0x40000000
  275. #define    SV_TYPE_DOMAIN_ENUM        0x80000000
  276.  
  277.  
  278. //===========================================================================
  279. //  Function prototypes.
  280. //===========================================================================
  281.  
  282. // question:  what other functions?
  283.  
  284. extern VOID  WINAPIV BrowserFormatSummary(LPPROPERTYINST lpPropertyInst);
  285. extern VOID  WINAPIV BrowserFormatCommand(LPPROPERTYINST lpPropertyInst);
  286. extern VOID  WINAPIV FormatBrowserSummary(LPPROPERTYINST lpPropertyInst);
  287.  
  288. //=============================================================================
  289. //  Helper functions.
  290. //=============================================================================
  291.  
  292. //question: what helper functions?
  293.  
  294. // extern WORD   WINAPI GetBrowserFrameSize(LPBrowser Frame);
  295.  
  296.  
  297. //=============================================================================
  298. //  Format Table.
  299. //=============================================================================
  300. // question:  what is this?
  301.  
  302.  
  303. //=============================================================================
  304. //  Manifests for Creating Handoff Set
  305. //=============================================================================
  306.  
  307. //question: what is handoff set?
  308.  
  309. //#define MAX_SAPS            50
  310. //#define MAX_ETYPES          50
  311.  
  312. #define ELECTION_DESIRE_AM_BACKUP  0x00000001L // Currently is backup
  313. #define ELECTION_DESIRE_AM_CFG_BKP 0x00000002L // Always want to be
  314.  
  315.  
  316. #pragma pack()
  317.  
  318. //=============================================================================
  319. //  Property table index constants
  320. //=============================================================================
  321.  
  322. #define Browser_COMMAND             0
  323. #define Browser_SUMMARY             1
  324. #define HA_UpdateCount            2
  325. #define HA_Periodicity            3
  326. #define HA_ServerName            4
  327. #define HA_VersionMajor            5
  328. #define HA_VersionMinor            6
  329. #define HA_Type_Flag_Summary        7
  330. #define HA_Type                8
  331. #define HA_ElectionVersion        9
  332. #define HA_Constant            10
  333. #define AR_Flags            11
  334. #define AR_Reply            12
  335. #define BREQ_RequestedCount        13
  336. #define BREQ_Token            14
  337. #define BRSP_ServerCnt            15
  338. #define BRSP_Token            16
  339. #define BRSP_ServerList            17
  340. #define MA_MasterName            18
  341. #define ELEC_Version            19
  342. #define ELEC_Criteria            20
  343. #define ELEC_TimeUp            21
  344. #define ELEC_MustBeZero            22
  345. #define ELEC_ServerName            23
  346. #define ELEC_OS_Summary            24
  347. #define ELEC_OS                25
  348. #define ELEC_Revision            26
  349. #define ELEC_Desire_Summary        27
  350. #define ELEC_Desire            28
  351. #define RST_Options            29
  352. #define WKGRP_CommentPtr        30
  353. #define WKGRP_Comment            31
  354. #define RST_Options_Summary        32
  355. //#define WKGRP_VersionMajor            5
  356. //#define WKGRP_VersionMinor            6
  357.