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.

212 lines
6.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 2002 **/
  4. /**********************************************************************/
  5. /*
  6. global.h
  7. Global defines for the IPSecMon snapin
  8. FILE HISTORY:
  9. */
  10. const TCHAR PA_SERVICE_NAME[] = _T("PolicyAgent");
  11. // Defines for help from the help menu and F1 help for scope pane items
  12. #define IPSMSNAP_HELP_BASE 0xA0000000
  13. #define IPSMSNAP_HELP_SNAPIN IPSMSNAP_HELP_BASE + 1
  14. #define IPSMSNAP_HELP_ROOT IPSMSNAP_HELP_BASE + 2
  15. #define IPSMSNAP_HELP_SERVER IPSMSNAP_HELP_BASE + 3
  16. #define IPSMSNAP_HELP_PROVIDER IPSMSNAP_HELP_BASE + 4
  17. #define IPSMSNAP_HELP_DEVICE IPSMSNAP_HELP_BASE + 5
  18. // wait cursor stuff around functions. If you need a wait cursor for
  19. // and entire fucntion, just use CWaitCursor. To wrap a wait cursor
  20. // around an rpc call, use these macros.
  21. #define BEGIN_WAIT_CURSOR { CWaitCursor waitCursor;
  22. #define RESTORE_WAIT_CURSOR waitCursor.Restore();
  23. #define END_WAIT_CURSOR }
  24. #define ARRAYLEN(x) (sizeof(x) / sizeof((x)[0]))
  25. // macro to get the handler for a node. This is a IPSecMon snapin specific
  26. // implementation
  27. #define GETHANDLER(classname, node) (reinterpret_cast<classname *>(node->GetData(TFS_DATA_USER)))
  28. // HRESULT Mapping
  29. #define WIN32_FROM_HRESULT(hr) (0x0000FFFF & (hr))
  30. // Version Suff
  31. #define IPSMSNAP_VERSION 0x00010000
  32. extern DWORD gdwIpsmSnapVersion;
  33. #define IPSMSNAP_FILE_VERSION 0x00000001
  34. // constants for time conversion
  35. #define MILLISEC_PER_SECOND 1000
  36. #define MILLISEC_PER_MINUTE (60 * MILLISEC_PER_SECOND)
  37. #define MILLISEC_PER_HOUR (60 * MILLISEC_PER_MINUTE)
  38. #define IPSECMON_REFRESH_INTERVAL_DEFAULT (45 * MILLISEC_PER_SECOND) // 45 seconds
  39. // macros for memory exception handling
  40. #define CATCH_MEM_EXCEPTION \
  41. TRY
  42. #define END_MEM_EXCEPTION(err) \
  43. CATCH_ALL(e) { \
  44. err = ERROR_NOT_ENOUGH_MEMORY ; \
  45. } END_CATCH_ALL
  46. // some global defines we need
  47. #define STRING_LENGTH_MAX 256
  48. // Note - These are offsets into my image list
  49. typedef enum _ICON_INDICIES
  50. {
  51. ICON_IDX_SERVER,
  52. ICON_IDX_SERVER_BUSY,
  53. ICON_IDX_SERVER_CONNECTED,
  54. ICON_IDX_SERVER_LOST_CONNECTION,
  55. ICON_IDX_MACHINE,
  56. ICON_IDX_FOLDER_OPEN,
  57. ICON_IDX_FOLDER_CLOSED,
  58. ICON_IDX_PRODUCT,
  59. ICON_IDX_FILTER,
  60. ICON_IDX_POLICY,
  61. ICON_IDX_MAX
  62. } ICON_INDICIES, * LPICON_INDICIES;
  63. // Sample folder types
  64. enum NODETYPES
  65. {
  66. // scope pane items
  67. IPSMSNAP_ROOT,
  68. IPSMSNAP_SERVER,
  69. IPSECMON_QM_SA,
  70. IPSECMON_FILTER,
  71. IPSECMON_SPECIFIC_FILTER,
  72. IPSECMON_QUICK_MODE,
  73. IPSECMON_MAIN_MODE,
  74. IPSECMON_MM_POLICY,
  75. IPSECMON_QM_POLICY,
  76. IPSECMON_MM_FILTER,
  77. IPSECMON_MM_SP_FILTER,
  78. IPSECMON_MM_SA,
  79. IPSECMON_MM_IKESTATS,
  80. IPSECMON_QM_IPSECSTATS,
  81. IPSECMON_ACTIVEPOL,
  82. // result pane items
  83. IPSECMON_QM_SA_ITEM,
  84. IPSECMON_FILTER_ITEM,
  85. IPSECMON_SPECIFIC_FILTER_ITEM,
  86. IPSECMON_MM_POLICY_ITEM,
  87. IPSECMON_QM_POLICY_ITEM,
  88. IPSECMON_MM_FILTER_ITEM,
  89. IPSECMON_MM_SP_FILTER_ITEM,
  90. IPSECMON_MM_SA_ITEM,
  91. IPSECMON_MM_IKESTATS_ITEM,
  92. IPSECMON_QM_IPSECSTATS_ITEM,
  93. IPSECMON_ACTIVEPOL_ITEM,
  94. IPSECMON_NODETYPE_MAX,
  95. };
  96. // GUIDs are defined in guids.cpp
  97. extern const CLSID CLSID_IpsmSnapin; // In-Proc server GUID
  98. extern const CLSID CLSID_IpsmSnapinExtension; // In-Proc server GUID
  99. extern const CLSID CLSID_IpsmSnapinAbout; // In-Proc server GUID
  100. extern const GUID GUID_IpsmRootNodeType; // Root NodeType GUID
  101. extern const GUID GUID_IpsmServerNodeType; // Server NodeType GUID
  102. extern const GUID GUID_IpsmFilterNodeType; // Filters NodeType GUID
  103. extern const GUID GUID_IpsmSpecificFilterNodeType; // Specific Filters NodeType GUID
  104. extern const GUID GUID_QmNodeType; // Quick Mode NodeType GUID
  105. extern const GUID GUID_MmNodeType; // Main Mode NodeType GUID
  106. extern const GUID GUID_IpsmMmPolicyNodeType; // Main Mode Policy GUID
  107. extern const GUID GUID_IpsmQmPolicyNodeType; // Quick Mode Policy GUID
  108. extern const GUID GUID_IpsmMmFilterNodeType; // Main Mode Filter GUID
  109. extern const GUID GUID_IpsmMmSANodeType; // Main Mode SA GUID
  110. extern const GUID GUID_IpsmMmSpFilterNodeType; // Main Mode Specific Filter GUID
  111. extern const GUID GUID_IpsmMmIkeStatsNodeType;
  112. extern const GUID GUID_IpsmMmIpsecStatsNodeType;
  113. extern const GUID IID_ISpdInfo;
  114. extern const GUID GUID_IpsmQmSANodeType;
  115. extern const GUID GUID_IpsmActivePolNodeType;
  116. const int MAX_COLUMNS = 14;
  117. const int NUM_SCOPE_ITEMS = 3;
  118. const int NUM_CONSOLE_VERBS = 8;
  119. // arrays used to hold all of the result pane column information
  120. extern UINT aColumns[IPSECMON_NODETYPE_MAX][MAX_COLUMNS];
  121. extern int aColumnWidths[IPSECMON_NODETYPE_MAX][MAX_COLUMNS];
  122. // arrays for console verbs
  123. extern MMC_CONSOLE_VERB g_ConsoleVerbs[NUM_CONSOLE_VERBS];
  124. extern MMC_BUTTON_STATE g_ConsoleVerbStates[IPSECMON_NODETYPE_MAX][NUM_CONSOLE_VERBS];
  125. extern MMC_BUTTON_STATE g_ConsoleVerbStatesMultiSel[IPSECMON_NODETYPE_MAX][NUM_CONSOLE_VERBS];
  126. // array for help
  127. extern DWORD g_dwMMCHelp[IPSECMON_NODETYPE_MAX];
  128. // Clipboard format that has the Type and Cookie
  129. extern const wchar_t* SNAPIN_INTERNAL;
  130. // CIpsmSnapinApp definition
  131. class CIpsmSnapinApp : public CWinApp
  132. {
  133. public:
  134. virtual BOOL InitInstance();
  135. virtual int ExitInstance();
  136. DECLARE_MESSAGE_MAP()
  137. public:
  138. BOOL m_bWinsockInited;
  139. };
  140. class CThemeContextActivator
  141. {
  142. public:
  143. CThemeContextActivator() : m_ulActivationCookie(0)
  144. { SHActivateContext (&m_ulActivationCookie); }
  145. ~CThemeContextActivator()
  146. { SHDeactivateContext (m_ulActivationCookie); }
  147. private:
  148. ULONG_PTR m_ulActivationCookie;
  149. };
  150. extern CIpsmSnapinApp theApp;
  151. #define IPSECMON_UPDATE_STATUS ( 0x10000000 )
  152. //Macros for convering ip to text form
  153. // 0,1,2,3 : count of bytes from MSB to LSB in host order
  154. #define BYTE0(l) ((BYTE)((DWORD)(l) >> 24))
  155. #define BYTE1(l) ((BYTE)((DWORD)(l) >> 16))
  156. #define BYTE2(l) ((BYTE)((DWORD)(l) >> 8))
  157. #define BYTE3(l) ((BYTE)((DWORD)(l)))
  158. // Handy macro to use in printf statements
  159. #define BYTES0123(l) BYTE0(l), BYTE1(l), BYTE2(l), BYTE3(l)
  160. // 0,1,2,3 : count of bytes from MSB to LSB in network order
  161. #define NETORDER_BYTE0(l) ((BYTE)((BYTE *) &l)[0])
  162. #define NETORDER_BYTE1(l) ((BYTE)((BYTE *) &l)[1])
  163. #define NETORDER_BYTE2(l) ((BYTE)((BYTE *) &l)[2])
  164. #define NETORDER_BYTE3(l) ((BYTE)((BYTE *) &l)[3])
  165. // Handy macro to use in printf statements
  166. #define NETORDER_BYTES0123(l) \
  167. NETORDER_BYTE0(l), NETORDER_BYTE1(l), \
  168. NETORDER_BYTE2(l), NETORDER_BYTE3(l)
  169. #define GET_SOCKADDR(pAddr) NETORDER_BYTES0123(pAddr)