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.

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