Source code of Windows XP (NT5)
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.

365 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. #define IP_ADDDRESS_LENGTH_MAX 16
  106. #define DHCP_INFINIT_LEASE 0xffffffff // Inifinite lease LONG value
  107. // DHCP Server version defines
  108. #define DHCP_NT4_VERSION 0x0000000400000000
  109. #define DHCP_SP2_VERSION 0x0000000400000001
  110. #define DHCP_NT5_VERSION 0x0000000500000000
  111. #define DHCP_NT51_VERSION 0x0000000500000006
  112. // Note - These are offsets into my toolbar image list
  113. typedef enum _TOOLBAR_IMAGE_INDICIES
  114. {
  115. TOOLBAR_IDX_ADD_SERVER,
  116. TOOLBAR_IDX_REFRESH,
  117. TOOLBAR_IDX_CREATE_SCOPE,
  118. TOOLBAR_IDX_CREATE_SUPERSCOPE,
  119. TOOLBAR_IDX_DEACTIVATE,
  120. TOOLBAR_IDX_ACTIVATE,
  121. TOOLBAR_IDX_ADD_BOOTP,
  122. TOOLBAR_IDX_ADD_RESERVATION,
  123. TOOLBAR_IDX_ADD_EXCLUSION,
  124. TOOLBAR_IDX_OPTION_GLOBAL,
  125. TOOLBAR_IDX_OPTION_SCOPE,
  126. TOOLBAR_IDX_OPTION_RESERVATION,
  127. TOOLBAR_IDX_MAX
  128. } TOOLBAR_IMAGE_INDICIES, * LPTOOLBAR_IMAGE_INDICIES;
  129. typedef enum _ICON_IMAGE_INDICIES
  130. {
  131. ICON_IDX_ACTIVE_LEASES_FOLDER_OPEN,
  132. ICON_IDX_ACTIVE_LEASES_LEAF,
  133. ICON_IDX_ACTIVE_LEASES_FOLDER_CLOSED,
  134. ICON_IDX_ACTIVE_LEASES_FOLDER_OPEN_BUSY,
  135. ICON_IDX_ACTIVE_LEASES_LEAF_BUSY,
  136. ICON_IDX_ACTIVE_LEASES_FOLDER_CLOSED_BUSY,
  137. ICON_IDX_ACTIVE_LEASES_FOLDER_OPEN_LOST_CONNECTION,
  138. ICON_IDX_ACTIVE_LEASES_LEAF_LOST_CONNECTION,
  139. ICON_IDX_ACTIVE_LEASES_FOLDER_CLOSED_LOST_CONNECTION,
  140. ICON_IDX_ADDR_POOL_FOLDER_OPEN,
  141. ICON_IDX_ADDR_POOL_LEAF, //10
  142. ICON_IDX_ADDR_POOL_FOLDER_CLOSED,
  143. ICON_IDX_ADDR_POOL_FOLDER_OPEN_BUSY,
  144. ICON_IDX_ADDR_POOL_LEAF_BUSY,
  145. ICON_IDX_ADDR_POOL_FOLDER_CLOSED_BUSY,
  146. ICON_IDX_ADDR_POOL_FOLDER_OPEN_LOST_CONNECTION,
  147. ICON_IDX_ADDR_POOL_LEAF_LOST_CONNECTION,
  148. ICON_IDX_ADDR_POOL_FOLDER_CLOSED_LOST_CONNECTION,
  149. ICON_IDX_ALLOCATION_RANGE,
  150. ICON_IDX_BOOTP_ENTRY,
  151. ICON_IDX_BOOTP_TABLE_CLOSED, //20
  152. ICON_IDX_BOOTP_TABLE_OPEN,
  153. ICON_IDX_BOOTP_TABLE_CLOSED_BUSY,
  154. ICON_IDX_BOOTP_TABLE_OPEN_BUSY,
  155. ICON_IDX_BOOTP_TABLE_CLOSED_LOST_CONNECTION,
  156. ICON_IDX_BOOTP_TABLE_OPEN_LOST_CONNECTION,
  157. ICON_IDX_CLIENT,
  158. ICON_IDX_CLIENT_DNS_REGISTERING,
  159. ICON_IDX_CLIENT_EXPIRED,
  160. ICON_IDX_CLIENT_RAS,
  161. ICON_IDX_CLIENT_OPTION_FOLDER_OPEN, //30
  162. ICON_IDX_CLIENT_OPTION_LEAF,
  163. ICON_IDX_CLIENT_OPTION_FOLDER_CLOSED,
  164. ICON_IDX_CLIENT_OPTION_FOLDER_OPEN_BUSY,
  165. ICON_IDX_CLIENT_OPTION_LEAF_BUSY,
  166. ICON_IDX_CLIENT_OPTION_FOLDER_CLOSED_BUSY,
  167. ICON_IDX_CLIENT_OPTION_FOLDER_OPEN_LOST_CONNECTION,
  168. ICON_IDX_CLIENT_OPTION_LEAF_LOST_CONNECTION,
  169. ICON_IDX_CLIENT_OPTION_FOLDER_CLOSED_LOST_CONNECTION,
  170. ICON_IDX_EXCLUSION_RANGE,
  171. ICON_IDX_FOLDER_CLOSED, //40
  172. ICON_IDX_FOLDER_OPEN,
  173. ICON_IDX_RES_CLIENT,
  174. ICON_IDX_RES_CLIENT_BUSY,
  175. ICON_IDX_RES_CLIENT_LOST_CONNECTION,
  176. ICON_IDX_RESERVATIONS_FOLDER_OPEN,
  177. ICON_IDX_RESERVATIONS_FOLDER_CLOSED,
  178. ICON_IDX_RESERVATIONS_FOLDER_OPEN_BUSY,
  179. ICON_IDX_RESERVATIONS_FOLDER_CLOSED_BUSY,
  180. ICON_IDX_RESERVATIONS_FOLDER_OPEN_LOST_CONNECTION,
  181. ICON_IDX_RESERVATIONS_FOLDER_CLOSED_LOST_CONNECTION, //50
  182. ICON_IDX_SCOPE_OPTION_FOLDER_OPEN,
  183. ICON_IDX_SCOPE_OPTION_LEAF,
  184. ICON_IDX_SCOPE_OPTION_FOLDER_CLOSED,
  185. ICON_IDX_SCOPE_OPTION_FOLDER_OPEN_BUSY,
  186. ICON_IDX_SCOPE_OPTION_LEAF_BUSY,
  187. ICON_IDX_SCOPE_OPTION_FOLDER_CLOSED_BUSY,
  188. ICON_IDX_SCOPE_OPTION_FOLDER_OPEN_LOST_CONNECTION,
  189. ICON_IDX_SCOPE_OPTION_FOLDER_CLOSED_LOST_CONNECTION,
  190. ICON_IDX_SCOPE_OPTION_LEAF_LOST_CONNECTION,
  191. ICON_IDX_SERVER, //60
  192. ICON_IDX_SERVER_ALERT,
  193. ICON_IDX_SERVER_BUSY,
  194. ICON_IDX_SERVER_CONNECTED,
  195. ICON_IDX_SERVER_GROUP,
  196. ICON_IDX_SERVER_ROGUE,
  197. ICON_IDX_SERVER_LOST_CONNECTION,
  198. ICON_IDX_SERVER_NO_ACCESS,
  199. ICON_IDX_SERVER_WARNING,
  200. ICON_IDX_SERVER_OPTION_FOLDER_OPEN,
  201. ICON_IDX_SERVER_OPTION_LEAF, //70
  202. ICON_IDX_SERVER_OPTION_FOLDER_CLOSED,
  203. ICON_IDX_SERVER_OPTION_FOLDER_OPEN_BUSY,
  204. ICON_IDX_SERVER_OPTION_LEAF_BUSY,
  205. ICON_IDX_SERVER_OPTION_FOLDER_CLOSED_BUSY,
  206. ICON_IDX_SERVER_OPTION_FOLDER_OPEN_LOST_CONNECTION,
  207. ICON_IDX_SERVER_OPTION_LEAF_LOST_CONNECTION,
  208. ICON_IDX_SERVER_OPTION_FOLDER_CLOSED_LOST_CONNECTION,
  209. ICON_IDX_SCOPE_FOLDER_OPEN,
  210. ICON_IDX_SCOPE_FOLDER_OPEN_BUSY,
  211. ICON_IDX_SCOPE_FOLDER_CLOSED_BUSY, //80
  212. ICON_IDX_SCOPE_FOLDER_OPEN_WARNING,
  213. ICON_IDX_SCOPE_FOLDER_CLOSED_WARNING,
  214. ICON_IDX_SCOPE_FOLDER_OPEN_LOST_CONNECTION,
  215. ICON_IDX_SCOPE_FOLDER_CLOSED_LOST_CONNECTION,
  216. ICON_IDX_SCOPE_FOLDER_OPEN_ALERT,
  217. ICON_IDX_SCOPE_INACTIVE_FOLDER_OPEN,
  218. ICON_IDX_SCOPE_INACTIVE_FOLDER_CLOSED,
  219. ICON_IDX_SCOPE_INACTIVE_FOLDER_OPEN_LOST_CONNECTION,
  220. ICON_IDX_SCOPE_INACTIVE_FOLDER_CLOSED_LOST_CONNECTION,
  221. ICON_IDX_SCOPE_FOLDER_CLOSED, //90
  222. ICON_IDX_SCOPE_FOLDER_CLOSED_ALERT,
  223. ICON_IDX_APPLICATION,
  224. ICON_IDX_MAX
  225. } ICON_IMAGE_INDICIES, * LPICON_IMAGE_INDICIES;
  226. // Constants used in for column information
  227. const int MAX_COLUMNS = 7;
  228. const int NUM_CONSOLE_VERBS = 8;
  229. const int NUM_SCOPE_ITEMS = 14;
  230. // Sample folder types
  231. enum NODETYPES
  232. {
  233. // scope pane items
  234. DHCPSNAP_ROOT,
  235. DHCPSNAP_SERVER,
  236. DHCPSNAP_BOOTP_TABLE,
  237. DHCPSNAP_SUPERSCOPE,
  238. DHCPSNAP_SCOPE,
  239. DHCPSNAP_MSCOPE,
  240. DHCPSNAP_ADDRESS_POOL,
  241. DHCPSNAP_ACTIVE_LEASES,
  242. DHCPSNAP_MSCOPE_LEASES,
  243. DHCPSNAP_RESERVATIONS,
  244. DHCPSNAP_RESERVATION_CLIENT,
  245. DHCPSNAP_SCOPE_OPTIONS,
  246. DHCPSNAP_GLOBAL_OPTIONS,
  247. DHCPSNAP_CLASSID_HOLDER,
  248. // result pane items
  249. DHCPSNAP_ACTIVE_LEASE,
  250. DHCPSNAP_ALLOCATION_RANGE,
  251. DHCPSNAP_EXCLUSION_RANGE,
  252. DHCPSNAP_BOOTP_ENTRY,
  253. DHCPSNAP_OPTION_ITEM,
  254. DHCPSNAP_CLASSID,
  255. DHCPSNAP_MCAST_LEASE,
  256. DHCPSNAP_NODETYPE_MAX
  257. };
  258. // GUIDs are defined in guids.cpp
  259. extern const CLSID CLSID_DhcpSnapin; // In-Proc server GUID
  260. extern const CLSID CLSID_DhcpSnapinExtension; // In-Proc server GUID
  261. extern const CLSID CLSID_DhcpSnapinAbout; // In-Proc server GUID
  262. extern const GUID GUID_DhcpRootNodeType; // Root NodeType GUID
  263. extern const GUID GUID_DhcpServerNodeType; // Server NodeType GUID
  264. extern const GUID GUID_DhcpScopeNodeType; // Scope NodeType GUID
  265. extern const GUID GUID_DhcpMScopeNodeType; // MScope NodeType GUID
  266. extern const GUID GUID_DhcpBootpNodeType; // Bootp NodeType GUID
  267. extern const GUID GUID_DhcpGlobalOptionsNodeType; // GlobalOptions NodeType GUID
  268. extern const GUID GUID_DhcpClassIdHolderNodeType; // ClassId Scope NodeType GUID
  269. extern const GUID GUID_DhcpSuperscopeNodeType; // Superscope NodeType GUID
  270. extern const GUID GUID_DhcpAddressPoolNodeType; // AddressPool NodeType GUID
  271. extern const GUID GUID_DhcpActiveLeasesNodeType; // ActiveLeases NodeType GUID
  272. extern const GUID GUID_DhcpReservationsNodeType; // Reservations NodeType GUID
  273. extern const GUID GUID_DhcpScopeOptionsNodeType; // ScopeOptions NodeType GUID
  274. extern const GUID GUID_DhcpReservationClientNodeType; // Reservation Client NodeType GUID
  275. extern const GUID GUID_DhcpAllocationNodeType; // Allocation range NodeType GUID
  276. extern const GUID GUID_DhcpExclusionNodeType; // Exlusion range NodeType GUID
  277. extern const GUID GUID_DhcpBootpEntryNodeType; // BootpEntry NodeType GUID
  278. extern const GUID GUID_DhcpActiveLeaseNodeType; // ActiveLease NodeType GUID
  279. extern const GUID GUID_DhcpOptionNodeType; // Option NodeType GUID
  280. extern const GUID GUID_DhcpClassIdNodeType; // ClassId (result pane) NodeType GUID
  281. extern const GUID GUID_DhcpMCastLeaseNodeType; // Multicast lease (result pane) NodeType GUID
  282. extern const GUID GUID_DhcpMCastAddressPoolNodeType; // AddressPool NodeType GUID (multicast scope)
  283. extern const GUID GUID_DhcpMCastActiveLeasesNodeType; // ActiveLeases NodeType GUID (multicast scope)
  284. // arrays used to hold all of the result pane column information
  285. extern UINT aColumns[DHCPSNAP_NODETYPE_MAX][MAX_COLUMNS];
  286. extern int aColumnWidths[DHCPSNAP_NODETYPE_MAX][MAX_COLUMNS];
  287. // arrays for toolbar information
  288. extern MMCBUTTON g_SnapinButtons[TOOLBAR_IDX_MAX];
  289. extern int g_SnapinButtonStrings[TOOLBAR_IDX_MAX][2];
  290. extern MMC_BUTTON_STATE g_SnapinButtonStates[DHCPSNAP_NODETYPE_MAX][TOOLBAR_IDX_MAX];
  291. // arrays for console verbs
  292. extern MMC_CONSOLE_VERB g_ConsoleVerbs[NUM_CONSOLE_VERBS];
  293. extern MMC_BUTTON_STATE g_ConsoleVerbStates[DHCPSNAP_NODETYPE_MAX][NUM_CONSOLE_VERBS];
  294. extern MMC_BUTTON_STATE g_ConsoleVerbStatesMultiSel[DHCPSNAP_NODETYPE_MAX][NUM_CONSOLE_VERBS];
  295. // array for help
  296. extern DWORD g_dwMMCHelp[DHCPSNAP_NODETYPE_MAX];
  297. // icon image map
  298. extern UINT g_uIconMap[ICON_IDX_MAX + 1][2];
  299. // Clipboard format that has the Type and Cookie
  300. extern const wchar_t* SNAPIN_INTERNAL;
  301. // CDhcpSnapinApp definition
  302. class CDhcpSnapinApp : public CWinApp
  303. {
  304. public:
  305. virtual BOOL InitInstance();
  306. virtual int ExitInstance();
  307. DECLARE_MESSAGE_MAP()
  308. public:
  309. BOOL m_bWinsockInited;
  310. };
  311. extern CDhcpSnapinApp theApp;
  312. // help stuff here
  313. typedef CMap<UINT, UINT, DWORD *, DWORD *> CDhcpContextHelpMap;
  314. extern CDhcpContextHelpMap g_dhcpContextHelpMap;
  315. #define DHCPSNAP_NUM_HELP_MAPS 38
  316. extern DWORD * DhcpGetHelpMap(UINT uID);