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.

190 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. callback.c
  5. Abstract:
  6. This module implements NCP Response callback routines.
  7. Author:
  8. Manny Weiser [MannyW] 3-Mar-1993
  9. Revision History:
  10. --*/
  11. #include "procs.h"
  12. #define Dbg (DEBUG_TRACE_EXCHANGE)
  13. #ifdef ALLOC_PRAGMA
  14. #ifndef QFE_BUILD
  15. #pragma alloc_text( PAGE1, SynchronousResponseCallback )
  16. #pragma alloc_text( PAGE1, AsynchResponseCallback )
  17. #endif
  18. #endif
  19. #if 0 // Not pageable
  20. // see ifndef QFE_BUILD above
  21. #endif
  22. NTSTATUS
  23. SynchronousResponseCallback (
  24. IN PIRP_CONTEXT pIrpContext,
  25. IN ULONG BytesAvailable,
  26. IN PUCHAR RspData
  27. )
  28. /*++
  29. Routine Description:
  30. This routine is the callback routine for an NCP which has no
  31. return parameters and the caller blocks waiting for a response.
  32. Arguments:
  33. pIrpContext - A pointer to the context information for this IRP.
  34. BytesAvailable - Actual number of bytes in the received message.
  35. RspData - Points to the receive buffer.
  36. Return Value:
  37. NTSTATUS - Status of the operation.
  38. --*/
  39. {
  40. PEPrequest *pNcpHeader;
  41. PEPresponse *pNcpResponse;
  42. DebugTrace( 0, Dbg, "SynchronousResponseCallback\n", 0 );
  43. ASSERT( pIrpContext->pNpScb->Requests.Flink == &pIrpContext->NextRequest );
  44. if ( BytesAvailable == 0) {
  45. //
  46. // No response from server. Status is in pIrpContext->
  47. // ResponseParameters.Error
  48. //
  49. #ifdef MSWDBG
  50. ASSERT( pIrpContext->Event.Header.SignalState == 0 );
  51. pIrpContext->DebugValue = 0x103;
  52. #endif
  53. pIrpContext->pOriginalIrp->IoStatus.Status = STATUS_REMOTE_NOT_LISTENING;
  54. NwSetIrpContextEvent( pIrpContext );
  55. return STATUS_REMOTE_NOT_LISTENING;
  56. }
  57. pIrpContext->ResponseLength = BytesAvailable;
  58. //
  59. // Simply copy the data into the response buffer, if it is not
  60. // already there (because we used an IRP to receive the data).
  61. //
  62. if ( RspData != pIrpContext->rsp ) {
  63. CopyBufferToMdl( pIrpContext->RxMdl, 0, RspData, pIrpContext->ResponseLength );
  64. }
  65. //
  66. // Remember the returned error code.
  67. //
  68. pNcpHeader = (PEPrequest *)pIrpContext->rsp;
  69. pNcpResponse = (PEPresponse *)(pNcpHeader + 1);
  70. pIrpContext->ResponseParameters.Error = pNcpResponse->error;
  71. //
  72. // Tell the caller that the response has been received.
  73. //
  74. #ifdef MSWDBG
  75. ASSERT( pIrpContext->Event.Header.SignalState == 0 );
  76. pIrpContext->DebugValue = 0x104;
  77. #endif
  78. pIrpContext->pOriginalIrp->IoStatus.Status = STATUS_SUCCESS;
  79. pIrpContext->pOriginalIrp->IoStatus.Information = BytesAvailable;
  80. NwSetIrpContextEvent( pIrpContext );
  81. return STATUS_SUCCESS;
  82. }
  83. NTSTATUS
  84. AsynchResponseCallback (
  85. IN PIRP_CONTEXT pIrpContext,
  86. IN ULONG BytesAvailable,
  87. IN PUCHAR RspData
  88. )
  89. /*++
  90. Routine Description:
  91. This routine is the callback routine for an NCP which has no
  92. return parameters and the caller DOES NOT BLOCK waiting for a
  93. response.
  94. Arguments:
  95. pIrpContext - A pointer to the context information for this IRP.
  96. BytesAvailable - Actual number of bytes in the received message.
  97. RspData - Points to the receive buffer.
  98. Return Value:
  99. NTSTATUS - Status of the operation.
  100. --*/
  101. {
  102. NTSTATUS Status;
  103. if ( BytesAvailable == 0) {
  104. //
  105. // No response from server. Status is in pIrpContext->
  106. // ResponseParameters.Error
  107. //
  108. Status = STATUS_REMOTE_NOT_LISTENING;
  109. } else {
  110. if ( ((PNCP_RESPONSE)RspData)->Status != 0 ) {
  111. Status = STATUS_LINK_FAILED;
  112. } else {
  113. Status = NwErrorToNtStatus( ((PNCP_RESPONSE)RspData)->Error );
  114. }
  115. }
  116. //
  117. // We're done with this request. Dequeue the IRP context from
  118. // SCB and complete the request.
  119. //
  120. NwDequeueIrpContext( pIrpContext, FALSE );
  121. NwCompleteRequest( pIrpContext, Status );
  122. return STATUS_SUCCESS;
  123. }