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.

211 lines
4.4 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // PolicyQM.h : Declaration of CQMPolicy class which implements
  3. // our WMI class Nsp_QMPolicySettings
  4. // Copyright (c)1997-2001 Microsoft Corporation
  5. //
  6. // Original Create Date: 3/8/2001
  7. // Original Author: shawnwu
  8. //////////////////////////////////////////////////////////////////////
  9. #pragma once
  10. #include "globals.h"
  11. #include "Policy.h"
  12. //
  13. // flags for quick mode policy's negotiation
  14. //
  15. enum EnumEncryption
  16. {
  17. RAS_L2TP_NO_ENCRYPTION,
  18. RAS_L2TP_OPTIONAL_ENCRYPTION,
  19. RAS_L2TP_REQUIRE_MAX_ENCRYPTION,
  20. RAS_L2TP_REQUIRE_ENCRYPTION,
  21. };
  22. /*
  23. Class description
  24. Naming:
  25. CQMPolicy stands for Quick Mode Policy.
  26. Base class:
  27. CIPSecBase, because it is a class representing a WMI object - its WMI
  28. class name is Nsp_QMPolicySettings
  29. Purpose of class:
  30. (1) Nsp_QMPolicySettings is the WMI class for SPD's IPSEC_QM_POLICY.
  31. Design:
  32. (1) it implements IIPSecObjectImpl.
  33. Use:
  34. (1) You probably will never create an instance and use it directly. Everything
  35. should normall go through IIPSecObjectImpl for non-static functions.
  36. */
  37. class ATL_NO_VTABLE CQMPolicy :
  38. public CIPSecPolicy
  39. {
  40. protected:
  41. CQMPolicy(){}
  42. virtual ~CQMPolicy(){}
  43. public:
  44. //
  45. // IIPSecObjectImpl methods:
  46. //
  47. STDMETHOD(QueryInstance) (
  48. IN LPCWSTR pszQuery,
  49. IN IWbemContext * pCtx,
  50. IN IWbemObjectSink * pSink
  51. );
  52. STDMETHOD(DeleteInstance) (
  53. IN IWbemContext * pCtx,
  54. IN IWbemObjectSink * pSink
  55. );
  56. STDMETHOD(PutInstance) (
  57. IN IWbemClassObject * pInst,
  58. IN IWbemContext * pCtx,
  59. IN IWbemObjectSink * pSink
  60. );
  61. STDMETHOD(GetInstance) (
  62. IN IWbemContext * pCtx,
  63. IN IWbemObjectSink * pSink
  64. );
  65. static
  66. HRESULT AddPolicy (
  67. IN bool bPreExist,
  68. IN PIPSEC_QM_POLICY pQMPolicy
  69. );
  70. static
  71. HRESULT DeletePolicy (
  72. IN LPCWSTR pszPolicyName
  73. );
  74. static
  75. HRESULT ExecMethod (
  76. IN IWbemServices * pNamespace,
  77. IN LPCWSTR pszMethod,
  78. IN IWbemContext * pCtx,
  79. IN IWbemClassObject * pInParams,
  80. IN IWbemObjectSink * pSink
  81. );
  82. static
  83. HRESULT DeleteDefaultPolicies();
  84. static
  85. HRESULT DoReturn (
  86. IN IWbemServices * pNamespace,
  87. IN LPCWSTR pszMethod,
  88. IN DWORD dwCount,
  89. IN LPCWSTR * pszValueNames,
  90. IN VARIANT * varValues,
  91. IN IWbemContext * pCtx,
  92. IN IWbemObjectSink * pSink
  93. );
  94. private:
  95. static
  96. HRESULT CreateDefaultPolicy (
  97. EnumEncryption eEncryption
  98. );
  99. HRESULT CreateWbemObjFromQMPolicy (
  100. IN PIPSEC_QM_POLICY pPolicy,
  101. OUT IWbemClassObject ** ppObj
  102. );
  103. HRESULT GetQMPolicyFromWbemObj (
  104. IN IWbemClassObject * pInst,
  105. OUT PIPSEC_QM_POLICY * ppPolicy,
  106. OUT bool * pbPreExist
  107. );
  108. static
  109. LPCWSTR GetDefaultPolicyName (
  110. EnumEncryption eEncryption
  111. );
  112. };
  113. //
  114. // The following functions are used to create default QM policies
  115. //
  116. DWORD
  117. BuildOffers(
  118. EnumEncryption eEncryption,
  119. IPSEC_QM_OFFER * pOffers,
  120. PDWORD pdwNumOffers,
  121. PDWORD pdwFlags
  122. );
  123. DWORD
  124. BuildOptEncryption(
  125. IPSEC_QM_OFFER * pOffers,
  126. PDWORD pdwNumOffers
  127. );
  128. DWORD
  129. BuildRequireEncryption(
  130. IPSEC_QM_OFFER * pOffers,
  131. PDWORD pdwNumOffers
  132. );
  133. DWORD
  134. BuildNoEncryption(
  135. IPSEC_QM_OFFER * pOffers,
  136. PDWORD pdwNumOffers
  137. );
  138. DWORD
  139. BuildStrongEncryption(
  140. IPSEC_QM_OFFER * pOffers,
  141. PDWORD pdwNumOffers
  142. );
  143. void
  144. BuildOffer(
  145. IPSEC_QM_OFFER * pOffer,
  146. DWORD dwNumAlgos,
  147. DWORD dwFirstOperation,
  148. DWORD dwFirstAlgoIdentifier,
  149. DWORD dwFirstAlgoSecIdentifier,
  150. DWORD dwSecondOperation,
  151. DWORD dwSecondAlgoIdentifier,
  152. DWORD dwSecondAlgoSecIdentifier,
  153. DWORD dwKeyExpirationBytes,
  154. DWORD dwKeyExpirationTime
  155. );
  156. VOID
  157. BuildQMPolicy(
  158. PIPSEC_QM_POLICY pQMPolicy,
  159. EnumEncryption eEncryption,
  160. PIPSEC_QM_OFFER pOffers,
  161. DWORD dwNumOffers,
  162. DWORD dwFlags
  163. );