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.

143 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. event.c
  5. Abstract:
  6. This module contains code which performs the following TDI services:
  7. o TdiSetEventHandler
  8. Environment:
  9. Kernel mode
  10. Revision History:
  11. Sanjay Anand (SanjayAn) 3-Oct-1995
  12. Changes to support transfer of buffer ownership to transports
  13. 1. Added a new event type - TDI_EVENT_CHAINED_RECEIVE_DATAGRAM
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. NTSTATUS
  18. IpxTdiSetEventHandler(
  19. IN PREQUEST Request
  20. )
  21. /*++
  22. Routine Description:
  23. This routine performs the TdiSetEventHandler request for the
  24. transport provider. The caller (request dispatcher) verifies
  25. that this routine will not be executed on behalf of a user-mode
  26. client, as this request enables direct callouts at DISPATCH_LEVEL.
  27. Arguments:
  28. Request - Pointer to the request
  29. Return Value:
  30. NTSTATUS - status of operation.
  31. --*/
  32. {
  33. NTSTATUS Status;
  34. CTELockHandle LockHandle;
  35. PTDI_REQUEST_KERNEL_SET_EVENT Parameters;
  36. PADDRESS_FILE AddressFile;
  37. //
  38. // Get the Address this is associated with; if there is none, get out.
  39. //
  40. AddressFile = REQUEST_OPEN_CONTEXT(Request);
  41. Status = IpxVerifyAddressFile (AddressFile);
  42. if (!NT_SUCCESS (Status)) {
  43. return Status;
  44. }
  45. CTEGetLock (&AddressFile->Address->Lock, &LockHandle);
  46. Parameters = (PTDI_REQUEST_KERNEL_SET_EVENT)REQUEST_PARAMETERS(Request);
  47. switch (Parameters->EventType) {
  48. case TDI_EVENT_RECEIVE_DATAGRAM:
  49. if (Parameters->EventHandler == NULL) {
  50. AddressFile->ReceiveDatagramHandler =
  51. (PTDI_IND_RECEIVE_DATAGRAM)TdiDefaultRcvDatagramHandler;
  52. AddressFile->ReceiveDatagramHandlerContext = NULL;
  53. AddressFile->RegisteredReceiveDatagramHandler = FALSE;
  54. } else {
  55. AddressFile->ReceiveDatagramHandler =
  56. (PTDI_IND_RECEIVE_DATAGRAM)Parameters->EventHandler;
  57. AddressFile->ReceiveDatagramHandlerContext = Parameters->EventContext;
  58. AddressFile->RegisteredReceiveDatagramHandler = TRUE;
  59. }
  60. break;
  61. //
  62. // [SA] New event handler to receive chained buffers
  63. //
  64. case TDI_EVENT_CHAINED_RECEIVE_DATAGRAM:
  65. if (Parameters->EventHandler == NULL) {
  66. AddressFile->ChainedReceiveDatagramHandler =
  67. (PTDI_IND_CHAINED_RECEIVE_DATAGRAM)TdiDefaultChainedRcvDatagramHandler;
  68. AddressFile->ChainedReceiveDatagramHandlerContext = NULL;
  69. AddressFile->RegisteredChainedReceiveDatagramHandler = FALSE;
  70. } else {
  71. AddressFile->ChainedReceiveDatagramHandler =
  72. (PTDI_IND_CHAINED_RECEIVE_DATAGRAM)Parameters->EventHandler;
  73. AddressFile->ChainedReceiveDatagramHandlerContext = Parameters->EventContext;
  74. AddressFile->RegisteredChainedReceiveDatagramHandler = TRUE;
  75. }
  76. break;
  77. case TDI_EVENT_ERROR:
  78. if (Parameters->EventHandler == NULL) {
  79. AddressFile->ErrorHandler =
  80. (PTDI_IND_ERROR)TdiDefaultErrorHandler;
  81. AddressFile->ErrorHandlerContext = NULL;
  82. AddressFile->RegisteredErrorHandler = FALSE;
  83. } else {
  84. AddressFile->ErrorHandler =
  85. (PTDI_IND_ERROR)Parameters->EventHandler;
  86. AddressFile->ErrorHandlerContext = Parameters->EventContext;
  87. AddressFile->RegisteredErrorHandler = TRUE;
  88. }
  89. break;
  90. default:
  91. Status = STATUS_INVALID_PARAMETER;
  92. } /* switch */
  93. CTEFreeLock (&AddressFile->Address->Lock, LockHandle);
  94. IpxDereferenceAddressFile (AddressFile, AFREF_VERIFY);
  95. REQUEST_INFORMATION(Request) = 0;
  96. return Status;
  97. } /* IpxTdiSetEventHandler */
  98.