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.

126 lines
2.9 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. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. PVOID TdiDefaultHandlers[6] = {
  15. TdiDefaultConnectHandler,
  16. TdiDefaultDisconnectHandler,
  17. TdiDefaultErrorHandler,
  18. TdiDefaultReceiveHandler,
  19. TdiDefaultRcvDatagramHandler,
  20. TdiDefaultRcvExpeditedHandler
  21. };
  22. NTSTATUS
  23. NbiTdiSetEventHandler(
  24. IN PDEVICE Device,
  25. IN PREQUEST Request
  26. )
  27. /*++
  28. Routine Description:
  29. This routine performs the TdiSetEventHandler request for the
  30. transport provider. The caller (request dispatcher) verifies
  31. that this routine will not be executed on behalf of a user-mode
  32. client, as this request enables direct callouts at DISPATCH_LEVEL.
  33. Arguments:
  34. Device - The netbios device object.
  35. Request - Pointer to the request.
  36. Return Value:
  37. NTSTATUS - status of operation.
  38. --*/
  39. {
  40. NTSTATUS Status;
  41. CTELockHandle LockHandle;
  42. PTDI_REQUEST_KERNEL_SET_EVENT Parameters;
  43. PADDRESS_FILE AddressFile;
  44. UINT EventType;
  45. UNREFERENCED_PARAMETER (Device);
  46. //
  47. // Check that the file type is valid
  48. //
  49. if (REQUEST_OPEN_TYPE(Request) != (PVOID)TDI_TRANSPORT_ADDRESS_FILE)
  50. {
  51. CTEAssert(FALSE);
  52. return (STATUS_INVALID_ADDRESS_COMPONENT);
  53. }
  54. //
  55. // Get the Address this is associated with; if there is none, get out.
  56. //
  57. AddressFile = REQUEST_OPEN_CONTEXT(Request);
  58. #if defined(_PNP_POWER)
  59. Status = NbiVerifyAddressFile (AddressFile, CONFLICT_IS_OK);
  60. #else
  61. Status = NbiVerifyAddressFile (AddressFile);
  62. #endif _PNP_POWER
  63. if (!NT_SUCCESS (Status)) {
  64. return Status;
  65. }
  66. NB_GET_LOCK (&AddressFile->Address->Lock, &LockHandle);
  67. Parameters = (PTDI_REQUEST_KERNEL_SET_EVENT)REQUEST_PARAMETERS(Request);
  68. EventType = (UINT)(Parameters->EventType);
  69. if (Parameters->EventType > TDI_EVENT_RECEIVE_EXPEDITED) {
  70. Status = STATUS_INVALID_PARAMETER;
  71. } else {
  72. if (Parameters->EventHandler == NULL) {
  73. AddressFile->RegisteredHandler[EventType] = FALSE;
  74. AddressFile->Handlers[EventType] = TdiDefaultHandlers[EventType];
  75. AddressFile->HandlerContexts[EventType] = NULL;
  76. } else {
  77. AddressFile->Handlers[EventType] = Parameters->EventHandler;
  78. AddressFile->HandlerContexts[EventType] = Parameters->EventContext;
  79. AddressFile->RegisteredHandler[EventType] = TRUE;
  80. }
  81. }
  82. NB_FREE_LOCK (&AddressFile->Address->Lock, LockHandle);
  83. NbiDereferenceAddressFile (AddressFile, AFREF_VERIFY);
  84. return Status;
  85. } /* NbiTdiSetEventHandler */