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.

96 lines
3.0 KiB

  1. // define UNICODE for this module so linking works
  2. #ifndef _POL2STORE_H_
  3. #define _POL2STORE_H_
  4. const time_t P2STORE_DEFAULT_POLLINT = 60 * 180;
  5. const HRESULT P2STORE_MISSING_NAME = 0x00000013;
  6. // these are the versions of storage that we want
  7. const DWORD P2S_MAJOR_VER = 0x00010000;
  8. const DWORD P2S_MINOR_VER = 0x00000000;
  9. class IPSECPolicyToStorage
  10. {
  11. public:
  12. // these just to initialization/deleting,
  13. // you must call Open to do anything useful
  14. IPSECPolicyToStorage();
  15. ~IPSECPolicyToStorage();
  16. // opens the location and establishes
  17. // an ipsec policy to work with
  18. HRESULT
  19. Open(IN DWORD location,
  20. IN LPTSTR name,
  21. IN LPTSTR szPolicyName,
  22. IN LPTSTR szDescription = NULL,
  23. IN time_t tPollingInterval = P2STORE_DEFAULT_POLLINT,
  24. IN bool bUseExisting = false);
  25. // add rules to the policy
  26. HRESULT
  27. AddRule(IN IPSEC_IKE_POLICY ,
  28. IN PSTORAGE_INFO pStorageInfo = NULL);
  29. HRESULT
  30. AddDefaultResponseRule( );
  31. // associates an ISAKMP policy
  32. HRESULT SetISAKMPPolicy(IPSEC_MM_POLICY);
  33. HRESULT
  34. UpdateRule(
  35. IN PIPSEC_NFA_DATA pRule,
  36. IN IPSEC_IKE_POLICY IpsecIkePol,
  37. IN PSTORAGE_INFO pStorageInfo = NULL);
  38. bool IsOpen() { return mybIsOpen; }
  39. bool IsPolicyInStorage() { return mybPolicyExists; }
  40. // will return a list of filters given a filter spec
  41. // WILL NOT COMMIT to the storage
  42. PIPSEC_FILTER_DATA IPSECPolicyToStorage::MakeFilters(
  43. T2P_FILTER *Filters,
  44. UINT NumFilters,
  45. LPWSTR);
  46. PIPSEC_POLICY_DATA GetPolicy() { return myIPSECPolicy; }
  47. HANDLE GetStorageHandle() { return myPolicyStorage; }
  48. DWORD SetAssignedPolicy(PIPSEC_POLICY_DATA p)
  49. {
  50. PIPSEC_POLICY_DATA pActive = NULL;
  51. DWORD dwReturn = ERROR_SUCCESS;
  52. dwReturn = IsPolicyInStorage() ?
  53. (IPSecGetAssignedPolicyData(myPolicyStorage, &pActive),
  54. pActive ? IPSecUnassignPolicy(myPolicyStorage, pActive->PolicyIdentifier) : 0,
  55. IPSecAssignPolicy(myPolicyStorage, p->PolicyIdentifier)) :
  56. ERROR_ACCESS_DENIED;
  57. // if (pActive) IPSecFreePolicyData(pActive);
  58. // polstore AVs if something inside the policy is missing
  59. return dwReturn;
  60. }
  61. // this is temp patch
  62. static LPVOID ReallocPolMem (LPVOID pOldMem, DWORD cbOld, DWORD cbNew);
  63. private:
  64. void TryToCreatePolicy();
  65. PIPSEC_NEGPOL_DATA
  66. MakeNegotiationPolicy(IPSEC_QM_POLICY IpsPol,
  67. LPWSTR);
  68. PIPSEC_NEGPOL_DATA MakeDefaultResponseNegotiationPolicy ( );
  69. PIPSEC_NFA_DATA
  70. MakeRule(IN IPSEC_IKE_POLICY IpsecIkePol, IN PSTORAGE_INFO pStorageInfo = NULL);
  71. PIPSEC_NFA_DATA MakeDefaultResponseRule ( );
  72. HANDLE myPolicyStorage;
  73. PIPSEC_POLICY_DATA myIPSECPolicy;
  74. bool mybIsOpen;
  75. bool mybPolicyExists;
  76. };
  77. #endif
  78.