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.

403 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. cxinit.c
  5. Abstract:
  6. Initialization code for the Cluster Network Driver.
  7. Author:
  8. Mike Massa (mikemas) January 3, 1997
  9. Revision History:
  10. Who When What
  11. -------- -------- ----------------------------------------------
  12. mikemas 01-03-97 created
  13. Notes:
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #include "cxinit.tmh"
  18. //
  19. // Tdi Data
  20. //
  21. HANDLE CxTdiRegistrationHandle = NULL;
  22. HANDLE CxTdiPnpBindingHandle = NULL;
  23. //
  24. // FIPS function table
  25. //
  26. HANDLE CxFipsDriverHandle = NULL;
  27. FIPS_FUNCTION_TABLE CxFipsFunctionTable;
  28. #ifdef ALLOC_PRAGMA
  29. #pragma alloc_text(INIT, CxLoad)
  30. #pragma alloc_text(PAGE, CxUnload)
  31. #pragma alloc_text(PAGE, CxInitialize)
  32. #pragma alloc_text(PAGE, CxShutdown)
  33. #endif // ALLOC_PRAGMA
  34. //
  35. // Routines
  36. //
  37. NTSTATUS
  38. CxLoad(
  39. IN PUNICODE_STRING RegistryPath
  40. )
  41. /*++
  42. Routine Description:
  43. Driver load routine for the cluster transport. Initializes all
  44. transport data structures.
  45. Arguments:
  46. RegistryPath - The driver's registry key.
  47. Return Value:
  48. An NT status code.
  49. --*/
  50. {
  51. NTSTATUS status;
  52. UNICODE_STRING deviceName;
  53. TDI_CLIENT_INTERFACE_INFO info;
  54. IF_CNDBG(CN_DEBUG_INIT) {
  55. CNPRINT(("[CX] Loading...\n"));
  56. }
  57. TdiInitialize();
  58. //
  59. // Register our device object with TDI.
  60. //
  61. RtlInitUnicodeString(&deviceName, DD_CDP_DEVICE_NAME);
  62. status = TdiRegisterDeviceObject(&deviceName, &CxTdiRegistrationHandle);
  63. if (!NT_SUCCESS(status)) {
  64. CNPRINT((
  65. "[CX] Unable to register device %ws with TDI, status %lx\n",
  66. deviceName.Buffer,
  67. status
  68. ));
  69. return(status);
  70. }
  71. //
  72. // Register for PnP events.
  73. //
  74. RtlZeroMemory(&info, sizeof(info));
  75. info.MajorTdiVersion = 2;
  76. info.MinorTdiVersion = 0;
  77. info.ClientName = &deviceName;
  78. info.AddAddressHandlerV2 = CxTdiAddAddressHandler;
  79. info.DelAddressHandlerV2 = CxTdiDelAddressHandler;
  80. status = TdiRegisterPnPHandlers(
  81. &info,
  82. sizeof(info),
  83. &CxTdiPnpBindingHandle
  84. );
  85. if (!NT_SUCCESS(status)) {
  86. CNPRINT((
  87. "[CX] Unable to register for TDI PnP events, status %lx\n",
  88. status
  89. ));
  90. return(status);
  91. }
  92. //
  93. // Register for WMI NDIS media status events.
  94. //
  95. status = CxWmiPnpLoad();
  96. if (!NT_SUCCESS(status)) {
  97. CNPRINT((
  98. "[CX] Failed to initialize WMI PnP event handlers, "
  99. "status %lx\n",
  100. status
  101. ));
  102. }
  103. //
  104. // Get the FIPS function table. Hold onto the FIPS driver
  105. // handle so that the FIPS driver cannot unload.
  106. //
  107. status = CnpOpenDevice(FIPS_DEVICE_NAME, &CxFipsDriverHandle);
  108. if (NT_SUCCESS(status)) {
  109. status = CnpZwDeviceControl(
  110. CxFipsDriverHandle,
  111. IOCTL_FIPS_GET_FUNCTION_TABLE,
  112. NULL,
  113. 0,
  114. &CxFipsFunctionTable,
  115. sizeof(CxFipsFunctionTable)
  116. );
  117. if (!NT_SUCCESS(status)) {
  118. IF_CNDBG(CN_DEBUG_INIT) {
  119. CNPRINT(("[CNP] Failed to fill FIPS function "
  120. "table, status %x.\n", status));
  121. }
  122. }
  123. } else {
  124. CxFipsDriverHandle = NULL;
  125. IF_CNDBG(CN_DEBUG_INIT) {
  126. CNPRINT(("[CNP] Failed to open FIPS device, "
  127. "status %x.\n", status));
  128. }
  129. }
  130. if (status != STATUS_SUCCESS) {
  131. return(status);
  132. }
  133. status = CnpLoadNodes();
  134. if (status != STATUS_SUCCESS) {
  135. return(status);
  136. }
  137. status = CnpLoadNetworks();
  138. if (status != STATUS_SUCCESS) {
  139. return(status);
  140. }
  141. status = CnpLoad();
  142. if (status != STATUS_SUCCESS) {
  143. return(status);
  144. }
  145. status = CcmpLoad();
  146. if (status != STATUS_SUCCESS) {
  147. return(status);
  148. }
  149. status = CxInitializeHeartBeat();
  150. if (status != STATUS_SUCCESS) {
  151. return(status);
  152. }
  153. status = CdpLoad();
  154. if (status != STATUS_SUCCESS) {
  155. return(status);
  156. }
  157. IF_CNDBG(CN_DEBUG_INIT) {
  158. CNPRINT(("[CX] Loaded.\n"));
  159. }
  160. return(STATUS_SUCCESS);
  161. } // CxLoad
  162. VOID
  163. CxUnload(
  164. VOID
  165. )
  166. /*++
  167. Routine Description:
  168. Called when the Cluster Network driver is unloading. Frees all resources
  169. allocated by the Cluster Transport.
  170. The Transport is guaranteed not to receive any more user-mode requests,
  171. membership send requests, or membership events at the time
  172. this routine is called.
  173. A shutdown of the Cluster Network driver has already occured when this
  174. routine is called.
  175. Arguments:
  176. None.
  177. Return Value:
  178. None
  179. Notes:
  180. This routine MUST be callable even if CxLoad() has not yet been
  181. called.
  182. --*/
  183. {
  184. PAGED_CODE();
  185. IF_CNDBG(CN_DEBUG_INIT) {
  186. CNPRINT(("[CX] Unloading...\n"));
  187. }
  188. CxUnreserveClusnetEndpoint();
  189. CdpUnload();
  190. CxUnloadHeartBeat();
  191. CcmpUnload();
  192. CnpUnload();
  193. CxWmiPnpUnload();
  194. if (CxFipsDriverHandle != NULL) {
  195. ZwClose(CxFipsDriverHandle);
  196. CxFipsDriverHandle = NULL;
  197. }
  198. if (CxTdiPnpBindingHandle != NULL) {
  199. TdiDeregisterPnPHandlers(CxTdiPnpBindingHandle);
  200. CxTdiPnpBindingHandle = NULL;
  201. }
  202. if (CxTdiRegistrationHandle != NULL) {
  203. TdiDeregisterDeviceObject(CxTdiRegistrationHandle);
  204. CxTdiRegistrationHandle = NULL;
  205. }
  206. IF_CNDBG(CN_DEBUG_INIT) {
  207. CNPRINT(("[CX] Unloaded.\n"));
  208. }
  209. return;
  210. } // CxUnload
  211. NTSTATUS
  212. CxInitialize(
  213. VOID
  214. )
  215. /*++
  216. Routine Description:
  217. Initialization routine for the Cluster Transport.
  218. Called when the Membership Manager is starting up.
  219. Enables operation of the transport.
  220. Arguments:
  221. None.
  222. Return Value:
  223. An NT status code.
  224. --*/
  225. {
  226. NTSTATUS status;
  227. IF_CNDBG(CN_DEBUG_INIT) {
  228. CNPRINT(("[CX] Initializing...\n"));
  229. }
  230. EventEpoch = 0;
  231. status = CnpInitializeNodes();
  232. if (!NT_SUCCESS(status)) {
  233. return(status);
  234. }
  235. status = CnpInitializeNetworks();
  236. if (!NT_SUCCESS(status)) {
  237. return(status);
  238. }
  239. status = CxWmiPnpInitialize();
  240. if (!NT_SUCCESS(status)) {
  241. return(status);
  242. }
  243. IF_CNDBG(CN_DEBUG_INIT) {
  244. CNPRINT(("[CX] Initialized...\n"));
  245. }
  246. return(STATUS_SUCCESS);
  247. } // CxInitialize
  248. VOID
  249. CxShutdown(
  250. VOID
  251. )
  252. /*++
  253. Routine Description:
  254. Terminates operation of the Cluster Transport.
  255. Called when the Membership Manager is shutting down.
  256. Arguments:
  257. None.
  258. Return Value:
  259. None.
  260. --*/
  261. {
  262. IF_CNDBG(CN_DEBUG_INIT) {
  263. CNPRINT(("[CX] Shutting down...\n"));
  264. }
  265. CnpStopHeartBeats();
  266. CxWmiPnpShutdown();
  267. CnpShutdownNetworks();
  268. CnpShutdownNodes();
  269. IF_CNDBG(CN_DEBUG_INIT) {
  270. CNPRINT(("[CX] Shutdown complete...\n"));
  271. }
  272. return;
  273. } // CxShutdown