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.

255 lines
6.3 KiB

  1. /*
  2. Copyright (c) 1989 - 1999 Microsoft Corporation
  3. Module Name:
  4. srvcall.c
  5. Abstract:
  6. This module implements the routines for handling the creation/manipulation of
  7. server entries in the connection engine database. It also contains the routines
  8. for parsing the negotiate response from the server.
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. //
  13. // The local debug trace level
  14. //
  15. RXDT_DefineCategory(SRVCALL);
  16. #define Dbg (DEBUG_TRACE_SRVCALL)
  17. NTSTATUS
  18. ExecuteCreateSrvCall(
  19. PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext)
  20. /*++
  21. Routine Description:
  22. This routine patches the RDBSS created srv call instance with the
  23. information required by the mini redirector.
  24. Arguments:
  25. CallBackContext - the call back context in RDBSS for continuation.
  26. Return Value:
  27. RXSTATUS - The return status for the operation
  28. --*/
  29. {
  30. NTSTATUS Status;
  31. PWCHAR pSrvName;
  32. BOOLEAN Verifyer;
  33. PMRX_SRVCALL_CALLBACK_CONTEXT SCCBC = pCallbackContext;
  34. PMRX_SRV_CALL pSrvCall;
  35. PMRX_SRVCALLDOWN_STRUCTURE SrvCalldownStructure =
  36. (PMRX_SRVCALLDOWN_STRUCTURE)(SCCBC->SrvCalldownStructure);
  37. pSrvCall = SrvCalldownStructure->SrvCall;
  38. ASSERT( pSrvCall );
  39. ASSERT( NodeType(pSrvCall) == RDBSS_NTC_SRVCALL );
  40. // validate the server name with the test name of 'nulsvr'
  41. DbgPrint("NulMRx - SrvCall: Connection Name Length: %d\n", pSrvCall->pSrvCallName->Length );
  42. if ( pSrvCall->pSrvCallName->Length >= 14 )
  43. {
  44. pSrvName = pSrvCall->pSrvCallName->Buffer;
  45. Verifyer = ( pSrvName[0] == L'\\' );
  46. Verifyer &= ( pSrvName[1] == L'N' ) || ( pSrvName[1] == L'n' );
  47. Verifyer &= ( pSrvName[2] == L'U' ) || ( pSrvName[2] == L'u' );
  48. Verifyer &= ( pSrvName[3] == L'L' ) || ( pSrvName[3] == L'l' );
  49. Verifyer &= ( pSrvName[4] == L'S' ) || ( pSrvName[4] == L's' );
  50. Verifyer &= ( pSrvName[5] == L'V' ) || ( pSrvName[5] == L'v' );
  51. Verifyer &= ( pSrvName[6] == L'R' ) || ( pSrvName[6] == L'r' );
  52. Verifyer &= ( pSrvName[7] == L'\\' ) || ( pSrvName[7] == L'\0' );
  53. }
  54. else
  55. {
  56. Verifyer = FALSE;
  57. }
  58. if ( Verifyer )
  59. {
  60. RxDbgTrace( 0, Dbg, ("Verifier Succeeded!!!!!!!!!\n"));
  61. Status = STATUS_SUCCESS;
  62. }
  63. else
  64. {
  65. RxDbgTrace( 0, Dbg, ("Verifier Failed!!!!!!!!!\n"));
  66. Status = STATUS_BAD_NETWORK_PATH;
  67. }
  68. SCCBC->Status = Status;
  69. SrvCalldownStructure->CallBack(SCCBC);
  70. return Status;
  71. }
  72. NTSTATUS
  73. NulMRxCreateSrvCall(
  74. PMRX_SRV_CALL pSrvCall,
  75. PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext)
  76. /*++
  77. Routine Description:
  78. This routine patches the RDBSS created srv call instance with the information required
  79. by the mini redirector.
  80. Arguments:
  81. RxContext - Supplies the context of the original create/ioctl
  82. CallBackContext - the call back context in RDBSS for continuation.
  83. Return Value:
  84. RXSTATUS - The return status for the operation
  85. --*/
  86. {
  87. NTSTATUS Status;
  88. UNICODE_STRING ServerName;
  89. PMRX_SRVCALLDOWN_STRUCTURE SrvCalldownStructure =
  90. (PMRX_SRVCALLDOWN_STRUCTURE)(pCallbackContext->SrvCalldownStructure);
  91. ASSERT( pSrvCall );
  92. ASSERT( NodeType(pSrvCall) == RDBSS_NTC_SRVCALL );
  93. //
  94. // If this request was made on behalf of the RDBSS, do ExecuteCreatSrvCall
  95. // immediately. If the request was made from somewhere else, create a work item
  96. // and place it on a queue for a worker thread to process later. This distinction
  97. // is made to simplify transport handle management.
  98. //
  99. if (IoGetCurrentProcess() == RxGetRDBSSProcess())
  100. {
  101. RxDbgTrace( 0, Dbg, ("Called in context of RDBSS process\n"));
  102. //
  103. // Peform the processing immediately because RDBSS is the initiator of this
  104. // request
  105. //
  106. Status = ExecuteCreateSrvCall(pCallbackContext);
  107. }
  108. else
  109. {
  110. RxDbgTrace( 0, Dbg, ("Dispatching to worker thread\n"));
  111. //
  112. // Dispatch the request to a worker thread because the redirected drive
  113. // buffering sub-system (RDBSS) was not the initiator
  114. //
  115. Status = RxDispatchToWorkerThread(
  116. NulMRxDeviceObject,
  117. DelayedWorkQueue,
  118. ExecuteCreateSrvCall,
  119. pCallbackContext);
  120. if (Status == STATUS_SUCCESS)
  121. {
  122. //
  123. // Map the return value since the wrapper expects PENDING.
  124. //
  125. Status = STATUS_PENDING;
  126. }
  127. }
  128. return Status;
  129. }
  130. NTSTATUS
  131. NulMRxFinalizeSrvCall(
  132. PMRX_SRV_CALL pSrvCall,
  133. BOOLEAN Force)
  134. /*++
  135. Routine Description:
  136. This routine destroys a given server call instance
  137. Arguments:
  138. pSrvCall - the server call instance to be disconnected.
  139. Force - TRUE if a disconnection is to be enforced immediately.
  140. Return Value:
  141. RXSTATUS - The return status for the operation
  142. --*/
  143. {
  144. NTSTATUS Status = STATUS_SUCCESS;
  145. RxDbgTrace( 0, Dbg, ("NulMRxFinalizeSrvCall \n"));
  146. pSrvCall->Context = NULL;
  147. return(Status);
  148. }
  149. NTSTATUS
  150. NulMRxSrvCallWinnerNotify(
  151. IN PMRX_SRV_CALL pSrvCall,
  152. IN BOOLEAN ThisMinirdrIsTheWinner,
  153. IN OUT PVOID pSrvCallContext
  154. )
  155. /*++
  156. Routine Description:
  157. This routine finalizes the mini rdr context associated with an RDBSS Server call instance
  158. Arguments:
  159. pSrvCall - the Server Call
  160. ThisMinirdrIsTheWinner - TRUE if this mini rdr is the choosen one.
  161. pSrvCallContext - the server call context created by the mini redirector.
  162. Return Value:
  163. RXSTATUS - The return status for the operation
  164. Notes:
  165. The two phase construction protocol for Server calls is required because of parallel
  166. initiation of a number of mini redirectors. The RDBSS finalizes the particular mini
  167. redirector to be used in communicating with a given server based on quality of
  168. service criterion.
  169. --*/
  170. {
  171. NTSTATUS Status = STATUS_SUCCESS;
  172. RxDbgTrace( 0, Dbg, ("NulMRxSrvCallWinnerNotify \n"));
  173. if( ThisMinirdrIsTheWinner ) {
  174. RxDbgTrace(0, Dbg, ("This minirdr is the winner \n"));
  175. }
  176. pSrvCall->Context = (PVOID)0xDEADBEEFDEADBEEF;
  177. return(Status);
  178. }
  179.