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.

213 lines
6.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. server.h
  7. FILE HISTORY:
  8. */
  9. #ifndef _SERVER_H
  10. #define _SERVER_H
  11. #ifndef _IPSMHAND_H
  12. #include "ipsmhand.h"
  13. #endif
  14. #ifndef _SPDDB_H
  15. #include "spddb.h"
  16. #endif
  17. #ifndef _APINFO_H
  18. #include "apinfo.h"
  19. #endif
  20. //#include "stats.h"
  21. // options for the server outside of the API
  22. #define IPSMSNAP_OPTIONS_REFRESH 0x00000001
  23. #define IPSMSNAP_OPTIONS_EXTENSION 0x00000002
  24. #define IPSMSNAP_OPTIONS_DNS 0x00000004
  25. // custom data types for query object
  26. #define IPSECMON_QDATA_REFRESH_STATS 0x00000001
  27. #define IPSECMON_QDATA_FAILED 0x00000002
  28. class CIpsmServer;
  29. class CTimerDesc
  30. {
  31. public:
  32. SPITFSNode spNode;
  33. CIpsmServer * pServer;
  34. UINT_PTR uTimer;
  35. TIMERPROC timerProc;
  36. };
  37. typedef CArray<CTimerDesc *, CTimerDesc *> CTimerArrayBase;
  38. class CTimerMgr : CTimerArrayBase
  39. {
  40. public:
  41. CTimerMgr();
  42. ~CTimerMgr();
  43. public:
  44. int AllocateTimer(ITFSNode * pNode, CIpsmServer * pServer, UINT uTimerValue, TIMERPROC TimerProc);
  45. void FreeTimer(UINT_PTR uEventId);
  46. void ChangeInterval(UINT_PTR uEventId, UINT uNewInterval);
  47. CTimerDesc * GetTimerDesc(UINT_PTR uEventId);
  48. CCriticalSection m_csTimerMgr;
  49. };
  50. /*---------------------------------------------------------------------------
  51. Class: CIpsmServer
  52. ---------------------------------------------------------------------------*/
  53. class CIpsmServer : public CMTIpsmHandler
  54. {
  55. public:
  56. CIpsmServer(ITFSComponentData* pTFSComponentData);
  57. ~CIpsmServer();
  58. // Interface
  59. public:
  60. // base handler functionality we override
  61. OVERRIDE_NodeHandler_HasPropertyPages();
  62. OVERRIDE_NodeHandler_CreatePropertyPages();
  63. OVERRIDE_NodeHandler_OnAddMenuItems();
  64. OVERRIDE_NodeHandler_OnCommand();
  65. OVERRIDE_NodeHandler_GetString()
  66. { return (nCol == 0) ? GetDisplayName() : NULL; }
  67. // Choose which messages we want to handle
  68. OVERRIDE_BaseHandlerNotify_OnDelete();
  69. OVERRIDE_BaseHandlerNotify_OnPropertyChange();
  70. // Result handler functionality we override
  71. // CMTHandler overridden
  72. virtual HRESULT OnRefresh(ITFSNode *, LPDATAOBJECT, DWORD, LPARAM, LPARAM);
  73. public:
  74. // CMTIpsmHandler functionality
  75. virtual HRESULT InitializeNode(ITFSNode * pNode);
  76. virtual int GetImageIndex(BOOL bOpenImage);
  77. ITFSQueryObject* OnCreateQuery(ITFSNode * pNode);
  78. virtual void OnHaveData(ITFSNode * pParentNode, ITFSNode * pNode);
  79. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type);
  80. STDMETHOD(OnNotifyExiting)(LPARAM);
  81. virtual void GetErrorPrefix(ITFSNode * pNode, CString * pstrMessage)
  82. {
  83. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  84. AfxFormatString1(*pstrMessage, IDS_ERR_SERVER_NODE, GetDisplayName());
  85. }
  86. virtual void UpdateConsoleVerbs(IConsoleVerb * pConsoleVerb, LONG_PTR dwNodeType, BOOL bMultiSelect = FALSE);
  87. public:
  88. // implementation specific
  89. HRESULT BuildDisplayName(CString * pstrDisplayName);
  90. void SetName(LPCTSTR pName) { m_strServerAddress = pName; }
  91. LPCTSTR GetName() { return m_strServerAddress; }
  92. HRESULT OnRefreshStats(ITFSNode * pNode,
  93. LPDATAOBJECT pDataObject,
  94. DWORD dwType,
  95. LPARAM arg,
  96. LPARAM param);
  97. void SetOptions(DWORD dwOptions) { m_dwOptions = dwOptions; }
  98. DWORD GetOptions() { return m_dwOptions; }
  99. HRESULT SetAutoRefresh(ITFSNode * pNode, BOOL bOn, DWORD dwRefreshInterval);
  100. HRESULT SetDnsResolve(ITFSNode * pNode, BOOL bEnable);
  101. BOOL IsAutoRefreshEnabled() { return m_dwOptions & IPSMSNAP_OPTIONS_REFRESH; }
  102. DWORD GetAutoRefreshInterval() { return m_dwRefreshInterval; }
  103. void SetExtensionName();
  104. // Implementation
  105. private:
  106. // Command handlers
  107. HRESULT OnDelete(ITFSNode * pNode);
  108. public:
  109. BOOL m_bStatsOnly;
  110. private:
  111. SPISpdInfo m_spSpdInfo;
  112. SPIApDbInfo m_spApDbInfo;
  113. //CIpsecStats m_StatsDlg;
  114. CString m_strServerAddress;
  115. DWORD m_dwOptions;
  116. DWORD m_dwRefreshInterval;
  117. int m_StatsTimerId;
  118. };
  119. /*---------------------------------------------------------------------------
  120. Class: CIpsmServerQueryObj
  121. ---------------------------------------------------------------------------*/
  122. class CIpsmServerQueryObj : public CIpsmQueryObj
  123. {
  124. public:
  125. CIpsmServerQueryObj(ITFSComponentData * pTFSComponentData,
  126. ITFSNodeMgr * pNodeMgr)
  127. : CIpsmQueryObj(pTFSComponentData, pNodeMgr) {};
  128. STDMETHODIMP Execute();
  129. public:
  130. SPISpdInfo m_spSpdInfo;
  131. SPIApDbInfo m_spApDbInfo;
  132. BOOL m_bStatsOnly;
  133. };
  134. class HashEntry {
  135. public:
  136. LIST_ENTRY Linkage;
  137. in_addr IpAddr;
  138. CString HostName;
  139. };
  140. #define HASH_TABLE_SIZE 128
  141. #define TOTAL_TABLE_SIZE 129 //hash entries 0-127, Pending list is 128
  142. #define PENDING_INDEX 128
  143. //Callback for background resolver thread
  144. UINT HashResolverCallback(LPVOID pParam);
  145. class CHashTable {
  146. public:
  147. CHashTable();
  148. ~CHashTable();
  149. DWORD AddPendingObject(in_addr IpAddr);
  150. DWORD AddObject(HashEntry *pHE);
  151. DWORD GetObject(HashEntry **ppHashEntry,in_addr IpAddr);
  152. HRESULT SetDnsResolve(BOOL bEnable);
  153. DWORD FlushTable();
  154. DWORD DnsResolve();
  155. public:
  156. CCriticalSection m_csHashLock;
  157. BOOL m_bDnsResolveActive;
  158. BOOL m_bThreadRunning;
  159. private:
  160. DWORD HashData(in_addr IPAddr);
  161. LIST_ENTRY HashTable[TOTAL_TABLE_SIZE];
  162. };
  163. #endif _SERVER_H