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.

1453 lines
36 KiB

  1. /*********************************************************************/
  2. /** Microsoft Generic Packet Scheduler **/
  3. /** Copyright(c) Microsoft Corp., 1996-1997 **/
  4. /********************************************************************/
  5. #ifndef __GPCDEF
  6. #define __GPCDEF
  7. //*** gpcdef.h - GPC internal definitions & prototypes
  8. //
  9. // This file containes all the GPC data structures & defines
  10. /*
  11. /////////////////////////////////////////////////////////////////
  12. //
  13. // defines
  14. //
  15. /////////////////////////////////////////////////////////////////
  16. */
  17. //
  18. // Max number of clients per blob (same CF)
  19. //
  20. // AbhisheV - This can not be more than sizeof(ULONG)*8.
  21. //
  22. #define MAX_CLIENTS_CTX_PER_BLOB 8
  23. //
  24. // Max pattern size,
  25. // GPC_IP_PATTERN = 24 bytes
  26. // GPC_IPX_PATTERN = 24 bytes
  27. //
  28. #define MAX_PATTERN_SIZE sizeof(GPC_IP_PATTERN)
  29. extern BOOLEAN IsItChanging;
  30. //
  31. // Pattern flags
  32. //
  33. #define PATTERN_SPECIFIC 0x00000001
  34. #define PATTERN_AUTO 0x00000002
  35. #define PATTERN_REMOVE_CB_BLOB 0x00000004
  36. //
  37. // Auto Pattern defines
  38. //
  39. // Every PATTERN_TIMEOUT seconds, the PatternTimerExpiry Routine gets called.
  40. #define PATTERN_TIMEOUT 60000 // 60 seconds
  41. // This is the amount of time that a Pattern created for optimization
  42. // lives on the Pattern List.
  43. #define AUTO_PATTERN_ENTRY_TIMEOUT 300000 // 5 minutes
  44. // This is the number of timer granularity.
  45. #define NUMBER_OF_WHEELS (AUTO_PATTERN_ENTRY_TIMEOUT/PATTERN_TIMEOUT)
  46. // New debug locks [ShreeM]
  47. // This will enable us to figure out who took the lock last
  48. // and who released it last. New structure defined below and
  49. // lock_acquire and lock_release macros are redefined later.
  50. typedef struct _GPC_LOCK {
  51. NDIS_SPIN_LOCK Lock;
  52. #if DBG
  53. PETHREAD CurrentThread;
  54. KIRQL CurrentIRQL;
  55. LONG LockAcquired; // is it current held?
  56. UCHAR LastAcquireFile[8];
  57. ULONG LastAcquireLine;
  58. UCHAR LastReleaseFile[8];
  59. ULONG LastReleaseLine;
  60. #endif
  61. } GPC_LOCK, PGPC_LOCK;
  62. //
  63. //
  64. // states for blobs, patterns and more
  65. //
  66. typedef enum {
  67. GPC_STATE_READY = 0,
  68. GPC_STATE_INIT,
  69. GPC_STATE_ADD,
  70. GPC_STATE_MODIFY,
  71. GPC_STATE_REMOVE,
  72. GPC_STATE_FORCE_REMOVE,
  73. GPC_STATE_DELETE,
  74. GPC_STATE_INVALID,
  75. GPC_STATE_NOTREADY,
  76. GPC_STATE_ERROR,
  77. GPC_STATE_PENDING
  78. } GPC_STATE;
  79. //
  80. // ObjectVerification macro
  81. //
  82. #define VERIFY_OBJECT(_obj, _val) if(_obj) \
  83. {if(*(GPC_ENUM_OBJECT_TYPE *)_obj!=_val) return STATUS_INVALID_HANDLE;}
  84. //
  85. // define event log error codes
  86. //
  87. #define GPC_ERROR_INIT_MAIN 0x00010000
  88. #define GPC_ERROR_INIT_IOCTL 0x00020000
  89. #define GPC_FLAGS_USERMODE_CLIENT 0x80000000
  90. #define IS_USERMODE_CLIENT(_pc) \
  91. TEST_BIT_ON((_pc)->Flags,GPC_FLAGS_USERMODE_CLIENT)
  92. //
  93. // for ioctl
  94. //
  95. #define SHUTDOWN_DELETE_DEVICE 0x00000100
  96. #define SHUTDOWN_DELETE_SYMLINK 0x00000200
  97. //
  98. // helper macros
  99. //
  100. #define TEST_BIT_ON(_v,_b) (((_v)&(_b))==(_b))
  101. #define TEST_BIT_OFF(_v,_b) (((_v)&(_b))==0)
  102. #if DBG
  103. #define NDIS_INIT_LOCK(_sl) {\
  104. NdisAllocateSpinLock(&(_sl)->Lock); \
  105. TRACE(LOCKS,(_sl),(_sl)->Lock.OldIrql,"LOCK");\
  106. (_sl)->LockAcquired = -1; \
  107. strncpy((_sl)->LastAcquireFile, strrchr(__FILE__,'\\')+1, 7); \
  108. (_sl)->LastAcquireLine = __LINE__; \
  109. strncpy((_sl)->LastReleaseFile, strrchr(__FILE__,'\\')+1, 7); \
  110. (_sl)->LastReleaseLine = __LINE__; \
  111. (_sl)->CurrentIRQL = KeGetCurrentIrql(); \
  112. (_sl)->CurrentThread = PsGetCurrentThread(); \
  113. }
  114. #define NDIS_LOCK(_sl) {\
  115. NdisAcquireSpinLock(&(_sl)->Lock);\
  116. TRACE(LOCKS,(_sl),(_sl)->Lock.OldIrql,"LOCK");\
  117. (_sl)->LockAcquired = TRUE; \
  118. strncpy((_sl)->LastAcquireFile, strrchr(__FILE__,'\\')+1, 7); \
  119. (_sl)->LastAcquireLine = __LINE__; \
  120. (_sl)->CurrentIRQL = KeGetCurrentIrql(); \
  121. (_sl)->CurrentThread = PsGetCurrentThread(); \
  122. }
  123. #define NDIS_UNLOCK(_sl) {\
  124. (_sl)->LockAcquired = FALSE; \
  125. strncpy((_sl)->LastReleaseFile, strrchr(__FILE__,'\\')+1, 7); \
  126. (_sl)->LastReleaseLine = __LINE__; \
  127. TRACE(LOCKS,(_sl),(_sl)->Lock.OldIrql,"UNLOCK");\
  128. NdisReleaseSpinLock(&(_sl)->Lock);\
  129. }
  130. #define NDIS_DPR_LOCK(_sl) {\
  131. NdisDprAcquireSpinLock(&(_sl)->Lock);\
  132. TRACE(LOCKS,(_sl),(_sl)->Lock.OldIrql,"DPR_LOCK");\
  133. (_sl)->LockAcquired = TRUE; \
  134. strncpy((_sl)->LastAcquireFile, strrchr(__FILE__,'\\')+1, 7); \
  135. (_sl)->LastAcquireLine = __LINE__; \
  136. (_sl)->CurrentIRQL = KeGetCurrentIrql(); \
  137. (_sl)->CurrentThread = PsGetCurrentThread(); \
  138. }
  139. #define NDIS_DPR_UNLOCK(_sl) {\
  140. (_sl)->LockAcquired = FALSE; \
  141. strncpy((_sl)->LastReleaseFile, strrchr(__FILE__,'\\')+1, 7); \
  142. (_sl)->LastReleaseLine = __LINE__; \
  143. TRACE(LOCKS,(_sl),(_sl)->Lock.OldIrql,"DPR_UNLOCK");\
  144. NdisDprReleaseSpinLock(&(_sl)->Lock);\
  145. }
  146. #else
  147. #define NDIS_INIT_LOCK(_sl) NdisAllocateSpinLock(&(_sl)->Lock)
  148. #define NDIS_LOCK(_sl) NdisAcquireSpinLock(&(_sl)->Lock)
  149. #define NDIS_UNLOCK(_sl) NdisReleaseSpinLock(&(_sl)->Lock)
  150. #define NDIS_DPR_LOCK(_sl) NdisDprAcquireSpinLock(&(_sl)->Lock)
  151. #define NDIS_DPR_UNLOCK(_sl) NdisDprReleaseSpinLock(&(_sl)->Lock)
  152. #endif
  153. #if DBG && EXTRA_DBG
  154. #define VERIFY_LIST(_l) DbgVerifyList(_l)
  155. #else
  156. #define VERIFY_LIST(_l)
  157. #endif
  158. #define GpcRemoveEntryList(_pl) {PLIST_ENTRY _q = (_pl)->Flink;VERIFY_LIST(_pl);RemoveEntryList(_pl);InitializeListHead(_pl);VERIFY_LIST(_q);}
  159. #define GpcInsertTailList(_l,_e) VERIFY_LIST(_l);InsertTailList(_l,_e);VERIFY_LIST(_e)
  160. #define GpcInsertHeadList(_l,_e) VERIFY_LIST(_l);InsertHeadList(_l,_e);VERIFY_LIST(_e)
  161. #if 0
  162. #define GpcInterlockedInsertTailList(_l,_e,_s) \
  163. NdisInterlockedInsertTailList(_l,_e,_s)
  164. #else
  165. #define GpcInterlockedInsertTailList(_l,_e,_s) \
  166. {NDIS_LOCK(_s);VERIFY_LIST(_l);InsertTailList(_l,_e);VERIFY_LIST(_l);NDIS_UNLOCK(_s);}
  167. #endif
  168. #if NEW_MRSW
  169. #define INIT_LOCK InitializeMRSWLock
  170. #define READ_LOCK EnterReader
  171. #define READ_UNLOCK ExitReader
  172. #define WRITE_LOCK EnterWriter
  173. #define WRITE_UNLOCK ExitWriter
  174. #else
  175. #define INIT_LOCK InitializeMRSWLock
  176. #define READ_LOCK AcquireReadLock
  177. #define READ_UNLOCK ReleaseReadLock
  178. #define WRITE_LOCK AcquireWriteLock
  179. #define WRITE_UNLOCK ReleaseWriteLock
  180. #endif
  181. //
  182. // Get the CF index from the client block
  183. //
  184. #define GetCFIndexFromClient(_cl) (((PCLIENT_BLOCK)(_cl))->pCfBlock->AssignedIndex)
  185. //
  186. // Get the client index from the client block
  187. //
  188. #define GetClientIndexFromClient(_cl) (((PCLIENT_BLOCK)(_cl))->AssignedIndex)
  189. //
  190. // return the blob block pointer for the pattern:
  191. // for specific patterns - its the blob entry in the CB
  192. // for generic patterns - its the pBlobBlock
  193. //
  194. #define GetBlobFromPattern(_p,_i) (_p)->arpBlobBlock[_i]
  195. //
  196. // return the index bit to the ULONG
  197. //
  198. #define ReleaseClientIndex(_v,_i) _v&=~(1<<_i) // clear the bit
  199. //
  200. // statistics macros
  201. //
  202. #define StatInc(_m) (glStat._m)++
  203. #define StatDec(_m) (glStat._m)--
  204. #define CfStatInc(_cf,_m) (glStat.CfStat[_cf]._m)++
  205. #define CfStatDec(_cf,_m) (glStat.CfStat[_cf]._m)--
  206. #define ProtocolStatInc(_p,_m) (glStat.ProtocolStat[_p]._m)++
  207. #define ProtocolStatDec(_p,_m) (glStat.ProtocolStat[_p]._m)--
  208. /*
  209. /////////////////////////////////////////////////////////////////
  210. //
  211. // typedef
  212. //
  213. /////////////////////////////////////////////////////////////////
  214. */
  215. //
  216. // completion opcodes
  217. //
  218. typedef enum {
  219. OP_ANY_CFINFO,
  220. OP_ADD_CFINFO,
  221. OP_MODIFY_CFINFO,
  222. OP_REMOVE_CFINFO
  223. } GPC_COMPLETION_OP;
  224. //
  225. // define object type enum for handle verification
  226. //
  227. typedef enum {
  228. GPC_ENUM_INVALID,
  229. GPC_ENUM_CLIENT_TYPE,
  230. GPC_ENUM_CFINFO_TYPE,
  231. GPC_ENUM_PATTERN_TYPE
  232. } GPC_ENUM_OBJECT_TYPE;
  233. typedef struct _CF_BLOCK CF_BLOCK;
  234. typedef struct _PATTERN_BLOCK PATTERN_BLOCK;
  235. //
  236. // A queued notification structure
  237. //
  238. typedef struct _QUEUED_NOTIFY {
  239. LIST_ENTRY Linkage;
  240. GPC_NOTIFY_REQUEST_RES NotifyRes;
  241. PFILE_OBJECT FileObject;
  242. } QUEUED_NOTIFY, *PQUEUED_NOTIFY;
  243. //
  244. // A queued completion structure
  245. //
  246. typedef struct _QUEUED_COMPLETION {
  247. GPC_COMPLETION_OP OpCode; // what completed
  248. GPC_HANDLE ClientHandle;
  249. GPC_HANDLE CfInfoHandle;
  250. GPC_STATUS Status;
  251. } QUEUED_COMPLETION, *PQUEUED_COMPLETION;
  252. //
  253. // A pending IRP structure
  254. //
  255. typedef struct _PENDING_IRP {
  256. LIST_ENTRY Linkage;
  257. PIRP Irp;
  258. PFILE_OBJECT FileObject;
  259. QUEUED_COMPLETION QComp;
  260. } PENDING_IRP, *PPENDING_IRP;
  261. #if NEW_MRSW
  262. //
  263. // Multiple Readers Single Write definitions
  264. // code has been taken from (tdi\tcpipmerge\ip\ipmlock.h)
  265. //
  266. typedef struct _MRSW_LOCK
  267. {
  268. KSPIN_LOCK rlReadLock;
  269. KSPIN_LOCK rlWriteLock;
  270. LONG lReaderCount;
  271. } MRSW_LOCK, *PMRSW_LOCK;
  272. #else
  273. //
  274. // Multiple Readers Single Write definitions
  275. // code has been taken from the filter driver project (routing\ip\fltrdrvr)
  276. //
  277. typedef struct _MRSW_LOCK
  278. {
  279. KSPIN_LOCK SpinLock;
  280. LONG ReaderCount;
  281. } MRSW_LOCK, *PMRSW_LOCK;
  282. #endif
  283. //
  284. // The generic pattern database struct
  285. //
  286. typedef struct _GENERIC_PATTERN_DB {
  287. MRSW_LOCK Lock;
  288. Rhizome *pRhizome; // pointer to a Rhizome
  289. } GENERIC_PATTERN_DB, *PGENERIC_PATTERN_DB;
  290. //
  291. // A client block is used to store specific client context
  292. //
  293. typedef struct _CLIENT_BLOCK {
  294. //
  295. // !!! MUST BE FIRST FIELD !!!
  296. //
  297. GPC_ENUM_OBJECT_TYPE ObjectType;
  298. LIST_ENTRY ClientLinkage; // client blocks list link
  299. LIST_ENTRY BlobList; // list of blobs of the client
  300. CF_BLOCK *pCfBlock;
  301. GPC_CLIENT_HANDLE ClientCtx;
  302. ULONG AssignedIndex;
  303. ULONG Flags;
  304. ULONG State;
  305. GPC_LOCK Lock;
  306. REF_CNT RefCount;
  307. PFILE_OBJECT pFileObject; // used for async completion
  308. GPC_HANDLE ClHandle; // handle returned to the client
  309. GPC_CLIENT_FUNC_LIST FuncList;
  310. } CLIENT_BLOCK, *PCLIENT_BLOCK;
  311. //
  312. // A blob (A.K.A CF_INFO) block holds a GPC header + client specific data
  313. //
  314. typedef struct _BLOB_BLOCK {
  315. //
  316. // !!! MUST BE FIRST FIELD !!!
  317. //
  318. GPC_ENUM_OBJECT_TYPE ObjectType;
  319. LIST_ENTRY ClientLinkage; // linked on the client
  320. LIST_ENTRY PatternList; // head of pattern linked list
  321. LIST_ENTRY CfLinkage; // blobs on the CF
  322. //PCLIENT_BLOCK pClientBlock; // pointer to installer
  323. REF_CNT RefCount;
  324. GPC_STATE State;
  325. ULONG Flags;
  326. GPC_CLIENT_HANDLE arClientCtx[MAX_CLIENTS_CTX_PER_BLOB];
  327. ULONG ClientStatusCountDown;
  328. GPC_STATUS LastStatus;
  329. GPC_LOCK Lock;
  330. CTEBlockStruc WaitBlockAddFailed;
  331. PCLIENT_BLOCK arpClientStatus[MAX_CLIENTS_CTX_PER_BLOB];
  332. ULONG ClientDataSize;
  333. PVOID pClientData;
  334. ULONG NewClientDataSize;
  335. PVOID pNewClientData;
  336. PCLIENT_BLOCK pOwnerClient;
  337. PCLIENT_BLOCK pCallingClient;
  338. PCLIENT_BLOCK pCallingClient2;
  339. HANDLE OwnerClientHandle;
  340. GPC_CLIENT_HANDLE OwnerClientCtx;
  341. GPC_HANDLE ClHandle; // handle returned to the client
  342. //
  343. // assume only one client can accept the flow
  344. //
  345. PCLIENT_BLOCK pNotifiedClient;
  346. GPC_CLIENT_HANDLE NotifiedClientCtx;
  347. #if NO_USER_PENDING
  348. CTEBlockStruc WaitBlock;
  349. #endif
  350. } BLOB_BLOCK, *PBLOB_BLOCK;
  351. //
  352. // The classification block is an array of blob pointers
  353. //
  354. typedef struct _CLASSIFICATION_BLOCK {
  355. REF_CNT RefCount;
  356. ULONG NumberOfElements;
  357. HFHandle ClassificationHandle; // how to get back to index tbl
  358. // must be last
  359. PBLOB_BLOCK arpBlobBlock[1];
  360. } CLASSIFICATION_BLOCK, *PCLASSIFICATION_BLOCK;
  361. //
  362. // A pattern block holds specific data for the pattern
  363. //
  364. typedef struct _PATTERN_BLOCK {
  365. //
  366. // !!! MUST BE FIRST FIELD !!!
  367. //
  368. GPC_ENUM_OBJECT_TYPE ObjectType;
  369. GPC_STATE State;
  370. LIST_ENTRY BlobLinkage[GPC_CF_MAX]; // linked on the blob
  371. LIST_ENTRY TimerLinkage;
  372. PBLOB_BLOCK arpBlobBlock[GPC_CF_MAX];
  373. PCLIENT_BLOCK pClientBlock;
  374. PCLIENT_BLOCK pAutoClient;
  375. PCLASSIFICATION_BLOCK pClassificationBlock;
  376. ULONG WheelIndex;
  377. REF_CNT RefCount;
  378. ULONG ClientRefCount;
  379. ULONG TimeToLive; // for internal patterns
  380. ULONG Flags;
  381. ULONG Priority; // for generic pattern
  382. PVOID DbCtx;
  383. GPC_LOCK Lock;
  384. GPC_HANDLE ClHandle; // handle returned to the client
  385. ULONG ProtocolTemplate;
  386. } PATTERN_BLOCK, *PPATTERN_BLOCK;
  387. //
  388. // A CF block struct. This would construct a linked list of Cf blocks.
  389. //
  390. typedef struct _CF_BLOCK {
  391. REF_CNT RefCount;
  392. LIST_ENTRY Linkage; // on the global list
  393. LIST_ENTRY ClientList; // for the client blocks
  394. LIST_ENTRY BlobList; // list of blobs
  395. ULONG NumberOfClients;
  396. ULONG AssignedIndex;
  397. ULONG ClientIndexes;
  398. GPC_LOCK Lock;
  399. //MRSW_LOCK ClientSync;
  400. GPC_LOCK ClientSync;
  401. ULONG MaxPriorities;
  402. PGENERIC_PATTERN_DB arpGenericDb[GPC_PROTOCOL_TEMPLATE_MAX];
  403. } CF_BLOCK, *PCF_BLOCK;
  404. typedef struct _SPECIFIC_PATTERN_DB {
  405. MRSW_LOCK Lock;
  406. PatHashTable *pDb;
  407. } SPECIFIC_PATTERN_DB, *PSPECIFIC_PATTERN_DB;
  408. typedef struct _FRAGMENT_DB {
  409. MRSW_LOCK Lock;
  410. PatHashTable *pDb;
  411. } FRAGMENT_DB, *PFRAGMENT_DB;
  412. //
  413. // A context structure to pass to the pathash scan routine
  414. //
  415. typedef struct _SCAN_STRUCT {
  416. PCLIENT_BLOCK pClientBlock;
  417. PPATTERN_BLOCK pPatternBlock;
  418. PBLOB_BLOCK pBlobBlock;
  419. ULONG Priority;
  420. BOOLEAN bRemove;
  421. } SCAN_STRUCT, *PSCAN_STRUCT;
  422. //
  423. // A protocol block holds pointers to databases for a specific
  424. // protocol template
  425. //
  426. typedef struct _PROTOCOL_BLOCK {
  427. LIST_ENTRY TimerPatternList[NUMBER_OF_WHEELS];
  428. ULONG CurrentWheelIndex;
  429. ULONG SpecificPatternCount;
  430. ULONG GenericPatternCount;
  431. ULONG AutoSpecificPatternCount;
  432. ULONG ProtocolTemplate;
  433. ULONG PatternSize;
  434. SPECIFIC_PATTERN_DB SpecificDb;
  435. PVOID pProtocolDb; // fragments
  436. GPC_LOCK PatternTimerLock[NUMBER_OF_WHEELS];
  437. NDIS_TIMER PatternTimer;
  438. } PROTOCOL_BLOCK, *PPROTOCOL_BLOCK;
  439. //
  440. // Global data block
  441. //
  442. typedef struct _GLOBAL_BLOCK {
  443. LIST_ENTRY CfList; // CF list head
  444. LIST_ENTRY gRequestList; // Maintain a request list to deal with contention...
  445. GPC_LOCK Lock;
  446. GPC_LOCK RequestListLock;
  447. HandleFactory *pCHTable;
  448. MRSW_LOCK ChLock; // lock for pCHTable
  449. PPROTOCOL_BLOCK pProtocols; // pointer to array of supported protocols
  450. } GLOBAL_BLOCK, *PGLOBAL_BLOCK;
  451. //
  452. // New request block. This will be used to store the event and linkage.
  453. // Therefore, when a thread needs to block, allocate a request_block, allocate
  454. // an event, grab the requestlist lock , put this on the list and wait.
  455. //
  456. typedef struct _REQUEST_BLOCK {
  457. LIST_ENTRY Linkage;
  458. NDIS_EVENT RequestEvent;
  459. } REQUEST_BLOCK, *PREQUEST_BLOCK;
  460. #if NEW_MRSW
  461. //
  462. // VOID
  463. // InitRwLock(
  464. // PMRSW_LOCK pLock
  465. // )
  466. //
  467. // Initializes the spin locks and the reader count
  468. //
  469. #define InitializeMRSWLock(l) { \
  470. KeInitializeSpinLock(&((l)->rlReadLock)); \
  471. KeInitializeSpinLock(&((l)->rlWriteLock)); \
  472. (l)->lReaderCount = 0; \
  473. }
  474. //
  475. // VOID
  476. // EnterReader(
  477. // PMRSW_LOCK pLock,
  478. // PKIRQL pCurrIrql
  479. // )
  480. //
  481. // Acquires the Reader Spinlock (now thread is at DPC).
  482. // InterlockedIncrements the reader count (interlocked because the reader
  483. // lock is not taken when the count is decremented in ExitReader())
  484. // If the thread is the first reader, also acquires the Writer Spinlock (at
  485. // DPC to be more efficient) to block writers
  486. // Releases the Reader Spinlock from DPC, so that it remains at DPC
  487. // for the duration of the lock being held
  488. //
  489. // If a writer is in the code, the first reader will wait on the Writer
  490. // Spinlock and all subsequent readers will wait on the Reader Spinlock
  491. // If a reader is in the code and is executing the EnterReader, then a new
  492. // reader will wait for sometime on the Reader Spinlock, and then proceed
  493. // on to the code (at DPC)
  494. //
  495. #define EnterReader(l, q) {\
  496. KeAcquireSpinLock(&((l)->rlReadLock), (q)); \
  497. TRACE(LOCKS,l,*q,"EnterReader"); \
  498. if(InterlockedIncrement(&((l)->lReaderCount)) == 1) { \
  499. TRACE(LOCKS,l,(l)->lReaderCount,"EnterReader1"); \
  500. KeAcquireSpinLockAtDpcLevel(&((l)->rlWriteLock)); \
  501. TRACE(LOCKS,l,(l)->rlWriteLock,"EnterReader2"); \
  502. } \
  503. TRACE(LOCKS,l,(l)->lReaderCount,"EnterReader3"); \
  504. KeReleaseSpinLockFromDpcLevel(&((l)->rlReadLock)); \
  505. }
  506. #define EnterReaderAtDpcLevel(l) {\
  507. KeAcquireSpinLockAtDpcLevel(&((l)->rlReadLock)); \
  508. if(InterlockedIncrement(&((l)->lReaderCount)) == 1) \
  509. KeAcquireSpinLockAtDpcLevel(&((l)->rlWriteLock)); \
  510. KeReleaseSpinLockFromDpcLevel(&((l)->rlReadLock)); \
  511. }
  512. //
  513. // VOID
  514. // ExitReader(
  515. // PMRSW_LOCK pLock,
  516. // KIRQL kiOldIrql
  517. // )
  518. //
  519. // InterlockedDec the reader count.
  520. // If this is the last reader, then release the Writer Spinlock to let
  521. // other writers in
  522. // Otherwise, just lower the irql to what was before the lock was
  523. // acquired. Either way, the irql is down to original irql
  524. //
  525. #define ExitReader(l, q) {\
  526. TRACE(LOCKS,l,q,"ExitReader");\
  527. if(InterlockedDecrement(&((l)->lReaderCount)) == 0) { \
  528. TRACE(LOCKS,(l)->rlWriteLock,q,"ExitReader1"); \
  529. KeReleaseSpinLock(&((l)->rlWriteLock), q); \
  530. } \
  531. else { \
  532. TRACE(LOCKS,l,(l)->lReaderCount,"ExitReader2"); \
  533. KeLowerIrql(q); \
  534. } \
  535. }
  536. #define ExitReaderFromDpcLevel(l) {\
  537. if(InterlockedDecrement(&((l)->lReaderCount)) == 0) \
  538. KeReleaseSpinLockFromDpcLevel(&((l)->rlWriteLock)); \
  539. }
  540. //
  541. // EnterWriter(
  542. // PMRSW_LOCK pLock,
  543. // PKIRQL pCurrIrql
  544. // )
  545. //
  546. // Acquire the reader and then the writer spin lock
  547. // If there are readers in the code, the first writer will wait
  548. // on the Writer Spinlock. All other writers will wait (with readers)
  549. // on the Reader Spinlock
  550. // If there is a writer in the code then a new writer will wait on
  551. // the Reader Spinlock
  552. #define EnterWriter(l, q) {\
  553. KeAcquireSpinLock(&((l)->rlReadLock), (q)); \
  554. TRACE(LOCKS,l,*q,"EnterWriter"); \
  555. TRACE(LOCKS,l,(l)->rlWriteLock,"EnterWrite1"); \
  556. KeAcquireSpinLockAtDpcLevel(&((l)->rlWriteLock)); \
  557. }
  558. #define EnterWriterAtDpcLevel(l) { \
  559. KeAcquireSpinLockAtDpcLevel(&((l)->rlReadLock)); \
  560. KeAcquireSpinLockAtDpcLevel(&((l)->rlWriteLock)); \
  561. }
  562. //
  563. // ExitWriter(
  564. // PMRSW_LOCK pLock,
  565. // KIRQL kiOldIrql
  566. // )
  567. //
  568. // Release both the locks
  569. //
  570. #define ExitWriter(l, q) {\
  571. TRACE(LOCKS,l,(l)->rlWriteLock,"ExitWrite1"); \
  572. KeReleaseSpinLockFromDpcLevel(&((l)->rlWriteLock)); \
  573. TRACE(LOCKS,l,q,"ExitWrite1"); \
  574. KeReleaseSpinLock(&((l)->rlReadLock), q); \
  575. }
  576. #define ExitWriterFromDpcLevel(l) {\
  577. KeReleaseSpinLockFromDpcLevel(&((l)->rlWriteLock)); \
  578. KeReleaseSpinLockFromDpcLevel(&((l)->rlReadLock)); \
  579. }
  580. #else
  581. #define InitializeMRSWLock(_pLock) { \
  582. (_pLock)->ReaderCount = 0; \
  583. KeInitializeSpinLock(&((_pLock)->SpinLock)); \
  584. }
  585. #define AcquireReadLock(_pLock,_pOldIrql) { \
  586. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "RL.1"); \
  587. KeAcquireSpinLock(&((_pLock)->SpinLock),_pOldIrql); \
  588. InterlockedIncrement(&((_pLock)->ReaderCount)); \
  589. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "RL.2"); \
  590. KeReleaseSpinLockFromDpcLevel(&((_pLock)->SpinLock)); \
  591. TRACE(LOCKS, _pLock, *(_pOldIrql), "RL.3"); \
  592. }
  593. #define ReleaseReadLock(_pLock,_OldIrql) { \
  594. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "RU.1"); \
  595. InterlockedDecrement(&((_pLock)->ReaderCount)); \
  596. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "RU.2"); \
  597. KeLowerIrql(_OldIrql); \
  598. TRACE(LOCKS, _pLock, _OldIrql, "RU.3"); \
  599. }
  600. #define AcquireWriteLock(_pLock,_pOldIrql) { \
  601. TRACE(LOCKS, _pLock, _pOldIrql, "WL.1"); \
  602. KeAcquireSpinLock(&((_pLock)->SpinLock),_pOldIrql); \
  603. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "WL.2"); \
  604. while(InterlockedDecrement(&((_pLock)->ReaderCount))>=0)\
  605. { \
  606. InterlockedIncrement (&((_pLock)->ReaderCount)); \
  607. } \
  608. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "WL.3"); \
  609. }
  610. #define ReleaseWriteLock(_pLock,_OldIrql) { \
  611. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "WU.1"); \
  612. InterlockedExchange(&(_pLock)->ReaderCount,0); \
  613. TRACE(LOCKS, _pLock, (_pLock)->ReaderCount, "WU.2"); \
  614. KeReleaseSpinLock(&((_pLock)->SpinLock),_OldIrql); \
  615. TRACE(LOCKS, _pLock, _OldIrql, "WU.3"); \
  616. }
  617. #endif
  618. #if 1
  619. #define RSC_READ_LOCK(_l,_i) NDIS_LOCK(_l)
  620. #define RSC_READ_UNLOCK(_l,_i) NDIS_UNLOCK(_l)
  621. #define RSC_WRITE_LOCK(_l,_i) NDIS_LOCK(_l)
  622. #define RSC_WRITE_UNLOCK(_l,_i) NDIS_UNLOCK(_l)
  623. #else
  624. #define RSC_READ_LOCK WRITE_LOCK
  625. #define RSC_READ_UNLOCK WRITE_UNLOCK
  626. #define RSC_WRITE_LOCK WRITE_LOCK
  627. #define RSC_WRITE_UNLOCK WRITE_UNLOCK
  628. #endif
  629. /*
  630. /////////////////////////////////////////////////////////////////
  631. //
  632. // IP definitions
  633. //
  634. /////////////////////////////////////////////////////////////////
  635. */
  636. #define DEFAULT_VERLEN 0x45 // Default version and length.
  637. #define IP_VERSION 0x40
  638. #define IP_VER_FLAG 0xF0
  639. #define IP_RSVD_FLAG 0x0080 // Reserved.
  640. #define IP_DF_FLAG 0x0040 // 'Don't fragment' flag
  641. #define IP_MF_FLAG 0x0020 // 'More fragments flag'
  642. #define IP_OFFSET_MASK ~0x00E0 // Mask for extracting offset field.
  643. #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
  644. #define net_short(_x) _byteswap_ushort((USHORT)(_x))
  645. #define net_long(_x) _byteswap_ulong(_x)
  646. #else
  647. #define net_short(x) ((((x)&0xff) << 8) | (((x)&0xff00) >> 8))
  648. #define net_long(x) (((((ulong)(x))&0xffL)<<24) | \
  649. ((((ulong)(x))&0xff00L)<<8) | \
  650. ((((ulong)(x))&0xff0000L)>>8) | \
  651. ((((ulong)(x))&0xff000000L)>>24))
  652. #endif
  653. /*
  654. * Protocols (from winsock.h)
  655. */
  656. #define IPPROTO_IP 0 /* dummy for IP */
  657. #define IPPROTO_ICMP 1 /* control message protocol */
  658. #define IPPROTO_IGMP 2 /* group management protocol */
  659. #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
  660. #define IPPROTO_TCP 6 /* tcp */
  661. #define IPPROTO_PUP 12 /* pup */
  662. #define IPPROTO_UDP 17 /* user datagram protocol */
  663. #define IPPROTO_IDP 22 /* xns idp */
  664. #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
  665. #define IPPROTO_IPSEC 51 /* ???????? */
  666. #define IPPROTO_RAW 255 /* raw IP packet */
  667. #define IPPROTO_MAX 256
  668. //
  669. // UDP header definition
  670. //
  671. typedef struct _UDP_HEADER {
  672. ushort uh_src;
  673. ushort uh_dest;
  674. ushort uh_length;
  675. ushort uh_xsum;
  676. } UDP_HEADER, *PUDP_HEADER;
  677. //
  678. //* IP Header format.
  679. //
  680. typedef struct _IP_HEADER {
  681. uchar iph_verlen; // Version and length.
  682. uchar iph_tos; // Type of service.
  683. ushort iph_length; // Total length of datagram.
  684. ushort iph_id; // Identification.
  685. ushort iph_offset; // Flags and fragment offset.
  686. uchar iph_ttl; // Time to live.
  687. uchar iph_protocol; // Protocol.
  688. ushort iph_xsum; // Header checksum.
  689. ULONG iph_src; // Source address.
  690. ULONG iph_dest; // Destination address.
  691. } IP_HEADER, *PIP_HEADER;
  692. //
  693. // Definition of the IPX header.
  694. //
  695. typedef struct _IPX_HEADER {
  696. USHORT CheckSum;
  697. UCHAR PacketLength[2];
  698. UCHAR TransportControl;
  699. UCHAR PacketType;
  700. UCHAR DestinationNetwork[4];
  701. UCHAR DestinationNode[6];
  702. USHORT DestinationSocket;
  703. UCHAR SourceNetwork[4];
  704. UCHAR SourceNode[6];
  705. USHORT SourceSocket;
  706. } IPX_HEADER, *PIPX_HEADER;
  707. /*
  708. /////////////////////////////////////////////////////////////////
  709. //
  710. // extern
  711. //
  712. /////////////////////////////////////////////////////////////////
  713. */
  714. extern GLOBAL_BLOCK glData;
  715. extern GPC_STAT glStat;
  716. #ifdef STANDALONE_DRIVER
  717. extern GPC_EXPORTED_CALLS glGpcExportedCalls;
  718. #endif
  719. // tags
  720. extern ULONG ClassificationFamilyTag;
  721. extern ULONG ClientTag;
  722. extern ULONG PatternTag;
  723. extern ULONG CfInfoTag;
  724. extern ULONG QueuedNotificationTag;
  725. extern ULONG PendingIrpTag;
  726. extern ULONG HandleFactoryTag;
  727. extern ULONG PathHashTag;
  728. extern ULONG RhizomeTag;
  729. extern ULONG GenPatternDbTag;
  730. extern ULONG FragmentDbTag;
  731. extern ULONG CfInfoDataTag;
  732. extern ULONG ClassificationBlockTag;
  733. extern ULONG ProtocolTag;
  734. extern ULONG DebugTag;
  735. // Lookaside lists
  736. extern NPAGED_LOOKASIDE_LIST ClassificationFamilyLL;
  737. extern NPAGED_LOOKASIDE_LIST ClientLL;
  738. extern NPAGED_LOOKASIDE_LIST PatternLL;
  739. extern NPAGED_LOOKASIDE_LIST CfInfoLL;
  740. extern NPAGED_LOOKASIDE_LIST QueuedNotificationLL;
  741. extern NPAGED_LOOKASIDE_LIST PendingIrpLL;
  742. /*
  743. /////////////////////////////////////////////////////////////////
  744. //
  745. // prototypes
  746. //
  747. /////////////////////////////////////////////////////////////////
  748. */
  749. NTSTATUS
  750. DriverEntry(
  751. IN PDRIVER_OBJECT DriverObject,
  752. IN PUNICODE_STRING RegistryPath
  753. );
  754. GPC_STATUS
  755. InitSpecificPatternDb(
  756. IN PSPECIFIC_PATTERN_DB pDb,
  757. IN ULONG PatternSize
  758. );
  759. GPC_STATUS
  760. UninitSpecificPatternDb(
  761. IN PSPECIFIC_PATTERN_DB pDb
  762. );
  763. GPC_STATUS
  764. InitClassificationHandleTbl(
  765. IN HandleFactory **ppCHTable
  766. );
  767. VOID
  768. UninitClassificationHandleTbl(
  769. IN HandleFactory *pCHTable
  770. );
  771. GPC_STATUS
  772. InitializeGenericDb(
  773. IN PGENERIC_PATTERN_DB *ppGenericDb,
  774. IN ULONG NumEntries,
  775. IN ULONG PatternSize
  776. );
  777. VOID
  778. UninitializeGenericDb(
  779. IN PGENERIC_PATTERN_DB *ppGenericDb,
  780. IN ULONG NumEntries
  781. );
  782. PCLIENT_BLOCK
  783. CreateNewClientBlock(VOID);
  784. VOID
  785. ReleaseCfBlock(
  786. IN PCF_BLOCK pCf
  787. );
  788. PCF_BLOCK
  789. CreateNewCfBlock(
  790. IN ULONG CfId,
  791. IN ULONG MaxPriorities
  792. );
  793. VOID
  794. ReleaseClientBlock(
  795. IN PCLIENT_BLOCK pClientBlock
  796. );
  797. PPATTERN_BLOCK
  798. CreateNewPatternBlock(
  799. IN ULONG Flags
  800. );
  801. VOID
  802. ReleasePatternBlock(
  803. IN PPATTERN_BLOCK pPatternBlock
  804. );
  805. PCLASSIFICATION_BLOCK
  806. CreateNewClassificationBlock(
  807. IN ULONG NumEntries
  808. );
  809. ULONG
  810. AssignNewClientIndex(
  811. IN PCF_BLOCK pCfBlock
  812. );
  813. GPC_STATUS
  814. AddGenericPattern(
  815. IN PCLIENT_BLOCK pClient,
  816. IN PUCHAR pPatternBits,
  817. IN PUCHAR pMaskBits,
  818. IN ULONG Priority,
  819. IN PBLOB_BLOCK pBlob,
  820. IN PPROTOCOL_BLOCK pProtocol,
  821. IN OUT PPATTERN_BLOCK *ppPattern
  822. );
  823. GPC_STATUS
  824. AddSpecificPattern(
  825. IN PCLIENT_BLOCK pClient,
  826. IN PUCHAR pPatternBits,
  827. IN PUCHAR pMaskBits,
  828. IN PBLOB_BLOCK pBlob,
  829. IN PPROTOCOL_BLOCK pProtocol,
  830. IN OUT PPATTERN_BLOCK *ppPattern,
  831. OUT PCLASSIFICATION_HANDLE pCH
  832. );
  833. ULONG
  834. GpcCalcHash(
  835. IN ULONG ProtocolTempId,
  836. IN PUCHAR pPattern
  837. );
  838. VOID
  839. DereferencePattern(
  840. IN PPATTERN_BLOCK pPattern
  841. );
  842. VOID
  843. DereferenceBlob(
  844. IN PBLOB_BLOCK pBlob
  845. );
  846. PBLOB_BLOCK
  847. CreateNewBlobBlock(
  848. IN ULONG ClientDataSize,
  849. IN PVOID pClientData
  850. );
  851. VOID
  852. ReleaseBlobBlock(
  853. IN PBLOB_BLOCK pBlobBlock
  854. );
  855. GPC_STATUS
  856. HandleFragment(
  857. IN PCLIENT_BLOCK pClientBlock,
  858. IN PPROTOCOL_BLOCK pProtocol,
  859. IN BOOLEAN bFirstFrag,
  860. IN BOOLEAN bLastFrag,
  861. IN ULONG PacketId,
  862. IN OUT PPATTERN_BLOCK *ppPatternBlock,
  863. OUT PBLOB_BLOCK *ppBlob
  864. );
  865. NTSTATUS
  866. InternalSearchPattern(
  867. IN PCLIENT_BLOCK pClientBlock,
  868. IN PPROTOCOL_BLOCK pProtocol,
  869. IN PVOID pPatternKey,
  870. OUT PPATTERN_BLOCK *ppPatternBlock,
  871. OUT PCLASSIFICATION_HANDLE pClassificationHandle,
  872. IN BOOLEAN bNoCache
  873. );
  874. GPC_STATUS
  875. InitFragmentDb(
  876. IN PFRAGMENT_DB *ppFragDb
  877. );
  878. GPC_STATUS
  879. UninitFragmentDb(
  880. IN PFRAGMENT_DB pFragDb
  881. );
  882. VOID
  883. DereferenceClient(
  884. IN PCLIENT_BLOCK pClient
  885. );
  886. GPC_STATUS
  887. ClientAddCfInfo(
  888. IN PCLIENT_BLOCK pClient,
  889. IN PBLOB_BLOCK pBlob,
  890. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext
  891. );
  892. VOID
  893. ClientAddCfInfoComplete(
  894. IN PCLIENT_BLOCK pClient,
  895. IN PBLOB_BLOCK pBlob,
  896. IN GPC_STATUS Status
  897. );
  898. GPC_STATUS
  899. ClientModifyCfInfo(
  900. IN PCLIENT_BLOCK pClient,
  901. IN PBLOB_BLOCK pBlob,
  902. IN ULONG CfInfoSize,
  903. IN PVOID pClientData
  904. );
  905. VOID
  906. ClientModifyCfInfoComplete(
  907. IN PCLIENT_BLOCK pClient,
  908. IN PBLOB_BLOCK pBlob,
  909. IN GPC_STATUS Status
  910. );
  911. GPC_STATUS
  912. ClientRemoveCfInfo(
  913. IN PCLIENT_BLOCK pClient,
  914. IN PBLOB_BLOCK pBlob,
  915. IN GPC_CLIENT_HANDLE ClientCfInfoContext
  916. );
  917. VOID
  918. ClientRemoveCfInfoComplete(
  919. IN PCLIENT_BLOCK pClient,
  920. IN PBLOB_BLOCK pBlob,
  921. IN GPC_STATUS Status
  922. );
  923. GPC_STATUS
  924. RemoveSpecificPattern(
  925. IN PCLIENT_BLOCK pClient,
  926. IN PPROTOCOL_BLOCK pProtocol,
  927. IN PPATTERN_BLOCK pPattern,
  928. IN BOOLEAN ForceRemoval
  929. );
  930. VOID
  931. ClientRefsExistForSpecificPattern(
  932. IN PCLIENT_BLOCK pClient,
  933. IN PPROTOCOL_BLOCK pProtocol,
  934. IN PPATTERN_BLOCK pPattern
  935. );
  936. VOID
  937. ReadySpecificPatternForDeletion(
  938. IN PCLIENT_BLOCK pClient,
  939. IN PPROTOCOL_BLOCK pProtocol,
  940. IN PPATTERN_BLOCK pPattern
  941. );
  942. GPC_STATUS
  943. RemoveGenericPattern(
  944. IN PCLIENT_BLOCK pClient,
  945. IN PPROTOCOL_BLOCK pProtocol,
  946. IN PPATTERN_BLOCK pPattern
  947. );
  948. VOID
  949. ReleaseClassificationBlock(
  950. IN PCLASSIFICATION_BLOCK pClassificationBlock
  951. );
  952. VOID
  953. ClearPatternLinks(
  954. IN PPATTERN_BLOCK pPattern,
  955. IN PPROTOCOL_BLOCK pProtocol,
  956. IN ULONG CfIndex
  957. );
  958. VOID
  959. ModifyCompleteClients(
  960. IN PCLIENT_BLOCK pClient,
  961. IN PBLOB_BLOCK pBlob
  962. );
  963. //CLASSIFICATION_HANDLE
  964. //GetClassificationHandle(
  965. // IN PCLIENT_BLOCK pClient,
  966. // IN PPATTERN_BLOCK pPattern
  967. // );
  968. VOID
  969. FreeClassificationHandle(
  970. IN PCLIENT_BLOCK pClient,
  971. IN CLASSIFICATION_HANDLE CH
  972. );
  973. GPC_STATUS
  974. CleanupBlobs(
  975. IN PCLIENT_BLOCK pClient
  976. );
  977. #ifdef STANDALONE_DRIVER
  978. /*
  979. /////////////////////////////////////////////////////////////////
  980. //
  981. // GPC inetrface APIs
  982. //
  983. /////////////////////////////////////////////////////////////////
  984. */
  985. GPC_STATUS
  986. GpcGetCfInfoClientContext(
  987. IN GPC_HANDLE ClientHandle,
  988. IN CLASSIFICATION_HANDLE ClassificationHandle,
  989. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext
  990. );
  991. GPC_CLIENT_HANDLE
  992. GpcGetCfInfoClientContextWithRef(
  993. IN GPC_HANDLE ClientHandle,
  994. IN CLASSIFICATION_HANDLE ClassificationHandle,
  995. IN ULONG Offset
  996. );
  997. GPC_STATUS
  998. GpcGetUlongFromCfInfo(
  999. IN GPC_HANDLE ClientHandle,
  1000. IN CLASSIFICATION_HANDLE ClassificationHandle,
  1001. IN ULONG Offset,
  1002. IN PULONG pValue
  1003. );
  1004. GPC_STATUS
  1005. GpcRegisterClient(
  1006. IN ULONG CfId,
  1007. IN ULONG Flags,
  1008. IN ULONG MaxPriorities,
  1009. IN PGPC_CLIENT_FUNC_LIST pClientFuncList,
  1010. IN GPC_CLIENT_HANDLE ClientContext,
  1011. OUT PGPC_HANDLE pClientHandle
  1012. );
  1013. GPC_STATUS
  1014. GpcDeregisterClient(
  1015. IN GPC_HANDLE ClientHandle
  1016. );
  1017. GPC_STATUS
  1018. GpcAddCfInfo(
  1019. IN GPC_HANDLE ClientHandle,
  1020. IN ULONG CfInfoSize,
  1021. IN PVOID pClientCfInfo,
  1022. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  1023. OUT PGPC_HANDLE pGpcCfInfoHandle
  1024. );
  1025. GPC_STATUS
  1026. GpcAddPattern(
  1027. IN GPC_HANDLE ClientHandle,
  1028. IN ULONG ProtocolTemplate,
  1029. IN PVOID Pattern,
  1030. IN PVOID Mask,
  1031. IN ULONG Priority,
  1032. IN GPC_HANDLE GpcCfInfoHandle,
  1033. OUT PGPC_HANDLE pGpcPatternHandle,
  1034. OUT PCLASSIFICATION_HANDLE pClassificationHandle
  1035. );
  1036. VOID
  1037. GpcAddCfInfoNotifyComplete(
  1038. IN GPC_HANDLE ClientHandle,
  1039. IN GPC_HANDLE GpcCfInfoHandle,
  1040. IN GPC_STATUS Status,
  1041. IN GPC_CLIENT_HANDLE ClientCfInfoContext
  1042. );
  1043. GPC_STATUS
  1044. GpcModifyCfInfo (
  1045. IN GPC_HANDLE ClientHandle,
  1046. IN GPC_HANDLE GpcCfInfoHandle,
  1047. IN ULONG CfInfoSize,
  1048. IN PVOID pClientCfInfo
  1049. );
  1050. VOID
  1051. GpcModifyCfInfoNotifyComplete(
  1052. IN GPC_HANDLE ClientHandle,
  1053. IN GPC_HANDLE GpcCfInfoHandle,
  1054. IN GPC_STATUS Status
  1055. );
  1056. GPC_STATUS
  1057. GpcRemoveCfInfo (
  1058. IN GPC_HANDLE ClientHandle,
  1059. IN GPC_HANDLE GpcCfInfoHandle
  1060. );
  1061. VOID
  1062. GpcRemoveCfInfoNotifyComplete(
  1063. IN GPC_HANDLE ClientHandle,
  1064. IN GPC_HANDLE GpcCfInfoHandle,
  1065. IN GPC_STATUS Status
  1066. );
  1067. GPC_STATUS
  1068. GpcRemovePattern (
  1069. IN GPC_HANDLE ClientHandle,
  1070. IN GPC_HANDLE GpcPatternHandle
  1071. );
  1072. GPC_STATUS
  1073. GpcClassifyPattern (
  1074. IN GPC_HANDLE ClientHandle,
  1075. IN ULONG ProtocolTemplate,
  1076. IN PVOID pPattern,
  1077. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext,
  1078. IN OUT PCLASSIFICATION_HANDLE pClassificationHandle,
  1079. IN ULONG Offset,
  1080. IN PULONG pValue,
  1081. IN BOOLEAN bNoCache
  1082. );
  1083. GPC_STATUS
  1084. GpcClassifyPacket (
  1085. IN GPC_HANDLE ClientHandle,
  1086. IN ULONG ProtocolTemplate,
  1087. IN PVOID pNdisPacket,
  1088. IN ULONG TransportHeaderOffset,
  1089. IN PTC_INTERFACE_ID InterfaceId,
  1090. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext,
  1091. OUT PCLASSIFICATION_HANDLE pClassificationHandle
  1092. );
  1093. GPC_STATUS
  1094. GpcEnumCfInfo (
  1095. IN GPC_HANDLE ClientHandle,
  1096. IN OUT PHANDLE pCfInfoHandle,
  1097. OUT PHANDLE pCfInfoMapHandle,
  1098. IN OUT PULONG pCfInfoCount,
  1099. IN OUT PULONG pBufferSize,
  1100. OUT PGPC_ENUM_CFINFO_BUFFER Buffer
  1101. );
  1102. #endif // STANDALONE_DRIVER
  1103. GPC_STATUS
  1104. GetClientCtxAndUlongFromCfInfo(
  1105. IN GPC_HANDLE ClientHandle,
  1106. IN OUT PCLASSIFICATION_HANDLE pClassificationHandle,
  1107. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext,
  1108. IN ULONG Offset,
  1109. IN PULONG pValue
  1110. );
  1111. GPC_STATUS
  1112. privateGpcRemoveCfInfo(
  1113. IN GPC_HANDLE ClientHandle,
  1114. IN GPC_HANDLE GpcCfInfoHandle,
  1115. IN ULONG Flags
  1116. );
  1117. GPC_STATUS
  1118. privateGpcRemovePattern(
  1119. IN GPC_HANDLE ClientHandle,
  1120. IN GPC_HANDLE GpcPatternHandle,
  1121. IN BOOLEAN ForceRemoval
  1122. );
  1123. VOID
  1124. UMClientRemoveCfInfoNotify(
  1125. IN PCLIENT_BLOCK pClient,
  1126. IN PBLOB_BLOCK pBlob
  1127. );
  1128. VOID
  1129. UMCfInfoComplete(
  1130. IN GPC_COMPLETION_OP OpCode,
  1131. IN PCLIENT_BLOCK pClient,
  1132. IN PBLOB_BLOCK pBlob,
  1133. IN GPC_STATUS Status
  1134. );
  1135. VOID
  1136. CloseAllObjects(
  1137. IN PFILE_OBJECT FileObject,
  1138. IN PIRP Irp
  1139. );
  1140. NTSTATUS
  1141. IoctlInitialize(
  1142. IN PDRIVER_OBJECT DriverObject,
  1143. IN PULONG InitShutdownMask
  1144. );
  1145. NTSTATUS
  1146. CheckQueuedNotification(
  1147. IN PIRP Irp,
  1148. IN OUT ULONG *outputBufferLength
  1149. );
  1150. NTSTATUS
  1151. CheckQueuedCompletion(
  1152. IN PQUEUED_COMPLETION pQItem,
  1153. IN PIRP Irp
  1154. );
  1155. VOID
  1156. PatternTimerExpired(
  1157. IN PVOID SystemSpecific1,
  1158. IN PVOID FunctionContext,
  1159. IN PVOID SystemSpecific2,
  1160. IN PVOID SystemSpecific3
  1161. );
  1162. GPC_STATUS
  1163. AddSpecificPatternWithTimer(
  1164. IN PCLIENT_BLOCK pClient,
  1165. IN ULONG ProtocolTemplate,
  1166. IN PVOID PatternKey,
  1167. OUT PPATTERN_BLOCK *ppPattern,
  1168. OUT PCLASSIFICATION_HANDLE pClassificationHandle
  1169. );
  1170. NTSTATUS
  1171. InitPatternTimer(
  1172. IN ULONG ProtocolTemplate
  1173. );
  1174. #endif // __GPCDEF