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.

190 lines
3.3 KiB

  1. //
  2. // Microsoft
  3. //
  4. //
  5. #include "PrimaryControlChannel.h"
  6. #include "SecondaryControlChannel.h"
  7. #include <list>
  8. //
  9. // Free the Channels
  10. //
  11. typedef std::list<CPrimaryControlChannel*> LISTOF_CHANNELS_PRIMARY;
  12. typedef std::list<CSecondaryControlChannel*> LISTOF_CHANNELS_SECONDARY;
  13. //
  14. //
  15. //
  16. class CCollectionControlChannelsPrimary
  17. {
  18. //
  19. // Properties
  20. //
  21. public:
  22. CComAutoCriticalSection m_AutoCS;
  23. LISTOF_CHANNELS_PRIMARY m_ListOfChannels;
  24. //
  25. // Methods
  26. //
  27. public:
  28. //
  29. // standard destructor
  30. //
  31. ~CCollectionControlChannelsPrimary();
  32. //
  33. // Add a new control channel (Thread safe)
  34. //
  35. HRESULT
  36. Add(
  37. CPrimaryControlChannel* pChannelToAdd
  38. );
  39. //
  40. // Remove a channel from the list (Thead safe)
  41. //
  42. HRESULT
  43. Remove(
  44. CPrimaryControlChannel* pChannelToRemove
  45. );
  46. //
  47. // Use to cancel all ControlChannel in the collection and free the list
  48. //
  49. HRESULT
  50. RemoveAll();
  51. //
  52. // Set a dynamic redirection and all collected Primary ControlChannel
  53. //
  54. HRESULT
  55. SetRedirects(
  56. ALG_ADAPTER_TYPE eAdapterType,
  57. ULONG nAdapterIndex,
  58. ULONG nAdapterAddress
  59. );
  60. //
  61. // Called when a port mapping is modified
  62. //
  63. HRESULT
  64. AdapterPortMappingChanged(
  65. ULONG nCookie,
  66. UCHAR ucProtocol,
  67. USHORT usPort
  68. );
  69. //
  70. // Called when an adapter got removed
  71. // function will cancel any redirect that was done on this adapter index
  72. //
  73. HRESULT
  74. AdapterRemoved(
  75. ULONG nAdapterIndex
  76. );
  77. private:
  78. CPrimaryControlChannel*
  79. FindControlChannel(
  80. ALG_PROTOCOL eProtocol,
  81. USHORT usPort
  82. )
  83. {
  84. for ( LISTOF_CHANNELS_PRIMARY::iterator theIterator = m_ListOfChannels.begin();
  85. theIterator != m_ListOfChannels.end();
  86. theIterator++
  87. )
  88. {
  89. CPrimaryControlChannel* pControlChannel = (CPrimaryControlChannel*)(*theIterator);
  90. if (pControlChannel->m_Properties.eProtocol == eProtocol
  91. && pControlChannel->m_Properties.usCapturePort == usPort)
  92. {
  93. return pControlChannel;
  94. }
  95. }
  96. return NULL;
  97. };
  98. };
  99. //
  100. //
  101. //
  102. class CCollectionControlChannelsSecondary
  103. {
  104. //
  105. // Properties
  106. //
  107. public:
  108. CComAutoCriticalSection m_AutoCS;
  109. LISTOF_CHANNELS_SECONDARY m_ListOfChannels;
  110. //
  111. // Methods
  112. //
  113. public:
  114. //
  115. // standard destructor
  116. //
  117. ~CCollectionControlChannelsSecondary();
  118. //
  119. // Add a new control channel (Thread safe)
  120. //
  121. HRESULT Add(
  122. CSecondaryControlChannel* pChannelToAdd
  123. );
  124. //
  125. // Remove a channel from the list (Thead safe)
  126. //
  127. HRESULT Remove(
  128. CSecondaryControlChannel* pChannelToRemove
  129. );
  130. //
  131. // Use to cancel all ControlChannel in the collection and free the list
  132. //
  133. HRESULT
  134. RemoveAll();
  135. };