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.

649 lines
22 KiB

  1. /*++
  2. Copyright (c) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. globals.h
  5. Abstract:
  6. This is the main header file for IPSEC. Contains all the globals.
  7. Author:
  8. Sanjay Anand (SanjayAn) 2-January-1997
  9. ChunYe
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #ifndef _GLOBALS_H
  15. #define _GLOBALS_H
  16. #define MAX_COUNT_STRING_LEN 32
  17. #define MAX_IP_OPTION_SIZE 40
  18. // 64 bytes
  19. #define MAX_KEYLEN_SHA 64
  20. #define MAX_KEYLEN_MD5 64
  21. // 8 bytes
  22. #define MAX_KEYLEN_DES 8
  23. #define MAX_IV_LEN DES_BLOCKLEN
  24. #define MAX_KEY_LEN MAX(MAX_KEYLEN_MD5, MAX_KEYLEN_DES)
  25. //
  26. // we set aside SPIs between 256 and 65536 (64K) for hardware offload
  27. //
  28. #define LOWER_BOUND_SPI 256
  29. #define UPPER_BOUND_SPI ((ULONG) -1) // MAX_ULONG
  30. #define INVALID_INDEX 0xffffffff
  31. #define RNG_KEY_SIZE 256 // 2048 bits
  32. #define RNG_REKEY_THRESHOLD 65536 // 64K raw bytes
  33. //
  34. // Constants related to filter lists
  35. //
  36. #define INBOUND_TRANSPORT_FILTER 0
  37. #define OUTBOUND_TRANSPORT_FILTER 1
  38. #define INBOUND_TUNNEL_FILTER 2
  39. #define OUTBOUND_TUNNEL_FILTER 3
  40. #define MIN_FILTER INBOUND_TRANSPORT_FILTER
  41. #define MAX_FILTER OUTBOUND_TUNNEL_FILTER
  42. #define MIN_TRANSPORT_FILTER INBOUND_TRANSPORT_FILTER
  43. #define MAX_TRANSPORT_FILTER OUTBOUND_TRANSPORT_FILTER
  44. #define MIN_TUNNEL_FILTER INBOUND_TUNNEL_FILTER
  45. #define MAX_TUNNEL_FILTER OUTBOUND_TUNNEL_FILTER
  46. #define INBOUND_OUTBOUND_INCREMENT 1
  47. #define TRANSPORT_TUNNEL_INCREMENT 2
  48. #define NUM_FILTERS (MAX_FILTER - MIN_FILTER + 1)
  49. //
  50. // Number of extra bytes when we pad - one for padlen and other for payloadtype
  51. //
  52. #define NUM_EXTRA 2
  53. #define ESP_SIZE (sizeof(ESP) + DES_BLOCKLEN * sizeof(UCHAR))
  54. #define TRUNCATED_HASH_LEN 12 // 96 bits
  55. #define REPLAY_WINDOW_SIZE 64
  56. #define MAX_PAD_LEN (DES_BLOCKLEN + NUM_EXTRA - 1)
  57. #define IPSEC_SMALL_BUFFER_SIZE 50
  58. #define IPSEC_LARGE_BUFFER_SIZE 200
  59. #define IPSEC_CACHE_LINE_SIZE 16
  60. #define IPSEC_LIST_DEPTH 5
  61. typedef ULONG tSPI;
  62. #define MAX_BLOCKLEN MAX(DES_BLOCKLEN, 0)
  63. #define IPSEC_TAG_INIT 'ISpI'
  64. #define IPSEC_TAG_AH 'TApI'
  65. #define IPSEC_TAG_AH_TU 'UApI'
  66. #define IPSEC_TAG_ESP 'TEpI'
  67. #define IPSEC_TAG_ESP_TU 'UEpI'
  68. #define IPSEC_TAG_HUGHES 'THpI'
  69. #define IPSEC_TAG_HUGHES_TU 'UHpI'
  70. #define IPSEC_TAG_ACQUIRE_CTX 'XApI'
  71. #define IPSEC_TAG_FILTER 'IFpI'
  72. #define IPSEC_TAG_SA 'ASpI'
  73. #define IPSEC_TAG_KEY 'EKpI'
  74. #define IPSEC_TAG_TIMER 'ITpI'
  75. #define IPSEC_TAG_STALL_QUEUE 'QSpI'
  76. #define IPSEC_TAG_LOOKASIDE_LISTS 'ALpI'
  77. #define IPSEC_TAG_BUFFER_POOL 'PBpI'
  78. #define IPSEC_TAG_SEND_COMPLETE 'CSpI'
  79. #define IPSEC_TAG_EVT_QUEUE 'QEpI'
  80. #define IPSEC_TAG_HW 'WHpI'
  81. #define IPSEC_TAG_HW_PKTINFO 'KPpI'
  82. #define IPSEC_TAG_HW_PKTEXT 'XEpI'
  83. #define IPSEC_TAG_HW_ADDSA 'SApI'
  84. #define IPSEC_TAG_HW_DELSA 'SDpI'
  85. #define IPSEC_TAG_HW_PLUMB 'LPpI'
  86. #define IPSEC_TAG_COMP 'OCpI'
  87. #define IPSEC_TAG_REINJECT 'ERpI'
  88. #define IPSEC_TAG_IOCTL 'OIpI'
  89. #define IPSEC_TAG_LOG 'OLpI'
  90. #define IPSEC_LOG_PACKET_SIZE 128 //Size in bytes of stored packet in troubleshoot mode
  91. //
  92. // The IPSEC ESP payload
  93. //
  94. typedef struct _ESP {
  95. tSPI esp_spi;
  96. } ESP, *PESP;
  97. //
  98. // SA Flags - Not mutually exclusive
  99. //
  100. #define FLAGS_SA_INITIATOR 0x00000001 // use Initiator keys? might be deprecated soon
  101. #define FLAGS_SA_OUTBOUND 0x00000002 // outbound SA?
  102. #define FLAGS_SA_TUNNEL 0x00000004 // tunnel mode? sa_TunnelAddr is significant
  103. #define FLAGS_SA_REPLAY 0x00000008 // check for replays? we always generate replay fields
  104. #define FLAGS_SA_REKEY 0x00000010 // is this rekeyed LarvalSA?
  105. #define FLAGS_SA_REKEY_ORI 0x00000020 // did this kick off a rekey?
  106. #define FLAGS_SA_MANUAL 0x00000040 // manual keyed?
  107. #define FLAGS_SA_MTU_BUMPED 0x00000080 // was MTU bumped down on this SA?
  108. #define FLAGS_SA_PENDING 0x00000100 // this is on the pending queue.
  109. #define FLAGS_SA_TIMER_STARTED 0x00000200 // timer started on this SA
  110. #define FLAGS_SA_HW_PLUMBED 0x00000400 // hw acceleration plumbed successfully
  111. #define FLAGS_SA_HW_PLUMB_FAILED 0x00000800 // hw acceleration plumbing failed
  112. #define FLAGS_SA_HW_DELETE_SA 0x00001000 // hw acceleration - this is the pending delete.
  113. #define FLAGS_SA_HW_CRYPTO_ONLY 0x00002000 // hw acceleration - this is a crypto-only provider.
  114. #define FLAGS_SA_HW_RESET 0x00004000 // hw acceleration - this offload SA has been reset
  115. #define FLAGS_SA_HW_DELETE_QUEUED 0x00008000 // hw acceleration - this SA delete is queued so make sure reset doesn't touch it
  116. #define FLAGS_SA_REFERENCED 0x00010000 // is this SA the next of another?
  117. #define FLAGS_SA_NOTIFY_PERFORMED 0x00020000 // For inbound only. Notification performed
  118. #define FLAGS_SA_ON_FILTER_LIST 0x00040000 // used on inbound SAs to indicate they are on filter lists
  119. #define FLAGS_SA_ON_SPI_HASH 0x00080000 // used on inbound SAs to indicate they are on spi hash lists
  120. #define FLAGS_SA_EXPIRED 0x00100000 // has this SA expired?
  121. #define FLAGS_SA_IDLED_OUT 0x00200000 // has this SA idled out?
  122. #define FLAGS_SA_HIBERNATED 0x00400000 // has this SA been hibernated?
  123. #define FLAGS_SA_DELETE_BY_IOCTL 0x00800000 // sa delete initiated by external source
  124. #define FLAGS_SA_OFFLOADABLE 0x01000000 // is this SA offloadable?
  125. #define FLAGS_SA_PASSTHRU_FILTER 0x02000000 // sa derived from a pass-thru filter
  126. #define FLAGS_SA_DISABLE_IDLE_OUT 0x04000000 // don't idle out
  127. #define FLAGS_SA_DISABLE_ANTI_REPLAY_CHECK 0x08000000 // don't check anti-replay
  128. #define FLAGS_SA_DISABLE_LIFETIME_CHECK 0x10000000 // don't check lifetimes
  129. //
  130. // SA States - Mutually exclusive
  131. //
  132. typedef enum _SA_STATE {
  133. STATE_SA_CREATED = 1, // when created
  134. STATE_SA_LARVAL, // Key negotiation going on - outbound SAs only
  135. STATE_SA_ASSOCIATED, // corresp inbound SA created, associated with outbound SA
  136. STATE_SA_ACTIVE, // outbound SA completely setup
  137. STATE_SA_ZOMBIE // SAs flushed, ready to be deleted
  138. } SA_STATE, *PSA_STATE;
  139. #define IPSEC_SA_SIGNATURE 0x4601
  140. #define IPSEC_FILTER_SIGNATURE 0x4602
  141. #if DBG
  142. #define IPSEC_SA_D_1 'SAD1'
  143. #define IPSEC_SA_D_2 'SAD2'
  144. #define IPSEC_SA_D_3 'SAD3'
  145. #define IPSEC_SA_D_4 'SAD4'
  146. #endif
  147. typedef struct _FILTER FILTER, *PFILTER;
  148. typedef struct _INTERNAL_ALGO_INFO {
  149. ULONG algoIdentifier;
  150. PUCHAR algoKey;
  151. ULONG algoKeylen;
  152. ULONG algoRounds;
  153. } INTERNAL_ALGO_INFO, *PINTERNAL_ALGO_INFO;
  154. typedef struct _INTERNAL_ALGO {
  155. INTERNAL_ALGO_INFO integrityAlgo;
  156. INTERNAL_ALGO_INFO confAlgo;
  157. INTERNAL_ALGO_INFO compAlgo;
  158. } INTERNAL_ALGO, *PINTERNAL_ALGO;
  159. typedef struct _IPSEC_ACQUIRE_CONTEXT IPSEC_ACQUIRE_CONTEXT, *PIPSEC_ACQUIRE_CONTEXT;
  160. typedef struct _FILTER_CACHE FILTER_CACHE, *PFILTER_CACHE;
  161. //
  162. // Security Association Table (SATable)
  163. //
  164. // Indexed by the following:
  165. //
  166. // Sender maps {Src Addr, Dest Addr, User Context} to the index
  167. //
  168. // Receiver maps {Dest Addr, SPI} to the index
  169. // SPI values are unique when generated manually, so can be used directly
  170. // to index into the SATable for
  171. //
  172. typedef struct _SATableEntry {
  173. LIST_ENTRY sa_SPILinkage; // linkage in SPI hash table list
  174. LIST_ENTRY sa_FilterLinkage; // linkage in Filter table list
  175. LIST_ENTRY sa_LarvalLinkage; // linkage in Larval SA list
  176. LIST_ENTRY sa_PendingLinkage; // linkage in pending SA list - waiting for Acquire Irp
  177. struct _SATableEntry *sa_AssociatedSA; // outbound -> inbound link
  178. struct _SATableEntry *sa_RekeyLarvalSA; // points to the Larval SA on a rekey
  179. struct _SATableEntry *sa_RekeyOriginalSA; // Rekey Larval SA points to the original SA that kicked off the rekey
  180. ULONG sa_Signature; // contains 4601
  181. ULONG sa_AcquireId; // cross-check with the Acquire Irp context
  182. PIPSEC_ACQUIRE_CONTEXT sa_AcquireCtx; // actual acquire context - used to invalidate the context.
  183. ULONG sa_Flags; // flags as defined above
  184. SA_STATE sa_State; // states as defined above
  185. ULONG sa_Reference; // ref count
  186. PFILTER sa_Filter; // assoc filter entry
  187. PFILTER_CACHE sa_FilterCache; // back pointer to cache entry so we can disable it when an SA goes away
  188. KSPIN_LOCK sa_Lock; // lock to protect the FilterCache ptr.
  189. #if DBG
  190. ULONG sa_d1;
  191. #endif
  192. ULARGE_INTEGER sa_uliSrcDstAddr;
  193. ULARGE_INTEGER sa_uliSrcDstMask;
  194. ULARGE_INTEGER sa_uliProtoSrcDstPort;
  195. IPAddr sa_TunnelAddr; // Tunnel dest end IP Addr
  196. IPAddr sa_SrcTunnelAddr; // Tunnel src end IP Addr
  197. // SPI - host order - if outbound, SPI for remote,
  198. // else inbound (our) SPI
  199. tSPI sa_SPI; // Inbound: in the multiple ops case, this is the SPI of the last operation.
  200. // Outbound: order is as specified in the update.
  201. LONG sa_NumOps; // the total number of operations to be done
  202. tSPI sa_OtherSPIs[MAX_OPS]; // the other alternate SPIs.
  203. OPERATION_E sa_Operation[MAX_OPS];
  204. INTERNAL_ALGO sa_Algorithm[MAX_OPS];
  205. ULONG sa_ReplayStartPoint; // corresponds to RP_Key_I/R
  206. ULONG sa_ReplayLastSeq[MAX_OPS]; // for replay detection - last seq recd
  207. ULONGLONG sa_ReplayBitmap[MAX_OPS]; // for replay detection - 64 packet window
  208. ULONG sa_ReplaySendSeq[MAX_OPS]; // for replay detection - next seq # to send
  209. ULONG sa_ReplayLen; // for replay detection - length of replay field - 32 bits
  210. #if DBG
  211. ULONG sa_d2;
  212. #endif
  213. UCHAR sa_iv[MAX_OPS][DES_BLOCKLEN]; // IV_Key_I/R
  214. ULONG sa_ivlen;
  215. ULONG sa_TruncatedLen; // length of final hash after truncation
  216. LARGE_INTEGER sa_KeyExpirationTime; // time till re-key
  217. LARGE_INTEGER sa_KeyExpirationBytes; // max # of KBytes xformed till re-key
  218. LARGE_INTEGER sa_TotalBytesTransformed; // running total
  219. LARGE_INTEGER sa_KeyExpirationTimeWithPad;
  220. LARGE_INTEGER sa_KeyExpirationBytesWithPad;
  221. LARGE_INTEGER sa_IdleTime; // total time this SA can sit idle
  222. LARGE_INTEGER sa_LastUsedTime; // time this SA was used last
  223. #if DBG
  224. ULONG sa_d3;
  225. #endif
  226. LIFETIME sa_Lifetime;
  227. ULONG sa_BlockedDataLen; // amount of pended data
  228. PNDIS_BUFFER sa_BlockedBuffer; // stall queue of 1 Mdl chain
  229. #if DBG
  230. ULONG sa_d4;
  231. #endif
  232. Interface *sa_IPIF;
  233. IPSEC_TIMER sa_Timer; // Timer struct for timer queue
  234. ULONG sa_ExpiryTime; // time until this SA expires
  235. NDIS_HANDLE sa_OffloadHandle;
  236. LONG sa_NumSends;
  237. WORK_QUEUE_ITEM sa_QueueItem;
  238. ULONG sa_IPSecOverhead;
  239. ULONG sa_NewMTU;
  240. DWORD sa_QMPFSGroup;
  241. IKE_COOKIE_PAIR sa_CookiePair;
  242. IPSEC_SA_STATS sa_Stats;
  243. UCHAR sa_DestType;
  244. } SA_TABLE_ENTRY, *PSA_TABLE_ENTRY;
  245. //
  246. // Context used between Key manager and IPSEC. Points to the Larval SA basically.
  247. //
  248. typedef struct _IPSEC_ACQUIRE_CONTEXT {
  249. ULONG AcquireId; // unique ID to represent this transaction
  250. PSA_TABLE_ENTRY pSA; // larval SA should contain this ID
  251. } IPSEC_ACQUIRE_CONTEXT, *PIPSEC_ACQUIRE_CONTEXT;
  252. //
  253. // Packet Classification/Policy Setting is similar to that of the
  254. // Filter Driver. We dont have filters per interface, however.
  255. //
  256. typedef struct _FILTER {
  257. ULONG Signature; // contains 4602
  258. BOOLEAN TunnelFilter;
  259. BOOLEAN LinkedFilter; // true if on linked list
  260. USHORT Flags;
  261. PFILTER_CACHE FilterCache; // back pointer to cache entry so we can disable it when filter is deleted
  262. LIST_ENTRY MaskedLinkage;
  263. ULARGE_INTEGER uliSrcDstAddr;
  264. ULARGE_INTEGER uliSrcDstMask;
  265. ULARGE_INTEGER uliProtoSrcDstPort;
  266. ULARGE_INTEGER uliProtoSrcDstMask;
  267. IPAddr TunnelAddr;
  268. ULONG Reference; // ref count
  269. LONG SAChainSize; // number of entries for SA chain hash
  270. ULONG Index; // hinted index
  271. GUID PolicyId; // policy GUID
  272. GUID FilterId; // filter GUID
  273. #if GPC
  274. union {
  275. LIST_ENTRY GpcLinkage;
  276. struct _GPC_FILTER {
  277. GPC_HANDLE GpcCfInfoHandle;
  278. GPC_HANDLE GpcPatternHandle;
  279. } GpcFilter;
  280. };
  281. #endif
  282. LIST_ENTRY SAChain[1]; // chain of SAs associated with this Filter
  283. } FILTER, *PFILTER;
  284. //
  285. // a first level cache, contains IP headers cached for fast lookups
  286. //
  287. typedef struct _FILTER_CACHE {
  288. ULARGE_INTEGER uliSrcDstAddr;
  289. ULARGE_INTEGER uliProtoSrcDstPort;
  290. BOOLEAN FilterEntry; // if TRUE, the next one is a Filter
  291. union {
  292. PSA_TABLE_ENTRY pSAEntry; // points to the associated SAEntry
  293. PFILTER pFilter; // points to the (drop/PassThru filter)
  294. };
  295. PSA_TABLE_ENTRY pNextSAEntry; // points to the associated NextSAEntry
  296. #if DBG
  297. ULARGE_INTEGER CacheHitCount;
  298. #endif
  299. } FILTER_CACHE, *PFILTER_CACHE;
  300. //
  301. // Hash tables for specific SAs
  302. //
  303. typedef struct _SA_HASH {
  304. LIST_ENTRY SAList;
  305. } SA_HASH, *PSA_HASH;
  306. //
  307. // This structure is used to hold on to an Irp from the Key manager.
  308. // The Irp is completed to kick off an SA negotiation.
  309. //
  310. typedef struct _IPSEC_ACQUIRE_INFO {
  311. PIRP Irp; // irp passed down from Key manager
  312. LIST_ENTRY PendingAcquires; // linked list of pending acquire requests
  313. LIST_ENTRY PendingNotifies; // linked list of pending notifications
  314. KSPIN_LOCK Lock;
  315. BOOLEAN ResolvingNow; // irp is in user mode doing a resolve
  316. BOOLEAN InMe; // irp is in user mode doing a resolve
  317. } IPSEC_ACQUIRE_INFO, *PIPSEC_ACQUIRE_INFO;
  318. //
  319. // Buffer for lookaside list descriptors. Lookaside list descriptors
  320. // cannot be statically allocated, as they need to ALWAYS be nonpageable,
  321. // even when the entire driver is paged out.
  322. //
  323. typedef struct _IPSEC_LOOKASIDE_LISTS {
  324. NPAGED_LOOKASIDE_LIST SendCompleteCtxList;
  325. NPAGED_LOOKASIDE_LIST LargeBufferList;
  326. NPAGED_LOOKASIDE_LIST SmallBufferList;
  327. } IPSEC_LOOKASIDE_LISTS, *PIPSEC_LOOKASIDE_LISTS;
  328. //
  329. // Data is organized as an MDL followed by the actual buffer being described by
  330. // the mdl.
  331. //
  332. // !!NOTE: In the struct below, Data should be quadaligned since MDLs are always
  333. // quad-aligned.
  334. //
  335. typedef struct _IPSEC_LA_BUFFER {
  336. ULONG Tag; // the actual tag this was used for
  337. PVOID Buffer; // the actual buffer
  338. ULONG BufferLength; // length of the buffer pointed by MDL
  339. PMDL Mdl; // pointer to an MDL describing the buffer
  340. UCHAR Data[1]; // the real data starts here
  341. } IPSEC_LA_BUFFER, *PIPSEC_LA_BUFFER;
  342. typedef struct _IPSEC_GLOBAL {
  343. BOOLEAN DriverUnloading; // Is driver being unloaded?
  344. BOOLEAN BoundToIP; // Are we bound to IP yet?
  345. BOOLEAN SendBoundToIP; // Is IPSecHandler bound to IP?
  346. BOOLEAN InitCrypto; // Are crypto routines initialized?
  347. BOOLEAN InitRNG; // Is RNG initialized?
  348. BOOLEAN InitTcpip; // Is TCP/IP loaded?
  349. #if FIPS
  350. BOOLEAN InitFips; // Is Fips driver loaded and function table set?
  351. #endif
  352. #if GPC
  353. BOOLEAN InitGpc; // Is GPC driver loaded and function table set?
  354. #endif
  355. LONG NumSends; // counts the number of pending sends
  356. LONG NumThreads; // counts the number of threads in driver
  357. LONG NumWorkers; // counts the number of worker threads
  358. LONG NumTimers; // counts the number of active timers
  359. LONG NumIoctls; // counts the number of active IOCTLs
  360. LIST_ENTRY LarvalSAList;
  361. KSPIN_LOCK LarvalListLock; // protects the larval SA list
  362. MRSW_LOCK SADBLock; // protects the Filter/SA DB
  363. MRSW_LOCK SPIListLock; // protects the SPI list
  364. //
  365. // We partition the filters into tunnel/masked and inbound/outbound filters.
  366. //
  367. LIST_ENTRY FilterList[NUM_FILTERS];
  368. ULONG NumPolicies; // number of filters plumbed in the driver
  369. ULONG NumTunnelFilters;
  370. ULONG NumMaskedFilters;
  371. ULONG NumOutboundSAs;
  372. ULONG NumMulticastFilters;
  373. //
  374. // Inbound <SPI, dest> hash
  375. //
  376. PSA_HASH pSADb;
  377. LONG NumSA;
  378. LONG SAHashSize;
  379. PFILTER_CACHE *ppCache;
  380. ULONG CacheSize;
  381. ULONG CacheHalfSize;
  382. //
  383. // SA negotiate context
  384. //
  385. IPSEC_ACQUIRE_INFO AcquireInfo;
  386. //
  387. // timers
  388. //
  389. KSPIN_LOCK TimerLock;
  390. IPSEC_TIMER_LIST TimerList[IPSEC_CLASS_MAX];
  391. IPSEC_TIMER ReaperTimer; // reaper thread runs here.
  392. //
  393. // Global lookaside lists. These must always be in nonpaged pool,
  394. // even when the driver is paged out.
  395. //
  396. PIPSEC_LOOKASIDE_LISTS IPSecLookasideLists;
  397. ULONG IPSecLargeBufferSize;
  398. ULONG IPSecLargeBufferListDepth;
  399. ULONG IPSecSmallBufferSize;
  400. ULONG IPSecSmallBufferListDepth;
  401. ULONG IPSecSendCompleteCtxSize;
  402. ULONG IPSecSendCompleteCtxDepth;
  403. ULONG IPSecCacheLineSize;
  404. PDEVICE_OBJECT IPSecDevice;
  405. PDRIVER_OBJECT IPSecDriverObject;
  406. ProtInfo IPProtInfo;
  407. IPOptInfo OptInfo;
  408. //
  409. // stats
  410. //
  411. IPSEC_QUERY_STATS Statistics;
  412. ULONG EnableOffload;
  413. ULONG DefaultSAIdleTime;
  414. ULONG LogInterval;
  415. ULONG EventQueueSize;
  416. ULONG RekeyTime;
  417. ULONG NoDefaultExempt;
  418. KSPIN_LOCK EventLogLock; // lock to protect event queue
  419. IPSEC_TIMER EventLogTimer;
  420. ULONG IPSecBufferedEvents;
  421. PUCHAR IPSecLogMemory;
  422. PUCHAR IPSecLogMemoryLoc;
  423. PUCHAR IPSecLogMemoryEnd;
  424. LARGE_INTEGER SAIdleTime;
  425. #if DBG
  426. ULARGE_INTEGER CacheHitCount;
  427. #endif
  428. OPERATION_MODE OperationMode;
  429. ULONG DiagnosticMode;
  430. #if GPC
  431. GPC_EXPORTED_CALLS GpcEntries;
  432. GPC_HANDLE GpcClients[GPC_CF_MAX];
  433. ULONG GpcActive;
  434. ULONG GpcNumFilters[GPC_CF_MAX];
  435. LIST_ENTRY GpcFilterList[NUM_FILTERS];
  436. #if DBG
  437. LARGE_INTEGER GpcTotalPassedIn;
  438. LARGE_INTEGER GpcClassifyNeeded;
  439. LARGE_INTEGER GpcReClassified;
  440. #endif
  441. #endif
  442. #if FIPS
  443. PFILE_OBJECT FipsFileObject;
  444. FIPS_FUNCTION_TABLE FipsFunctionTable;
  445. #endif
  446. VOID (*TcpipFreeBuff)(struct IPRcvBuf *);
  447. INT (*TcpipAllocBuff)(struct IPRcvBuf *, UINT);
  448. UCHAR (*TcpipGetAddrType)(IPAddr);
  449. IP_STATUS (*TcpipGetInfo)(IPInfo *, INT);
  450. NDIS_STATUS (*TcpipNdisRequest)(PVOID, NDIS_REQUEST_TYPE, NDIS_OID, PVOID, UINT, PUINT);
  451. PVOID (*TcpipRegisterProtocol)(UCHAR, PVOID, PVOID, PVOID, PVOID, PVOID, PVOID);
  452. NTSTATUS (*TcpipSetIPSecStatus)(BOOLEAN);
  453. IP_STATUS (*TcpipIPTransmit)(PVOID, PVOID, PNDIS_BUFFER, UINT, IPAddr, IPAddr, IPOptInfo *, RouteCacheEntry *, UCHAR, PIRP);
  454. IP_STATUS (*TcpipSetIPSecPtr)(PIPSEC_FUNCTIONS);
  455. IP_STATUS (*TcpipUnSetIPSecPtr)(PIPSEC_FUNCTIONS);
  456. IP_STATUS (*TcpipUnSetIPSecSendPtr)(PIPSEC_FUNCTIONS);
  457. UINT (*TcpipTCPXsum)(UINT, PVOID, UINT);
  458. USHORT (*TcpipGenIpId)();
  459. PVOID (*TcpipDeRegisterProtocol)(UCHAR);
  460. } IPSEC_GLOBAL, *PIPSEC_GLOBAL;
  461. //
  462. // Contexts used to store eventlog contexts.
  463. //
  464. #define IPSEC_DROP_STATUS_CRYPTO_DONE 0x00000001
  465. #define IPSEC_DROP_STATUS_NEXT_CRYPTO_DONE 0x00000002
  466. #define IPSEC_DROP_STATUS_SA_DELETE_REQ 0x00000004
  467. #define IPSEC_DROP_STATUS_DONT_LOG 0x00000008
  468. typedef struct _IPSEC_DROP_STATUS {
  469. ULONG IPSecStatus;
  470. ULONG OffloadStatus;
  471. ULONG Flags;
  472. } IPSEC_DROP_STATUS, *PIPSEC_DROP_STATUS;
  473. typedef struct _IPSEC_EVENT_CTX {
  474. IPAddr Addr;
  475. ULONG EventCode;
  476. ULONG UniqueEventValue;
  477. ULONG EventCount;
  478. PUCHAR pPacket;
  479. ULONG PacketSize;
  480. IPSEC_DROP_STATUS DropStatus;
  481. } IPSEC_EVENT_CTX, *PIPSEC_EVENT_CTX;
  482. typedef struct _IPSEC_NOTIFY_EXPIRE {
  483. LIST_ENTRY notify_PendingLinkage; // linkage in pending SA list - waiting for Acquire Irp
  484. ULARGE_INTEGER sa_uliSrcDstAddr;
  485. ULARGE_INTEGER sa_uliSrcDstMask;
  486. ULARGE_INTEGER sa_uliProtoSrcDstPort;
  487. IPAddr sa_TunnelAddr; // Tunnel end IP Addr
  488. IPAddr sa_InboundTunnelAddr; // Tunnel end IP Addr
  489. tSPI InboundSpi; // Inbound: in the multiple ops case, this is the SPI of the last operation.
  490. tSPI OutboundSpi;
  491. IKE_COOKIE_PAIR sa_CookiePair;
  492. DWORD Flags;
  493. } IPSEC_NOTIFY_EXPIRE, *PIPSEC_NOTIFY_EXPIRE;
  494. typedef IPSEC_ADD_UPDATE_SA IPSEC_ADD_SA, *PIPSEC_ADD_SA;
  495. typedef IPSEC_ADD_UPDATE_SA IPSEC_UPDATE_SA, *PIPSEC_UPDATE_SA;
  496. #define IPSEC_ADD_SA_NO_KEY_SIZE FIELD_OFFSET(IPSEC_ADD_SA, SAInfo.KeyMat[0])
  497. #define IPSEC_UPDATE_SA_NO_KEY_SIZE FIELD_OFFSET(IPSEC_UPDATE_SA, SAInfo.KeyMat[0])
  498. //
  499. // Contexts used to store SA plumbing contexts.
  500. //
  501. typedef struct _IPSEC_PLUMB_SA {
  502. Interface *DestIF;
  503. PSA_TABLE_ENTRY pSA;
  504. PUCHAR Buf;
  505. ULONG Len;
  506. WORK_QUEUE_ITEM PlumbQueueItem;
  507. } IPSEC_PLUMB_SA, *PIPSEC_PLUMB_SA;
  508. //
  509. // Contexts used to log events
  510. //
  511. typedef struct _IPSEC_LOG_EVENT {
  512. LONG LogSize;
  513. WORK_QUEUE_ITEM LogQueueItem;
  514. UCHAR pLog[1];
  515. } IPSEC_LOG_EVENT, *PIPSEC_LOG_EVENT;
  516. #endif _GLOBALS_H