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.

305 lines
5.6 KiB

  1. //
  2. // Constants used to identify what general structure has been initialized.
  3. //
  4. #define INIT_SA_DATABASE 0x00000001
  5. #define INIT_MDL_POOLS 0x00000002
  6. #define INIT_CACHE_STRUCT 0x00000004
  7. #define INIT_DEBUG_MEMORY 0x00000008
  8. #define INIT_TIMERS 0x00000010
  9. #define WORK_BUFFER_SIZE 256
  10. #define IPSEC_REG_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\IPSEC"
  11. #define IPSEC_REG_PARAM_ENABLE_OFFLOAD L"EnableOffload"
  12. #define IPSEC_REG_PARAM_SA_IDLE_TIME L"SAIdleTime"
  13. #define IPSEC_REG_PARAM_EVENT_QUEUE_SIZE L"EventQueueSize"
  14. #define IPSEC_REG_PARAM_LOG_INTERVAL L"LogInterval"
  15. #define IPSEC_REG_PARAM_REKEY_TIME L"RekeyTime"
  16. #define IPSEC_REG_PARAM_CACHE_SIZE L"CacheSize"
  17. #define IPSEC_REG_PARAM_SA_HASH_SIZE L"SAHashSize"
  18. #define IPSEC_REG_PARAM_NO_DEFAULT_EXEMPT L"NoDefaultExempt"
  19. #define IPSEC_REG_PARAM_ENABLE_DIAGNOSTICS L"EnableDiagnostics"
  20. #define IPSEC_REG_PARAM_OPERATION_MODE L"OperationMode"
  21. //
  22. // Enable offload.
  23. //
  24. #define IPSEC_DEFAULT_ENABLE_OFFLOAD 1
  25. #define IPSEC_MIN_ENABLE_OFFLOAD 0
  26. #define IPSEC_MAX_ENABLE_OFFLOAD 1
  27. //
  28. // SA idle time.
  29. //
  30. #define IPSEC_DEFAULT_SA_IDLE_TIME (5 * 60)
  31. #define IPSEC_MIN_SA_IDLE_TIME (5 * 60)
  32. #define IPSEC_MAX_SA_IDLE_TIME (60 * 60)
  33. //
  34. // Log interval.
  35. //
  36. #define IPSEC_DEFAULT_LOG_INTERVAL (60 * 60)
  37. #define IPSEC_MIN_LOG_INTERVAL (60)
  38. #define IPSEC_MAX_LOG_INTERVAL (24 * 60 * 60)
  39. //
  40. // Event queue size.
  41. //
  42. #define IPSEC_DEFAULT_EVENT_QUEUE_SIZE 50
  43. #define IPSEC_MIN_EVENT_QUEUE_SIZE 10
  44. #define IPSEC_MAX_EVENT_QUEUE_SIZE 500
  45. //
  46. // Rekey time.
  47. //
  48. #define IPSEC_DEFAULT_REKEY 600
  49. #define IPSEC_MIN_REKEY 300
  50. #define IPSEC_MAX_REKEY 1500
  51. //
  52. // No kerberos exempt.
  53. //
  54. #define IPSEC_DEFAULT_NO_DEFAULT_EXEMPT 0
  55. #define IPSEC_MIN_NO_DEFAULT_EXEMPT 0
  56. #define IPSEC_MAX_NO_DEFAULT_EXEMPT 3
  57. #define IPSEC_DIAGNOSTIC_ENABLE_LOG 0x00000001
  58. #define IPSEC_DIAGNOSTIC_INBOUND 0x00000002
  59. #define IPSEC_DIAGNOSTIC_OUTBOUND 0x00000004
  60. #define IPSEC_DEFAULT_ENABLE_DIAGNOSTICS 0
  61. #define IPSEC_MIN_ENABLE_DIAGNOSTICS 0
  62. #define IPSEC_MAX_ENABLE_DIAGNOSTICS 0x00000007
  63. //
  64. // First level (IP header based) cache size.
  65. //
  66. #define IPSEC_DEFAULT_CACHE_SIZE 64
  67. #define IPSEC_DEFAULT_AS_CACHE_SIZE 1024
  68. #define IPSEC_MIN_CACHE_SIZE 64
  69. #define IPSEC_MAX_CACHE_SIZE 4096
  70. //
  71. // Size of the <SPI, Dest> hash table for inbound SAs.
  72. //
  73. #define IPSEC_DEFAULT_SA_HASH_SIZE 64
  74. #define IPSEC_DEFAULT_AS_SA_HASH_SIZE 1024
  75. #define IPSEC_MIN_SA_HASH_SIZE 64
  76. #define IPSEC_MAX_SA_HASH_SIZE 4096
  77. NTSTATUS
  78. DriverEntry(
  79. IN PDRIVER_OBJECT DriverObject,
  80. IN PUNICODE_STRING RegistryPath
  81. );
  82. VOID
  83. IPSecUnload(
  84. IN PDRIVER_OBJECT DriverObject
  85. );
  86. NTSTATUS
  87. IPSecDispatch(
  88. IN PDEVICE_OBJECT DeviceObject,
  89. IN PIRP Irp
  90. );
  91. NTSTATUS
  92. IPSecBindToIP(
  93. );
  94. NTSTATUS
  95. IPSecUnbindFromIP(
  96. );
  97. NTSTATUS
  98. IPSecUnbindSendFromIP(
  99. );
  100. NTSTATUS
  101. OpenRegKey(
  102. PHANDLE HandlePtr,
  103. PWCHAR KeyName
  104. );
  105. NTSTATUS
  106. GetRegDWORDValue(
  107. HANDLE KeyHandle,
  108. PWCHAR ValueName,
  109. PULONG ValueData
  110. );
  111. NTSTATUS
  112. GetRegStringValue(
  113. HANDLE KeyHandle,
  114. PWCHAR ValueName,
  115. PKEY_VALUE_PARTIAL_INFORMATION *ValueData,
  116. PUSHORT ValueSize
  117. );
  118. NTSTATUS
  119. GetRegMultiSZValue(
  120. HANDLE KeyHandle,
  121. PWCHAR ValueName,
  122. PUNICODE_STRING ValueData
  123. );
  124. VOID
  125. IPSecReadRegistry(
  126. );
  127. NTSTATUS
  128. IPSecGeneralInit(
  129. );
  130. NTSTATUS
  131. IPSecGeneralFree(
  132. );
  133. NTSTATUS
  134. IPSecFreeConfig(
  135. );
  136. NTSTATUS
  137. IPSecInitMdlPool(
  138. );
  139. VOID
  140. IPSecDeinitMdlPool(
  141. );
  142. NTSTATUS
  143. IPSecQuiesce(
  144. );
  145. BOOLEAN
  146. AllocateCacheStructures(
  147. );
  148. VOID
  149. FreeExistingCache(
  150. );
  151. VOID
  152. FreePatternDbase(
  153. );
  154. SIZE_T
  155. IPSecCalculateBufferSize(
  156. IN SIZE_T BufferDataSize
  157. );
  158. VOID
  159. IPSecInitializeBuffer(
  160. IN PIPSEC_LA_BUFFER IPSecBuffer,
  161. IN SIZE_T BufferDataSize
  162. );
  163. PVOID
  164. IPSecAllocateBufferPool(
  165. IN POOL_TYPE PoolType,
  166. IN SIZE_T NumberOfBytes,
  167. IN ULONG Tag
  168. );
  169. PIPSEC_LA_BUFFER
  170. IPSecGetBuffer(
  171. IN CLONG BufferDataSize,
  172. IN ULONG Tag
  173. );
  174. VOID
  175. IPSecReturnBuffer (
  176. IN PIPSEC_LA_BUFFER IPSecBuffer
  177. );
  178. NTSTATUS
  179. IPSecWriteEvent(
  180. PDRIVER_OBJECT IPSecDriverObject,
  181. IN ULONG EventCode,
  182. IN NTSTATUS NtStatusCode,
  183. IN ULONG OffloadStatus,
  184. IN ULONG ExtraStatus1,
  185. IN ULONG ExtraStatus2,
  186. IN PVOID RawDataBuffer,
  187. IN USHORT RawDataLength,
  188. IN USHORT NumberOfInsertionStrings,
  189. ...
  190. );
  191. VOID
  192. IPSecLogEvents(
  193. IN PVOID Context
  194. );
  195. VOID
  196. IPSecBufferEvent(
  197. IN IPAddr Addr,
  198. IN ULONG EventCode,
  199. IN ULONG UniqueEventValue,
  200. IN BOOLEAN fBufferEvent
  201. );
  202. NTSTATUS
  203. CopyOutboundPacketToBuffer(
  204. IN PUCHAR pIPHeader,
  205. IN PVOID pData,
  206. OUT PUCHAR * pPacket,
  207. OUT ULONG * PacketSize
  208. );
  209. NTSTATUS
  210. CopyInboundPacketToBuffer(
  211. IN PUCHAR pIPHeader,
  212. IN PVOID pData,
  213. OUT PUCHAR * pPacket,
  214. OUT ULONG * PacketSize
  215. );
  216. VOID
  217. IPSecBufferPacketDrop(
  218. IN PUCHAR pIPHeader,
  219. IN PVOID pData,
  220. IN OUT PULONG pIpsecFlags,
  221. IN PIPSEC_DROP_STATUS pDropStatus
  222. );
  223. VOID
  224. IPSecQueueLogEvent(
  225. VOID
  226. );
  227. #if FIPS
  228. BOOLEAN
  229. IPSecFipsInitialize(
  230. VOID
  231. );
  232. #endif
  233. BOOLEAN
  234. IPSecCryptoInitialize(
  235. VOID
  236. );
  237. BOOLEAN
  238. IPSecCryptoDeinitialize(
  239. VOID
  240. );
  241. NTSTATUS
  242. IPSecRegisterProtocols(
  243. PIPSEC_REGISTER_PROTOCOL pIpsecRegisterProtocol
  244. );