Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

369 lines
14 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. global.h
  7. Global defines for the DHCP snapin
  8. FILE HISTORY:
  9. */
  10. // message that gets posted to statistics windows to update their stats
  11. #define WM_NEW_STATS_AVAILABLE WM_USER + 100
  12. // percentage of addresses in use to generate a warning for a scope
  13. #define SCOPE_WARNING_LEVEL 90
  14. // Defines for help from the help menu and F1 help for scope pane items
  15. #define DHCPSNAP_HELP_BASE 0xA0000000
  16. #define DHCPSNAP_HELP_SNAPIN DHCPSNAP_HELP_BASE + 1
  17. #define DHCPSNAP_HELP_ROOT DHCPSNAP_HELP_BASE + 2
  18. #define DHCPSNAP_HELP_SERVER DHCPSNAP_HELP_BASE + 3
  19. #define DHCPSNAP_HELP_SCOPE DHCPSNAP_HELP_BASE + 4
  20. #define DHCPSNAP_HELP_SUPERSCOPE DHCPSNAP_HELP_BASE + 5
  21. #define DHCPSNAP_HELP_BOOTP_TABLE DHCPSNAP_HELP_BASE + 6
  22. #define DHCPSNAP_HELP_GLOBAL_OPTIONS DHCPSNAP_HELP_BASE + 7
  23. #define DHCPSNAP_HELP_ADDRESS_POOL DHCPSNAP_HELP_BASE + 8
  24. #define DHCPSNAP_HELP_ACTIVE_LEASES DHCPSNAP_HELP_BASE + 9
  25. #define DHCPSNAP_HELP_RESERVATIONS DHCPSNAP_HELP_BASE + 10
  26. #define DHCPSNAP_HELP_SCOPE_OPTIONS DHCPSNAP_HELP_BASE + 11
  27. #define DHCPSNAP_HELP_RESERVATION_CLIENT DHCPSNAP_HELP_BASE + 12
  28. #define DHCPSNAP_HELP_ACTIVE_LEASE DHCPSNAP_HELP_BASE + 13
  29. #define DHCPSNAP_HELP_ALLOCATION_RANGE DHCPSNAP_HELP_BASE + 14
  30. #define DHCPSNAP_HELP_EXCLUSION_RANGE DHCPSNAP_HELP_BASE + 15
  31. #define DHCPSNAP_HELP_BOOTP_ENTRY DHCPSNAP_HELP_BASE + 16
  32. #define DHCPSNAP_HELP_OPTION_ITEM DHCPSNAP_HELP_BASE + 17
  33. #define DHCPSNAP_HELP_CLASSID_HOLDER DHCPSNAP_HELP_BASE + 18
  34. #define DHCPSNAP_HELP_CLASSID DHCPSNAP_HELP_BASE + 19
  35. #define DHCPSNAP_HELP_MSCOPE DHCPSNAP_HELP_BASE + 20
  36. #define DHCPSNAP_HELP_MCAST_LEASE DHCPSNAP_HELP_BASE + 21
  37. // wait cursor stuff around functions. If you need a wait cursor for
  38. // and entire fucntion, just use CWaitCursor. To wrap a wait cursor
  39. // around an rpc call, use these macros.
  40. #define BEGIN_WAIT_CURSOR { CWaitCursor waitCursor;
  41. #define RESTORE_WAIT_CURSOR waitCursor.Restore();
  42. #define END_WAIT_CURSOR }
  43. #define ARRAYLEN(x) (sizeof(x) / sizeof((x)[0]))
  44. // some defines for options that we get/set explicitly
  45. #define MADCAP_OPTION_LEASE_TIME 1
  46. #define OPTION_LEASE_DURATION 51
  47. #define OPTION_DNS_REGISTATION 81
  48. // HRESULT Mapping
  49. #define WIN32_FROM_HRESULT(hr) (0x0000FFFF & (hr))
  50. // Dynamic DNS defines
  51. #define DHCP_DYN_DNS_DEFAULT DNS_FLAG_ENABLED | DNS_FLAG_CLEANUP_EXPIRED;
  52. // notification and struct for toolbars
  53. #define DHCP_MSG_CONTROLBAR_NOTIFY 100
  54. typedef struct _DHCP_TOOLBAR_NOTIFY
  55. {
  56. MMC_COOKIE cookie;
  57. LPTOOLBAR pToolbar;
  58. LPCONTROLBAR pControlbar;
  59. MMC_NOTIFY_TYPE event;
  60. LONG_PTR id;
  61. BOOL bSelect;
  62. } DHCPTOOLBARNOTIFY, * LPDHCPTOOLBARNOTIFY;
  63. //
  64. // Registry constants-- key and value names
  65. //
  66. #define DHCP_REG_USER_KEY_NAME _T("Software\\Microsoft\\DHCP Admin Tool")
  67. #define DHCP_REG_VALUE_HOSTS _T("KnownHosts")
  68. // multicast address defines
  69. #define MCAST_ADDRESS_MIN 0xE0000000
  70. #define MCAST_ADDRESS_MAX 0xEFFFFFFF
  71. #define MCAST_SCOPED_RANGE_MIN 0xEF000000
  72. #define MCAST_SCOPED_RANGE_MIX 0xEFFFFFFF
  73. // macro to get the handler for a node. This is a DHCP snapin specific
  74. // implementation
  75. #define GETHANDLER(classname, node) (reinterpret_cast<classname *>(node->GetData(TFS_DATA_USER)))
  76. // used for notifing views to update
  77. // must not conflict with the RESULT_PANE notifications in tfsnode.h
  78. #define DHCPSNAP_UPDATE_OPTIONS 0x10000000
  79. #define DHCPSNAP_UPDATE_TOOLBAR 0x20000000
  80. // Version Suff
  81. #define DHCPSNAP_MAJOR_VERSION 0x00000001
  82. #define DHCPSNAP_MINOR_VERSION 0x00000000
  83. extern LARGE_INTEGER gliDhcpsnapVersion;
  84. #define DHCPSNAP_FILE_VERSION 0x00000002
  85. // defines for maximum lease time entries
  86. #define HOURS_MAX 23
  87. #define MINUTES_MAX 59
  88. // constants for time conversion
  89. #define MILLISEC_PER_SECOND 1000
  90. #define MILLISEC_PER_MINUTE (60 * MILLISEC_PER_SECOND)
  91. #define MILLISEC_PER_HOUR (60 * MILLISEC_PER_MINUTE)
  92. #define DHCPSNAP_REFRESH_INTERVAL_DEFAULT (10 * MILLISEC_PER_MINUTE) // 10 minutes in milliseconds
  93. // macros for memory exception handling
  94. #define CATCH_MEM_EXCEPTION \
  95. TRY
  96. #define END_MEM_EXCEPTION(err) \
  97. CATCH_ALL(e) { \
  98. err = ERROR_NOT_ENOUGH_MEMORY ; \
  99. } END_CATCH_ALL
  100. // some global defines we need
  101. #define STRING_LENGTH_MAX 256
  102. #define EDIT_ARRAY_MAX 2048
  103. #define EDIT_STRING_MAX STRING_LENGTH_MAX
  104. #define EDIT_ID_MAX 3
  105. // The maximum length of names supported by the server
  106. // Typically this is the scope name, sscope name, etc.
  107. #define MAX_NAME_LENGTH 255
  108. #define IP_ADDDRESS_LENGTH_MAX 16
  109. #define DHCP_INFINIT_LEASE 0xffffffff // Inifinite lease LONG value
  110. // DHCP Server version defines
  111. #define DHCP_NT4_VERSION 0x0000000400000000
  112. #define DHCP_SP2_VERSION 0x0000000400000001
  113. #define DHCP_NT5_VERSION 0x0000000500000000
  114. #define DHCP_NT51_VERSION 0x0000000500000006
  115. // Note - These are offsets into my toolbar image list
  116. typedef enum _TOOLBAR_IMAGE_INDICIES
  117. {
  118. TOOLBAR_IDX_ADD_SERVER,
  119. TOOLBAR_IDX_REFRESH,
  120. TOOLBAR_IDX_CREATE_SCOPE,
  121. TOOLBAR_IDX_CREATE_SUPERSCOPE,
  122. TOOLBAR_IDX_DEACTIVATE,
  123. TOOLBAR_IDX_ACTIVATE,
  124. TOOLBAR_IDX_ADD_BOOTP,
  125. TOOLBAR_IDX_ADD_RESERVATION,
  126. TOOLBAR_IDX_ADD_EXCLUSION,
  127. TOOLBAR_IDX_OPTION_GLOBAL,
  128. TOOLBAR_IDX_OPTION_SCOPE,
  129. TOOLBAR_IDX_OPTION_RESERVATION,
  130. TOOLBAR_IDX_MAX
  131. } TOOLBAR_IMAGE_INDICIES, * LPTOOLBAR_IMAGE_INDICIES;
  132. typedef enum _ICON_IMAGE_INDICIES
  133. {
  134. ICON_IDX_ACTIVE_LEASES_FOLDER_OPEN,
  135. ICON_IDX_ACTIVE_LEASES_LEAF,
  136. ICON_IDX_ACTIVE_LEASES_FOLDER_CLOSED,
  137. ICON_IDX_ACTIVE_LEASES_FOLDER_OPEN_BUSY,
  138. ICON_IDX_ACTIVE_LEASES_LEAF_BUSY,
  139. ICON_IDX_ACTIVE_LEASES_FOLDER_CLOSED_BUSY,
  140. ICON_IDX_ACTIVE_LEASES_FOLDER_OPEN_LOST_CONNECTION,
  141. ICON_IDX_ACTIVE_LEASES_LEAF_LOST_CONNECTION,
  142. ICON_IDX_ACTIVE_LEASES_FOLDER_CLOSED_LOST_CONNECTION,
  143. ICON_IDX_ADDR_POOL_FOLDER_OPEN,
  144. ICON_IDX_ADDR_POOL_LEAF, //10
  145. ICON_IDX_ADDR_POOL_FOLDER_CLOSED,
  146. ICON_IDX_ADDR_POOL_FOLDER_OPEN_BUSY,
  147. ICON_IDX_ADDR_POOL_LEAF_BUSY,
  148. ICON_IDX_ADDR_POOL_FOLDER_CLOSED_BUSY,
  149. ICON_IDX_ADDR_POOL_FOLDER_OPEN_LOST_CONNECTION,
  150. ICON_IDX_ADDR_POOL_LEAF_LOST_CONNECTION,
  151. ICON_IDX_ADDR_POOL_FOLDER_CLOSED_LOST_CONNECTION,
  152. ICON_IDX_ALLOCATION_RANGE,
  153. ICON_IDX_BOOTP_ENTRY,
  154. ICON_IDX_BOOTP_TABLE_CLOSED, //20
  155. ICON_IDX_BOOTP_TABLE_OPEN,
  156. ICON_IDX_BOOTP_TABLE_CLOSED_BUSY,
  157. ICON_IDX_BOOTP_TABLE_OPEN_BUSY,
  158. ICON_IDX_BOOTP_TABLE_CLOSED_LOST_CONNECTION,
  159. ICON_IDX_BOOTP_TABLE_OPEN_LOST_CONNECTION,
  160. ICON_IDX_CLIENT,
  161. ICON_IDX_CLIENT_DNS_REGISTERING,
  162. ICON_IDX_CLIENT_EXPIRED,
  163. ICON_IDX_CLIENT_RAS,
  164. ICON_IDX_CLIENT_OPTION_FOLDER_OPEN, //30
  165. ICON_IDX_CLIENT_OPTION_LEAF,
  166. ICON_IDX_CLIENT_OPTION_FOLDER_CLOSED,
  167. ICON_IDX_CLIENT_OPTION_FOLDER_OPEN_BUSY,
  168. ICON_IDX_CLIENT_OPTION_LEAF_BUSY,
  169. ICON_IDX_CLIENT_OPTION_FOLDER_CLOSED_BUSY,
  170. ICON_IDX_CLIENT_OPTION_FOLDER_OPEN_LOST_CONNECTION,
  171. ICON_IDX_CLIENT_OPTION_LEAF_LOST_CONNECTION,
  172. ICON_IDX_CLIENT_OPTION_FOLDER_CLOSED_LOST_CONNECTION,
  173. ICON_IDX_EXCLUSION_RANGE,
  174. ICON_IDX_FOLDER_CLOSED, //40
  175. ICON_IDX_FOLDER_OPEN,
  176. ICON_IDX_RES_CLIENT,
  177. ICON_IDX_RES_CLIENT_BUSY,
  178. ICON_IDX_RES_CLIENT_LOST_CONNECTION,
  179. ICON_IDX_RESERVATIONS_FOLDER_OPEN,
  180. ICON_IDX_RESERVATIONS_FOLDER_CLOSED,
  181. ICON_IDX_RESERVATIONS_FOLDER_OPEN_BUSY,
  182. ICON_IDX_RESERVATIONS_FOLDER_CLOSED_BUSY,
  183. ICON_IDX_RESERVATIONS_FOLDER_OPEN_LOST_CONNECTION,
  184. ICON_IDX_RESERVATIONS_FOLDER_CLOSED_LOST_CONNECTION, //50
  185. ICON_IDX_SCOPE_OPTION_FOLDER_OPEN,
  186. ICON_IDX_SCOPE_OPTION_LEAF,
  187. ICON_IDX_SCOPE_OPTION_FOLDER_CLOSED,
  188. ICON_IDX_SCOPE_OPTION_FOLDER_OPEN_BUSY,
  189. ICON_IDX_SCOPE_OPTION_LEAF_BUSY,
  190. ICON_IDX_SCOPE_OPTION_FOLDER_CLOSED_BUSY,
  191. ICON_IDX_SCOPE_OPTION_FOLDER_OPEN_LOST_CONNECTION,
  192. ICON_IDX_SCOPE_OPTION_FOLDER_CLOSED_LOST_CONNECTION,
  193. ICON_IDX_SCOPE_OPTION_LEAF_LOST_CONNECTION,
  194. ICON_IDX_SERVER, //60
  195. ICON_IDX_SERVER_ALERT,
  196. ICON_IDX_SERVER_BUSY,
  197. ICON_IDX_SERVER_CONNECTED,
  198. ICON_IDX_SERVER_GROUP,
  199. ICON_IDX_SERVER_ROGUE,
  200. ICON_IDX_SERVER_LOST_CONNECTION,
  201. ICON_IDX_SERVER_NO_ACCESS,
  202. ICON_IDX_SERVER_WARNING,
  203. ICON_IDX_SERVER_OPTION_FOLDER_OPEN,
  204. ICON_IDX_SERVER_OPTION_LEAF, //70
  205. ICON_IDX_SERVER_OPTION_FOLDER_CLOSED,
  206. ICON_IDX_SERVER_OPTION_FOLDER_OPEN_BUSY,
  207. ICON_IDX_SERVER_OPTION_LEAF_BUSY,
  208. ICON_IDX_SERVER_OPTION_FOLDER_CLOSED_BUSY,
  209. ICON_IDX_SERVER_OPTION_FOLDER_OPEN_LOST_CONNECTION,
  210. ICON_IDX_SERVER_OPTION_LEAF_LOST_CONNECTION,
  211. ICON_IDX_SERVER_OPTION_FOLDER_CLOSED_LOST_CONNECTION,
  212. ICON_IDX_SCOPE_FOLDER_OPEN,
  213. ICON_IDX_SCOPE_FOLDER_OPEN_BUSY,
  214. ICON_IDX_SCOPE_FOLDER_CLOSED_BUSY, //80
  215. ICON_IDX_SCOPE_FOLDER_OPEN_WARNING,
  216. ICON_IDX_SCOPE_FOLDER_CLOSED_WARNING,
  217. ICON_IDX_SCOPE_FOLDER_OPEN_LOST_CONNECTION,
  218. ICON_IDX_SCOPE_FOLDER_CLOSED_LOST_CONNECTION,
  219. ICON_IDX_SCOPE_FOLDER_OPEN_ALERT,
  220. ICON_IDX_SCOPE_INACTIVE_FOLDER_OPEN,
  221. ICON_IDX_SCOPE_INACTIVE_FOLDER_CLOSED,
  222. ICON_IDX_SCOPE_INACTIVE_FOLDER_OPEN_LOST_CONNECTION,
  223. ICON_IDX_SCOPE_INACTIVE_FOLDER_CLOSED_LOST_CONNECTION,
  224. ICON_IDX_SCOPE_FOLDER_CLOSED, //90
  225. ICON_IDX_SCOPE_FOLDER_CLOSED_ALERT,
  226. ICON_IDX_APPLICATION,
  227. ICON_IDX_MAX
  228. } ICON_IMAGE_INDICIES, * LPICON_IMAGE_INDICIES;
  229. // Constants used in for column information
  230. const int MAX_COLUMNS = 7;
  231. const int NUM_CONSOLE_VERBS = 8;
  232. const int NUM_SCOPE_ITEMS = 14;
  233. // Sample folder types
  234. enum NODETYPES
  235. {
  236. // scope pane items
  237. DHCPSNAP_ROOT,
  238. DHCPSNAP_SERVER,
  239. DHCPSNAP_BOOTP_TABLE,
  240. DHCPSNAP_SUPERSCOPE,
  241. DHCPSNAP_SCOPE,
  242. DHCPSNAP_MSCOPE,
  243. DHCPSNAP_ADDRESS_POOL,
  244. DHCPSNAP_ACTIVE_LEASES,
  245. DHCPSNAP_MSCOPE_LEASES,
  246. DHCPSNAP_RESERVATIONS,
  247. DHCPSNAP_RESERVATION_CLIENT,
  248. DHCPSNAP_SCOPE_OPTIONS,
  249. DHCPSNAP_GLOBAL_OPTIONS,
  250. DHCPSNAP_CLASSID_HOLDER,
  251. // result pane items
  252. DHCPSNAP_ACTIVE_LEASE,
  253. DHCPSNAP_ALLOCATION_RANGE,
  254. DHCPSNAP_EXCLUSION_RANGE,
  255. DHCPSNAP_BOOTP_ENTRY,
  256. DHCPSNAP_OPTION_ITEM,
  257. DHCPSNAP_CLASSID,
  258. DHCPSNAP_MCAST_LEASE,
  259. DHCPSNAP_NODETYPE_MAX
  260. };
  261. // GUIDs are defined in guids.cpp
  262. extern const CLSID CLSID_DhcpSnapin; // In-Proc server GUID
  263. extern const CLSID CLSID_DhcpSnapinExtension; // In-Proc server GUID
  264. extern const CLSID CLSID_DhcpSnapinAbout; // In-Proc server GUID
  265. extern const GUID GUID_DhcpRootNodeType; // Root NodeType GUID
  266. extern const GUID GUID_DhcpServerNodeType; // Server NodeType GUID
  267. extern const GUID GUID_DhcpScopeNodeType; // Scope NodeType GUID
  268. extern const GUID GUID_DhcpMScopeNodeType; // MScope NodeType GUID
  269. extern const GUID GUID_DhcpBootpNodeType; // Bootp NodeType GUID
  270. extern const GUID GUID_DhcpGlobalOptionsNodeType; // GlobalOptions NodeType GUID
  271. extern const GUID GUID_DhcpClassIdHolderNodeType; // ClassId Scope NodeType GUID
  272. extern const GUID GUID_DhcpSuperscopeNodeType; // Superscope NodeType GUID
  273. extern const GUID GUID_DhcpAddressPoolNodeType; // AddressPool NodeType GUID
  274. extern const GUID GUID_DhcpActiveLeasesNodeType; // ActiveLeases NodeType GUID
  275. extern const GUID GUID_DhcpReservationsNodeType; // Reservations NodeType GUID
  276. extern const GUID GUID_DhcpScopeOptionsNodeType; // ScopeOptions NodeType GUID
  277. extern const GUID GUID_DhcpReservationClientNodeType; // Reservation Client NodeType GUID
  278. extern const GUID GUID_DhcpAllocationNodeType; // Allocation range NodeType GUID
  279. extern const GUID GUID_DhcpExclusionNodeType; // Exlusion range NodeType GUID
  280. extern const GUID GUID_DhcpBootpEntryNodeType; // BootpEntry NodeType GUID
  281. extern const GUID GUID_DhcpActiveLeaseNodeType; // ActiveLease NodeType GUID
  282. extern const GUID GUID_DhcpOptionNodeType; // Option NodeType GUID
  283. extern const GUID GUID_DhcpClassIdNodeType; // ClassId (result pane) NodeType GUID
  284. extern const GUID GUID_DhcpMCastLeaseNodeType; // Multicast lease (result pane) NodeType GUID
  285. extern const GUID GUID_DhcpMCastAddressPoolNodeType; // AddressPool NodeType GUID (multicast scope)
  286. extern const GUID GUID_DhcpMCastActiveLeasesNodeType; // ActiveLeases NodeType GUID (multicast scope)
  287. // arrays used to hold all of the result pane column information
  288. extern UINT aColumns[DHCPSNAP_NODETYPE_MAX][MAX_COLUMNS];
  289. extern int aColumnWidths[DHCPSNAP_NODETYPE_MAX][MAX_COLUMNS];
  290. // arrays for toolbar information
  291. extern MMCBUTTON g_SnapinButtons[TOOLBAR_IDX_MAX];
  292. extern int g_SnapinButtonStrings[TOOLBAR_IDX_MAX][2];
  293. extern MMC_BUTTON_STATE g_SnapinButtonStates[DHCPSNAP_NODETYPE_MAX][TOOLBAR_IDX_MAX];
  294. // arrays for console verbs
  295. extern MMC_CONSOLE_VERB g_ConsoleVerbs[NUM_CONSOLE_VERBS];
  296. extern MMC_BUTTON_STATE g_ConsoleVerbStates[DHCPSNAP_NODETYPE_MAX][NUM_CONSOLE_VERBS];
  297. extern MMC_BUTTON_STATE g_ConsoleVerbStatesMultiSel[DHCPSNAP_NODETYPE_MAX][NUM_CONSOLE_VERBS];
  298. // array for help
  299. extern DWORD g_dwMMCHelp[DHCPSNAP_NODETYPE_MAX];
  300. // icon image map
  301. extern UINT g_uIconMap[ICON_IDX_MAX + 1][2];
  302. // Clipboard format that has the Type and Cookie
  303. extern const wchar_t* SNAPIN_INTERNAL;
  304. // CDhcpSnapinApp definition
  305. class CDhcpSnapinApp : public CWinApp
  306. {
  307. public:
  308. virtual BOOL InitInstance();
  309. virtual int ExitInstance();
  310. DECLARE_MESSAGE_MAP()
  311. public:
  312. BOOL m_bWinsockInited;
  313. };
  314. extern CDhcpSnapinApp theApp;
  315. // help stuff here
  316. typedef CMap<UINT, UINT, DWORD *, DWORD *> CDhcpContextHelpMap;
  317. extern CDhcpContextHelpMap g_dhcpContextHelpMap;
  318. #define DHCPSNAP_NUM_HELP_MAPS 41
  319. extern DWORD * DhcpGetHelpMap(UINT uID);