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.

166 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ipsecspd.c
  5. Abstract:
  6. This module contains all of the code to drive
  7. the WirelessPOl Service.
  8. Author:
  9. abhisheV 30-September-1999
  10. Environment
  11. User Level: Win32
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. DWORD WINAPI InitWirelessPolicy ( )
  16. {
  17. DWORD dwError = 0;
  18. InitMiscGlobals();
  19. dwError = InitSPDThruRegistry();
  20. BAIL_ON_WIN32_ERROR(dwError);
  21. dwError = InitSPDGlobals();
  22. BAIL_ON_WIN32_ERROR(dwError);
  23. _WirelessDbg(TRC_TRACK, "Starting the Service Wait Loop ");
  24. InitializePolicyStateBlock(
  25. gpWirelessPolicyState
  26. );
  27. // Intialize the policy Engine with Cached Wireless Policy
  28. dwError = PlumbCachePolicy(
  29. gpWirelessPolicyState
  30. );
  31. if (dwError) {
  32. gpWirelessPolicyState->dwCurrentState = POLL_STATE_INITIAL;
  33. _WirelessDbg(TRC_STATE, "Policy State :: Initial State ");
  34. gCurrentPollingInterval = gpWirelessPolicyState->DefaultPollingInterval;
  35. dwError = 0; // dont return this error
  36. }
  37. return(dwError);
  38. error:
  39. WirelessSPDShutdown(dwError);
  40. return(dwError);
  41. }
  42. VOID
  43. WirelessSPDShutdown(
  44. IN DWORD dwErrorCode
  45. )
  46. {
  47. /*
  48. gbIKENotify = FALSE;
  49. */
  50. DeletePolicyInformation(NULL);
  51. ClearPolicyStateBlock(
  52. gpWirelessPolicyState
  53. );
  54. ClearSPDGlobals();
  55. return;
  56. }
  57. VOID
  58. ClearSPDGlobals(
  59. )
  60. {
  61. if (ghNewDSPolicyEvent) {
  62. CloseHandle(ghNewDSPolicyEvent);
  63. ghNewDSPolicyEvent = NULL;
  64. }
  65. if (ghForcedPolicyReloadEvent) {
  66. CloseHandle(ghForcedPolicyReloadEvent);
  67. ghForcedPolicyReloadEvent = NULL;
  68. }
  69. if (ghPolicyChangeNotifyEvent) {
  70. CloseHandle(ghPolicyChangeNotifyEvent);
  71. ghPolicyChangeNotifyEvent = NULL;
  72. }
  73. if (ghPolicyEngineStopEvent) {
  74. CloseHandle(ghPolicyEngineStopEvent);
  75. }
  76. if (ghReApplyPolicy8021x) {
  77. CloseHandle(ghReApplyPolicy8021x);
  78. }
  79. /*
  80. if (gbSPDAuditSection) {
  81. DeleteCriticalSection(&gcSPDAuditSection);
  82. }
  83. if (gpSPDSD) {
  84. LocalFree(gpSPDSD);
  85. gpSPDSD = NULL;
  86. }
  87. */
  88. }
  89. VOID
  90. InitMiscGlobals(
  91. )
  92. {
  93. //
  94. // Init globals that aren't cleared on service stop to make sure
  95. // everything's in a known state on start. This allows us to
  96. // stop/restart without having our DLL unloaded/reloaded first.
  97. //
  98. gpWirelessPolicyState = &gWirelessPolicyState;
  99. gCurrentPollingInterval = 0;
  100. gDefaultPollingInterval = 166*60; // (seconds).
  101. gpszWirelessDSPolicyKey = L"SOFTWARE\\Policies\\Microsoft\\Windows\\Wireless\\GPTWirelessPolicy";
  102. gpszWirelessCachePolicyKey = L"SOFTWARE\\Policies\\Microsoft\\Windows\\Wireless\\Policy\\Cache";
  103. gpszLocPolicyAgent = L"SYSTEM\\CurrentControlSet\\Services\\WZCSVC";
  104. gdwDSConnectivityCheck = 0;
  105. ghNewDSPolicyEvent = NULL;
  106. ghForcedPolicyReloadEvent = NULL;
  107. ghPolicyChangeNotifyEvent = NULL;
  108. return;
  109. }