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.

185 lines
3.5 KiB

  1. // AlgController.h : Declaration of the CAlgController
  2. #pragma once
  3. #include "resource.h" // main symbols
  4. #include "ApplicationGatewayServices.h"
  5. #include "CollectionAdapters.h"
  6. #include "CollectionAlgModules.h"
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CAlgController
  9. class ATL_NO_VTABLE CAlgController :
  10. public CComObjectRootEx<CComMultiThreadModel>,
  11. public CComCoClass<CAlgController, &CLSID_AlgController>,
  12. public IAlgController
  13. {
  14. //
  15. // Constructors & Destructor
  16. //
  17. public:
  18. CAlgController()
  19. {
  20. MYTRACE_ENTER_NOSHOWEXIT("CAlgController()");
  21. HRESULT hr;
  22. m_pINat = NULL;
  23. m_pIAlgServices = NULL;
  24. }
  25. ~CAlgController()
  26. {
  27. MYTRACE_ENTER_NOSHOWEXIT("~CAlgController()");
  28. }
  29. //
  30. // ATL COM helper macros
  31. //
  32. DECLARE_REGISTRY_RESOURCEID(IDR_ALGCONTROLLER)
  33. DECLARE_NOT_AGGREGATABLE(CAlgController)
  34. BEGIN_COM_MAP(CAlgController)
  35. COM_INTERFACE_ENTRY(IAlgController)
  36. END_COM_MAP()
  37. //
  38. // IAlgController - COM Interface exposed methods
  39. //
  40. public:
  41. STDMETHODIMP Start(
  42. IN INat* pINat
  43. );
  44. STDMETHODIMP Stop();
  45. STDMETHODIMP Adapter_Add(
  46. IN ULONG nCookie,
  47. IN short Type
  48. );
  49. STDMETHODIMP Adapter_Remove(
  50. IN ULONG nCookie
  51. );
  52. STDMETHODIMP Adapter_Modify(
  53. IN ULONG nCookie
  54. );
  55. STDMETHODIMP Adapter_Bind(
  56. IN ULONG nCookie,
  57. IN ULONG nAdapterIndex,
  58. IN ULONG nAddressCount,
  59. IN DWORD anAdress[]
  60. );
  61. STDMETHODIMP Adapter_PortMappingChanged(
  62. IN ULONG nCookie,
  63. IN UCHAR ucProtocol,
  64. IN USHORT usPort
  65. );
  66. //
  67. // Private internal methods
  68. //
  69. private:
  70. public:
  71. //
  72. // Return the private interface to CComNAT
  73. //
  74. INat* GetNat()
  75. {
  76. return m_pINat;
  77. }
  78. //
  79. // Load new ALG module that may have been added and unload any modules not configured anymore
  80. //
  81. void
  82. ConfigurationUpdated()
  83. {
  84. m_AlgModules.Refresh();
  85. }
  86. //
  87. //
  88. //
  89. void
  90. FreeResources()
  91. {
  92. //
  93. // Cleanup member before the scalar destruction is
  94. // done on them because at that time the
  95. // two next intruction will have been done ant the two interface will be nuked
  96. //
  97. m_CollectionOfAdapters.RemoveAll();
  98. m_ControlChannelsPrimary.RemoveAll();
  99. m_ControlChannelsSecondary.RemoveAll();
  100. m_AdapterNotificationSinks.RemoveAll();
  101. //
  102. // Done with the public interface
  103. //
  104. if ( m_pIAlgServices )
  105. {
  106. m_pIAlgServices->Release();
  107. m_pIAlgServices = NULL;
  108. }
  109. //
  110. // Done with the private interface
  111. //
  112. if ( m_pINat )
  113. {
  114. m_pINat->Release();
  115. m_pINat = NULL;
  116. }
  117. }
  118. //
  119. // Properties
  120. //
  121. private:
  122. INat* m_pINat;
  123. CCollectionAlgModules m_AlgModules;
  124. public:
  125. IApplicationGatewayServices* m_pIAlgServices;
  126. CCollectionAdapters m_CollectionOfAdapters;
  127. CCollectionAdapterNotifySinks m_AdapterNotificationSinks;
  128. CCollectionControlChannelsPrimary m_ControlChannelsPrimary;
  129. CCollectionControlChannelsSecondary m_ControlChannelsSecondary;
  130. };
  131. extern CAlgController* g_pAlgController; // This is a singleton created by IPNATHLP/NatALG