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.

103 lines
2.3 KiB

  1. #include "precomp.h"
  2. DWORD
  3. ExportISAKMPDataToFile(
  4. HANDLE hSrcPolicyStore,
  5. PIPSEC_POLICY_STORE pDesPolicyStore
  6. )
  7. {
  8. DWORD dwError = 0;
  9. PIPSEC_ISAKMP_DATA * ppIpsecISAKMPData = NULL;
  10. DWORD dwNumISAKMPObjects = 0;
  11. DWORD i = 0;
  12. PIPSEC_ISAKMP_DATA pIpsecISAKMPData = NULL;
  13. dwError = IPSecEnumISAKMPData(
  14. hSrcPolicyStore,
  15. &ppIpsecISAKMPData,
  16. &dwNumISAKMPObjects
  17. );
  18. BAIL_ON_WIN32_ERROR(dwError);
  19. for (i = 0; i < dwNumISAKMPObjects; i++) {
  20. pIpsecISAKMPData = *(ppIpsecISAKMPData + i);
  21. dwError = RegCreateISAKMPData(
  22. pDesPolicyStore->hRegistryKey,
  23. pDesPolicyStore->pszIpsecRootContainer,
  24. pIpsecISAKMPData
  25. );
  26. BAIL_ON_WIN32_ERROR(dwError);
  27. }
  28. error:
  29. if (ppIpsecISAKMPData) {
  30. FreeMulIpsecISAKMPData(
  31. ppIpsecISAKMPData,
  32. dwNumISAKMPObjects
  33. );
  34. }
  35. return (dwError);
  36. }
  37. DWORD
  38. ImportISAKMPDataFromFile(
  39. PIPSEC_POLICY_STORE pSrcPolicyStore,
  40. HANDLE hDesPolicyStore
  41. )
  42. {
  43. DWORD dwError = 0;
  44. PIPSEC_ISAKMP_DATA * ppIpsecISAKMPData = NULL;
  45. DWORD dwNumISAKMPObjects = 0;
  46. DWORD i = 0;
  47. PIPSEC_ISAKMP_DATA pIpsecISAKMPData = NULL;
  48. dwError = RegEnumISAKMPData(
  49. pSrcPolicyStore->hRegistryKey,
  50. pSrcPolicyStore->pszIpsecRootContainer,
  51. &ppIpsecISAKMPData,
  52. &dwNumISAKMPObjects
  53. );
  54. BAIL_ON_WIN32_ERROR(dwError);
  55. for (i = 0; i < dwNumISAKMPObjects; i++) {
  56. pIpsecISAKMPData = *(ppIpsecISAKMPData + i);
  57. dwError = IPSecCreateISAKMPData(
  58. hDesPolicyStore,
  59. pIpsecISAKMPData
  60. );
  61. if (dwError == ERROR_OBJECT_ALREADY_EXISTS) {
  62. dwError = IPSecSetISAKMPData(
  63. hDesPolicyStore,
  64. pIpsecISAKMPData
  65. );
  66. BAIL_ON_WIN32_ERROR(dwError);
  67. }
  68. BAIL_ON_WIN32_ERROR(dwError);
  69. }
  70. error:
  71. if (ppIpsecISAKMPData) {
  72. FreeMulIpsecISAKMPData(
  73. ppIpsecISAKMPData,
  74. dwNumISAKMPObjects
  75. );
  76. }
  77. return (dwError);
  78. }