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.

192 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name :
  4. sslconfigchangeprovclient.cxx
  5. Abstract:
  6. SSL CONFIG CHANGE PROV client
  7. Receives SSL configuration change parameters detected by server side
  8. User of this class shold inherit it class and implement
  9. PipeListener() to process notifications
  10. Author:
  11. Jaroslav Dunajsky April-24-2001
  12. Environment:
  13. Win32 - User Mode
  14. Project:
  15. Stream Filter Worker Process
  16. --*/
  17. #include "precomp.hxx"
  18. HRESULT
  19. SSL_CONFIG_CHANGE_PROV_CLIENT::StartListeningForChanges(
  20. IN SSL_CONFIG_CHANGE_CALLBACK * pSslConfigChangeCallback,
  21. IN OPTIONAL PVOID pvParam
  22. )
  23. /*++
  24. Routine Description:
  25. Create thread to handle SSL configuration change notification
  26. Arguments:
  27. pSslConfigChangeCallback - callback function that receives change details
  28. pvParam - optional parameter that will be passed as first param to callback
  29. Return Value:
  30. HRESULT
  31. --*/
  32. {
  33. HRESULT hr = E_FAIL;
  34. IF_DEBUG( TRACE )
  35. {
  36. DBGPRINTF(( DBG_CONTEXT,
  37. "SSL_CONFIG_CHANGE_PROV_CLIENT::StartListeningForChanges()\n"
  38. ));
  39. }
  40. if ( pSslConfigChangeCallback == NULL )
  41. {
  42. DBG_ASSERT( pSslConfigChangeCallback != NULL );
  43. return HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
  44. }
  45. //
  46. // store the callback function pointer, and first parameter
  47. //
  48. _pSslConfigChangeCallback = pSslConfigChangeCallback;
  49. _pSslConfigChangeCallbackParameter = pvParam;
  50. //
  51. // Initialize parent (it will handle all the pipe initialization)
  52. //
  53. hr = SSL_CONFIG_PIPE::PipeInitializeClient( WSZ_SSL_CONFIG_CHANGE_PIPE );
  54. if ( FAILED( hr ) )
  55. {
  56. return hr;
  57. }
  58. //
  59. // Connect pipe
  60. //
  61. hr = SSL_CONFIG_PIPE::PipeConnect( );
  62. if ( SUCCEEDED( hr ) )
  63. {
  64. _fConnected = TRUE;
  65. }
  66. return hr;
  67. }
  68. HRESULT
  69. SSL_CONFIG_CHANGE_PROV_CLIENT::StopListeningForChanges(
  70. VOID
  71. )
  72. /*++
  73. Routine Description:
  74. Close named pipe for SSL config change notifications
  75. Arguments:
  76. Return Value:
  77. HRESULT
  78. --*/
  79. {
  80. IF_DEBUG( TRACE )
  81. {
  82. DBGPRINTF(( DBG_CONTEXT,
  83. "SSL_CONFIG_CHANGE_PROV_CLIENT::StopListeningForChanges\n"
  84. ));
  85. }
  86. //
  87. // Disconnect pipe
  88. //
  89. SSL_CONFIG_PIPE::PipeDisconnect( );
  90. _fConnected = FALSE;
  91. return SSL_CONFIG_PIPE::PipeTerminate( );
  92. }
  93. //virtual
  94. HRESULT
  95. SSL_CONFIG_CHANGE_PROV_CLIENT::PipeListener(
  96. VOID
  97. )
  98. /*++
  99. Routine Description:
  100. Pipe listener on the client side handles SSL Config change notifications
  101. Function is started on private thread launched by
  102. base class SSL_CONFIG_PIPE during pipe initialization
  103. Arguments:
  104. Return Value:
  105. HRESULT
  106. --*/
  107. {
  108. SSL_CONFIG_PIPE_COMMAND Command;
  109. HRESULT hr = E_FAIL;
  110. DWORD dwSiteId;
  111. //
  112. // Listen on pipe to receive commands
  113. // and handle them
  114. //
  115. while ( TRUE )
  116. {
  117. hr = PipeReceiveCommand( &Command );
  118. if ( FAILED( hr ) )
  119. {
  120. //
  121. // failure may simply mean that
  122. // termination has started and
  123. // pipe handle was closed
  124. //
  125. goto Cleanup;
  126. }
  127. dwSiteId = Command.dwParameter1;
  128. //
  129. // make the callback
  130. //
  131. DBG_ASSERT( _pSslConfigChangeCallback != NULL );
  132. (* _pSslConfigChangeCallback) (
  133. _pSslConfigChangeCallbackParameter,
  134. static_cast<SSL_CONFIG_CHANGE_COMMAND_ID>
  135. ( Command.dwCommandId ),
  136. dwSiteId );
  137. }
  138. return S_OK;
  139. Cleanup:
  140. _fConnected = FALSE;
  141. DBG_ASSERT( FAILED( hr ) );
  142. return hr;
  143. }