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.

140 lines
4.3 KiB

  1. // Copyright (c) 1997, Microsoft Corporation, all rights reserved
  2. //
  3. // main.c
  4. // RAS L2TP WAN mini-port/call-manager driver
  5. // Main routine (DriverEntry) and global data definitions
  6. //
  7. // 01/07/97 Steve Cobb
  8. #include "l2tpp.h"
  9. #include "main.tmh"
  10. //-----------------------------------------------------------------------------
  11. // Local prototypes
  12. //-----------------------------------------------------------------------------
  13. NDIS_STATUS
  14. DriverEntry(
  15. IN PDRIVER_OBJECT DriverObject,
  16. IN PUNICODE_STRING RegistryPath );
  17. // Mark routine to be unloaded after initialization.
  18. //
  19. #pragma NDIS_INIT_FUNCTION(DriverEntry)
  20. PDRIVER_OBJECT g_DriverObject = NULL;
  21. VOID LmpUnload(
  22. PVOID DriverObject)
  23. {
  24. if(g_DriverObject != NULL)
  25. {
  26. WPP_CLEANUP(g_DriverObject);
  27. }
  28. }
  29. //-----------------------------------------------------------------------------
  30. // Routines
  31. //-----------------------------------------------------------------------------
  32. NDIS_STATUS
  33. DriverEntry(
  34. IN PDRIVER_OBJECT DriverObject,
  35. IN PUNICODE_STRING RegistryPath )
  36. // Standard 'DriverEntry' driver initialization entrypoint called by the
  37. // I/0 system at IRQL PASSIVE_LEVEL before any other call to the driver.
  38. //
  39. // On NT, 'DriverObject' is the driver object created by the I/0 system
  40. // and 'RegistryPath' specifies where driver specific parameters are
  41. // stored. These arguments are opaque to this driver (and should remain
  42. // so for portability) which only forwards them to the NDIS wrapper.
  43. //
  44. // Returns the value returned by NdisMRegisterMiniport, per the doc on
  45. // "DriverEntry of NDIS Miniport Drivers".
  46. //
  47. {
  48. NDIS_STATUS status;
  49. NDIS_MINIPORT_CHARACTERISTICS nmc;
  50. NDIS_HANDLE NdisWrapperHandle;
  51. TRACE( TL_N, TM_Init, ( "DriverEntry" ) );
  52. // Register this driver with the NDIS wrapper. This call must occur
  53. // before any other NdisXxx calls.
  54. //
  55. NdisMInitializeWrapper(
  56. &NdisWrapperHandle, DriverObject, RegistryPath, NULL );
  57. // Set up the mini-port characteristics table that tells NDIS how to call
  58. // our mini-port.
  59. //
  60. NdisZeroMemory( &nmc, sizeof(nmc) );
  61. nmc.MajorNdisVersion = NDIS_MajorVersion;
  62. nmc.MinorNdisVersion = NDIS_MinorVersion;
  63. nmc.Reserved = NDIS_USE_WAN_WRAPPER;
  64. // no CheckForHangHandler
  65. // no DisableInterruptHandler
  66. // no EnableInterruptHandler
  67. nmc.HaltHandler = LmpHalt;
  68. // no HandleInterruptHandler
  69. nmc.InitializeHandler = LmpInitialize;
  70. // no ISRHandler
  71. // no QueryInformationHandler (see CoRequestHandler)
  72. nmc.ResetHandler = LmpReset;
  73. // no SendHandler (see CoSendPacketsHandler)
  74. // no WanSendHandler (see CoSendPacketsHandler)
  75. // no SetInformationHandler (see CoRequestHandler)
  76. // no TransferDataHandler
  77. // no WanTransferDataHandler
  78. nmc.ReturnPacketHandler = LmpReturnPacket;
  79. // no SendPacketsHandler (see CoSendPacketsHandler)
  80. // no AllocateCompleteHandler
  81. nmc.CoActivateVcHandler = LmpCoActivateVc;
  82. nmc.CoDeactivateVcHandler = LmpCoDeactivateVc;
  83. nmc.CoSendPacketsHandler = LmpCoSendPackets;
  84. nmc.CoRequestHandler = LmpCoRequest;
  85. // Register this driver as the L2TP mini-port. This will result in NDIS
  86. // calling back at LmpInitialize.
  87. //
  88. TRACE( TL_V, TM_Init, ( "NdisMRegMp" ) );
  89. status = NdisMRegisterMiniport( NdisWrapperHandle, &nmc, sizeof(nmc) );
  90. TRACE( TL_A, TM_Init, ( "NdisMRegMp=$%x", status ) );
  91. if (status == NDIS_STATUS_SUCCESS)
  92. {
  93. {
  94. extern CALLSTATS g_stats;
  95. extern NDIS_SPIN_LOCK g_lockStats;
  96. NdisZeroMemory( &g_stats, sizeof(g_stats) );
  97. NdisAllocateSpinLock( &g_lockStats );
  98. }
  99. #ifdef PSDEBUG
  100. {
  101. extern LIST_ENTRY g_listDebugPs;
  102. extern NDIS_SPIN_LOCK g_lockDebugPs;
  103. InitializeListHead( &g_listDebugPs );
  104. NdisAllocateSpinLock( &g_lockDebugPs );
  105. }
  106. #endif
  107. // WPP tracing support
  108. NdisMRegisterUnloadHandler(NdisWrapperHandle, LmpUnload);
  109. g_DriverObject = DriverObject;
  110. WPP_INIT_TRACING(DriverObject, RegistryPath);
  111. }
  112. else
  113. {
  114. NdisTerminateWrapper( NdisWrapperHandle, NULL );
  115. }
  116. return status;
  117. }