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.

312 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. IKE utils
  5. Abstract:
  6. Contains parameter validation
  7. Author:
  8. BrianSw 10-19-200
  9. Environment:
  10. User Level: Win32
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. DWORD
  15. ValidateInitiateIKENegotiation(
  16. STRING_HANDLE pServerName,
  17. PQM_FILTER_CONTAINER pQMFilterContainer,
  18. DWORD dwClientProcessId,
  19. ULONG uhClientEvent,
  20. DWORD dwFlags,
  21. IKENEGOTIATION_HANDLE * phIKENegotiation
  22. )
  23. {
  24. DWORD dwError=ERROR_SUCCESS;
  25. if (pQMFilterContainer == NULL ||
  26. pQMFilterContainer->pQMFilters == NULL) {
  27. dwError=ERROR_INVALID_PARAMETER;
  28. }
  29. if (pServerName && (wcscmp(pServerName,L"") != 0)) {
  30. if (uhClientEvent || phIKENegotiation || dwClientProcessId) {
  31. dwError=ERROR_NOT_SUPPORTED;
  32. BAIL_ON_WIN32_ERROR(dwError);
  33. }
  34. } else {
  35. if (phIKENegotiation || dwClientProcessId || uhClientEvent) {
  36. if (!phIKENegotiation || !dwClientProcessId || !uhClientEvent) {
  37. dwError=ERROR_INVALID_PARAMETER;
  38. BAIL_ON_WIN32_ERROR(dwError);
  39. }
  40. }
  41. }
  42. if (!(pQMFilterContainer->pQMFilters) ||
  43. !(pQMFilterContainer->dwNumFilters)) {
  44. dwError = ERROR_INVALID_PARAMETER;
  45. BAIL_ON_WIN32_ERROR(dwError);
  46. }
  47. dwError = ValidateIPSecQMFilter(
  48. pQMFilterContainer->pQMFilters
  49. );
  50. BAIL_ON_WIN32_ERROR(dwError);
  51. error:
  52. return dwError;
  53. }
  54. DWORD
  55. ValidateQueryIKENegotiationStatus(
  56. IKENEGOTIATION_HANDLE hIKENegotiation,
  57. SA_NEGOTIATION_STATUS_INFO *NegotiationStatus
  58. )
  59. {
  60. DWORD dwError=ERROR_SUCCESS;
  61. if (!hIKENegotiation || !NegotiationStatus) {
  62. dwError = ERROR_INVALID_PARAMETER;
  63. BAIL_ON_WIN32_ERROR(dwError);
  64. }
  65. error:
  66. return dwError;
  67. }
  68. DWORD
  69. ValidateCloseIKENegotiationHandle(
  70. IKENEGOTIATION_HANDLE * phIKENegotiation
  71. )
  72. {
  73. DWORD dwError=ERROR_SUCCESS;
  74. if (!phIKENegotiation) {
  75. dwError=ERROR_INVALID_PARAMETER;
  76. }
  77. BAIL_ON_WIN32_ERROR(dwError);
  78. error:
  79. return dwError;
  80. }
  81. DWORD
  82. ValidateEnumMMSAs(
  83. STRING_HANDLE pServerName,
  84. PMM_SA_CONTAINER pMMTemplate,
  85. PMM_SA_CONTAINER *ppMMSAContainer,
  86. LPDWORD pdwNumEntries,
  87. LPDWORD pdwTotalMMsAvailable,
  88. LPDWORD pdwEnumHandle,
  89. DWORD dwFlags
  90. )
  91. {
  92. DWORD dwError=ERROR_SUCCESS;
  93. if (pMMTemplate == NULL ||
  94. pMMTemplate->pMMSAs == NULL ||
  95. ppMMSAContainer == NULL ||
  96. *ppMMSAContainer == NULL ||
  97. pdwNumEntries == NULL ||
  98. pdwTotalMMsAvailable == NULL ||
  99. pdwEnumHandle == NULL ) {
  100. dwError=ERROR_INVALID_PARAMETER;
  101. }
  102. BAIL_ON_WIN32_ERROR(dwError);
  103. error:
  104. return dwError;
  105. }
  106. DWORD
  107. ValidateDeleteMMSAs(
  108. STRING_HANDLE pServerName,
  109. PMM_SA_CONTAINER pMMTemplate,
  110. DWORD dwFlags
  111. )
  112. {
  113. DWORD dwError=ERROR_SUCCESS;
  114. if (pMMTemplate == NULL ||
  115. pMMTemplate->pMMSAs == NULL) {
  116. dwError=ERROR_INVALID_PARAMETER;
  117. }
  118. BAIL_ON_WIN32_ERROR(dwError);
  119. error:
  120. return dwError;
  121. }
  122. DWORD
  123. ValidateQueryIKEStatistics(
  124. STRING_HANDLE pServerName,
  125. IKE_STATISTICS *pIKEStatistics
  126. )
  127. {
  128. DWORD dwError=ERROR_SUCCESS;
  129. if (pIKEStatistics == NULL) {
  130. dwError=ERROR_INVALID_PARAMETER;
  131. }
  132. BAIL_ON_WIN32_ERROR(dwError);
  133. error:
  134. return dwError;
  135. }
  136. DWORD
  137. ValidateRegisterIKENotifyClient(
  138. STRING_HANDLE pServerName,
  139. DWORD dwClientProcessId,
  140. ULONG uhClientEvent,
  141. PQM_SA_CONTAINER pQMSATemplateContainer,
  142. IKENOTIFY_HANDLE *phNotifyHandle,
  143. DWORD dwFlags
  144. )
  145. {
  146. DWORD dwError=ERROR_SUCCESS;
  147. if (pServerName && (wcscmp(pServerName,L"") != 0)) {
  148. return ERROR_NOT_SUPPORTED;
  149. }
  150. if (pQMSATemplateContainer == NULL ||
  151. pQMSATemplateContainer->pQMSAs == NULL ||
  152. phNotifyHandle == NULL) {
  153. dwError=ERROR_INVALID_PARAMETER;
  154. }
  155. BAIL_ON_WIN32_ERROR(dwError);
  156. error:
  157. return dwError;
  158. }
  159. DWORD ValidateQueryNotifyData(
  160. IKENOTIFY_HANDLE uhNotifyHandle,
  161. PDWORD pdwNumEntries,
  162. PQM_SA_CONTAINER *ppQMSAContainer,
  163. DWORD dwFlags
  164. )
  165. {
  166. DWORD dwError=ERROR_SUCCESS;
  167. if (ppQMSAContainer == NULL ||
  168. *ppQMSAContainer == NULL ||
  169. pdwNumEntries == NULL ||
  170. *pdwNumEntries == 0) {
  171. dwError=ERROR_INVALID_PARAMETER;
  172. }
  173. BAIL_ON_WIN32_ERROR(dwError);
  174. error:
  175. return dwError;
  176. }
  177. DWORD ValidateCloseNotifyHandle(
  178. IKENOTIFY_HANDLE *phHandle
  179. )
  180. {
  181. DWORD dwError=ERROR_SUCCESS;
  182. if (phHandle == NULL) {
  183. dwError=ERROR_INVALID_PARAMETER;
  184. }
  185. BAIL_ON_WIN32_ERROR(dwError);
  186. error:
  187. return dwError;
  188. }
  189. DWORD ValidateIPSecAddSA(
  190. STRING_HANDLE pServerName,
  191. PIPSEC_QM_POLICY_CONTAINER pQMPolicyContainer,
  192. PQM_FILTER_CONTAINER pQMFilterContainer,
  193. DWORD *uhLarvalContext,
  194. DWORD dwInboundKeyMatLen,
  195. BYTE *pInboundKeyMat,
  196. DWORD dwOutboundKeyMatLen,
  197. BYTE *pOutboundKeyMat,
  198. BYTE *pContextInfo,
  199. DWORD dwFlags)
  200. {
  201. DWORD dwError=ERROR_SUCCESS;
  202. if (!pQMFilterContainer ||
  203. !pQMPolicyContainer ||
  204. pContextInfo == NULL) {
  205. dwError= ERROR_INVALID_PARAMETER;
  206. }
  207. BAIL_ON_WIN32_ERROR(dwError);
  208. if (uhLarvalContext == NULL){
  209. dwError= ERROR_INVALID_PARAMETER;
  210. BAIL_ON_WIN32_ERROR(dwError);
  211. }
  212. if (!(pQMFilterContainer->pQMFilters) ||
  213. !(pQMFilterContainer->dwNumFilters)) {
  214. dwError = ERROR_INVALID_PARAMETER;
  215. BAIL_ON_WIN32_ERROR(dwError);
  216. }
  217. if (!(pQMPolicyContainer->pPolicies) ||
  218. !(pQMPolicyContainer->dwNumPolicies)) {
  219. dwError = ERROR_INVALID_PARAMETER;
  220. BAIL_ON_WIN32_ERROR(dwError);
  221. }
  222. dwError = ValidateIPSecQMFilter(
  223. pQMFilterContainer->pQMFilters
  224. );
  225. BAIL_ON_WIN32_ERROR(dwError);
  226. dwError = ValidateQMOffers(
  227. 1,
  228. pQMPolicyContainer->pPolicies->pOffers);
  229. BAIL_ON_WIN32_ERROR(dwError);
  230. if ((dwFlags & IPSEC_SA_INBOUND) &&
  231. (dwFlags & IPSEC_SA_OUTBOUND)) {
  232. dwError= ERROR_INVALID_PARAMETER;
  233. BAIL_ON_WIN32_ERROR(dwError);
  234. }
  235. error:
  236. return dwError;
  237. }