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.

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