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.

438 lines
9.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. // Copyright (c) 1996, 1997 Microsoft Corporation
  5. //
  6. //
  7. // Module Name:
  8. // Mpe.h
  9. //
  10. // Abstract:
  11. //
  12. //
  13. // Author:
  14. //
  15. // P Porzuczek
  16. //
  17. // Environment:
  18. //
  19. // Revision History:
  20. //
  21. //
  22. //////////////////////////////////////////////////////////////////////////////
  23. #ifndef _MPE_H_
  24. #define _MPE_H_
  25. #define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //
  28. //
  29. #define MPENAME "MPE"
  30. #define MPENAMEUNICODE L"MPE"
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // This defines the name of the WMI device that manages service IOCTLS
  34. //
  35. #define CodecDeviceName (L"\\\\.\\" MPENAMEUNICODE)
  36. #define CodecSymbolicName (L"\\DosDevices\\" MPENAMEUNICODE)
  37. ///////////////////////////////////////////////////////////////////////////////
  38. //
  39. //
  40. typedef struct
  41. {
  42. ULONG ulSize;
  43. UCHAR data;
  44. } MPE_BUFFER, *PMPE_BUFFER;
  45. ///////////////////////////////////////////////////////////////////////////////
  46. //
  47. //
  48. typedef enum
  49. {
  50. MPE_STREAM = 0,
  51. MPE_IPV4
  52. } MPE_STREAMS;
  53. ///////////////////////////////////////////////////////////////////////////////
  54. //
  55. // The MAX_STREAM_COUNT value must be equal to DRIVER_STREAM_COUNT
  56. // This particular value must be defined here to avoid circular references
  57. //
  58. #define MAX_STREAM_COUNT DRIVER_STREAM_COUNT
  59. /////////////////////////////////////////////////////////////////////////////
  60. //
  61. //
  62. //
  63. typedef NTSTATUS (*QUERY_INTERFACE) (PVOID pvContext);
  64. typedef ULONG (*ADD_REF) (PVOID pvContext);
  65. typedef ULONG (*RELEASE) (PVOID pvContext);
  66. /////////////////////////////////////////////////////////////////////////////
  67. //
  68. //
  69. //
  70. typedef struct _STATS_
  71. {
  72. ULONG ulTotalSectionsWritten;
  73. ULONG ulTotalPacketsRead;
  74. ULONG ulTotalInvalidSections;
  75. ULONG ulTotalUnexpectedSections;
  76. ULONG ulTotalUnavailableOutputBuffers;
  77. ULONG ulTotalOutputBuffersTooSmall;
  78. ULONG ulTotalInvalidIPSnapHeaders;
  79. ULONG ulTotalIPPacketsWritten;
  80. ULONG ulTotalIPBytesWritten;
  81. ULONG ulTotalIPFrameBytesWritten;
  82. ULONG ulTotalNetPacketsWritten;
  83. ULONG ulTotalUnknownPacketsWritten;
  84. } STATS, *PSTATS;
  85. /////////////////////////////////////////////////////////////////////////////
  86. //
  87. //
  88. //
  89. typedef struct
  90. {
  91. QUERY_INTERFACE QueryInterface;
  92. ADD_REF AddRef;
  93. RELEASE Release;
  94. } FILTER_VTABLE, *PFILTER_VTABLE;
  95. /////////////////////////////////////////////////////////////////////////////
  96. //
  97. //
  98. // definition of the full HW device extension structure This is the structure
  99. // that will be allocated in HW_INITIALIZATION by the stream class driver
  100. // Any information that is used in processing a device request (as opposed to
  101. // a STREAM based request) should be in this structure. A pointer to this
  102. // structure will be passed in all requests to the minidriver. (See
  103. // HW_STREAM_REQUEST_BLOCK in STRMINI.H)
  104. //
  105. typedef struct _MPE_FILTER_
  106. {
  107. LIST_ENTRY AdapterSRBQueue;
  108. KSPIN_LOCK AdapterSRBSpinLock;
  109. BOOLEAN bAdapterQueueInitialized;
  110. //
  111. //
  112. //
  113. BOOLEAN bInitializationComplete;
  114. //
  115. // Statistics
  116. //
  117. STATS Stats;
  118. //
  119. //
  120. //
  121. PDEVICE_OBJECT DeviceObject;
  122. //
  123. //
  124. //
  125. PDRIVER_OBJECT DriverObject;
  126. //
  127. //
  128. //
  129. PFILTER_VTABLE lpVTable;
  130. //
  131. //
  132. //
  133. ULONG ulRefCount;
  134. //
  135. //
  136. //
  137. PVOID pStream [2][1];
  138. //
  139. //
  140. //
  141. ULONG ulActualInstances [2]; // Count of instances per stream
  142. //
  143. //
  144. //
  145. KSPIN_LOCK IpV4StreamDataSpinLock; // Data queue spin lock
  146. LIST_ENTRY IpV4StreamDataQueue; // Stream data queue
  147. KSPIN_LOCK StreamControlSpinLock; // Command queue spin lock
  148. LIST_ENTRY StreamControlQueue; // Stream command queue
  149. KSPIN_LOCK StreamDataSpinLock; // Data queue spin lock
  150. LIST_ENTRY StreamDataQueue; // Stream data queue
  151. //
  152. //
  153. //
  154. KSPIN_LOCK StreamUserSpinLock;
  155. LIST_ENTRY StreamContxList;
  156. LARGE_INTEGER liLastTimeChecked;
  157. BOOLEAN bDiscontinuity;
  158. } MPE_FILTER, *PMPE_FILTER;
  159. /////////////////////////////////////////////////////////////////////////////
  160. //
  161. // this structure is our per stream extension structure. This stores
  162. // information that is relevant on a per stream basis. Whenever a new stream
  163. // is opened, the stream class driver will allocate whatever extension size
  164. // is specified in the HwInitData.PerStreamExtensionSize.
  165. //
  166. typedef struct _STREAM_
  167. {
  168. PMPE_FILTER pFilter;
  169. PHW_STREAM_OBJECT pStreamObject; // For timer use
  170. KSSTATE KSState; // Run, Stop, Pause
  171. HANDLE hMasterClock;
  172. HANDLE hClock;
  173. ULONG ulStreamInstance; // 0..NumberOfPossibleInstances-1
  174. KSDATAFORMAT OpenedFormat; // Based on the actual open request.
  175. KSDATARANGE MatchedFormat;
  176. ULONG Type; // type of this structure
  177. ULONG Size; // size of this structure
  178. PUCHAR pTransformBuffer; // temp buffer used for translating MPE to IP
  179. PUCHAR pOut; // pointer to next insertion point in output buffer
  180. BYTE bExpectedSection; // expected section number
  181. } STREAM, *PSTREAM;
  182. ///////////////////////////////////////////////////////////////////////////////
  183. //
  184. // This structure is our per SRB extension, and carries the forward and backward
  185. // links for the pending SRB queue.
  186. //
  187. typedef struct _SRB_EXTENSION
  188. {
  189. LIST_ENTRY ListEntry;
  190. PHW_STREAM_REQUEST_BLOCK pSrb;
  191. } SRB_EXTENSION, *PSRB_EXTENSION;
  192. //////////////////////////////////////////////////////////////////////////////
  193. //
  194. // the following section defines prototypes for the minidriver initialization
  195. // routines
  196. //
  197. BOOLEAN
  198. CodecInitialize (
  199. IN OUT PHW_STREAM_REQUEST_BLOCK pSrb
  200. );
  201. BOOLEAN
  202. CodecUnInitialize(
  203. PHW_STREAM_REQUEST_BLOCK pSrb
  204. );
  205. VOID
  206. CodecStreamInfo(
  207. PHW_STREAM_REQUEST_BLOCK pSrb
  208. );
  209. VOID
  210. CodecOpenStream(
  211. PHW_STREAM_REQUEST_BLOCK pSrb
  212. );
  213. VOID
  214. CodecCloseStream(
  215. PHW_STREAM_REQUEST_BLOCK pSrb
  216. );
  217. VOID STREAMAPI
  218. CodecReceivePacket(
  219. IN PHW_STREAM_REQUEST_BLOCK Srb
  220. );
  221. VOID STREAMAPI
  222. CodecCancelPacket(
  223. IN PHW_STREAM_REQUEST_BLOCK Srb
  224. );
  225. VOID STREAMAPI
  226. CodecTimeoutPacket(
  227. IN PHW_STREAM_REQUEST_BLOCK Srb
  228. );
  229. VOID STREAMAPI
  230. CodecGetProperty(
  231. IN PHW_STREAM_REQUEST_BLOCK Srb
  232. );
  233. VOID STREAMAPI
  234. CodecSetProperty(
  235. IN PHW_STREAM_REQUEST_BLOCK Srb
  236. );
  237. BOOL
  238. CodecVerifyFormat(
  239. IN KSDATAFORMAT *pKSDataFormat,
  240. UINT StreamNumber,
  241. PKSDATARANGE pMatchedFormat
  242. );
  243. BOOL
  244. CodecFormatFromRange(
  245. IN PHW_STREAM_REQUEST_BLOCK pSrb
  246. );
  247. /////////////////////////////////////////////////////////////////////////////////////
  248. //
  249. // SRB Queue Management functions
  250. //
  251. BOOL STREAMAPI
  252. QueueAddIfNotEmpty(
  253. IN PHW_STREAM_REQUEST_BLOCK,
  254. IN PKSPIN_LOCK,
  255. IN PLIST_ENTRY
  256. );
  257. BOOL STREAMAPI
  258. QueueAdd(
  259. IN PHW_STREAM_REQUEST_BLOCK,
  260. IN PKSPIN_LOCK,
  261. IN PLIST_ENTRY
  262. );
  263. BOOL STREAMAPI
  264. QueueRemove(
  265. IN OUT PHW_STREAM_REQUEST_BLOCK *,
  266. IN PKSPIN_LOCK,
  267. IN PLIST_ENTRY
  268. );
  269. BOOL STREAMAPI
  270. QueuePush (
  271. IN PHW_STREAM_REQUEST_BLOCK pSrb,
  272. IN PKSPIN_LOCK pQueueSpinLock,
  273. IN PLIST_ENTRY pQueue
  274. );
  275. BOOL STREAMAPI
  276. QueueRemoveSpecific(
  277. IN PHW_STREAM_REQUEST_BLOCK,
  278. IN PKSPIN_LOCK,
  279. IN PLIST_ENTRY
  280. );
  281. BOOL STREAMAPI
  282. QueueEmpty(
  283. IN PKSPIN_LOCK,
  284. IN PLIST_ENTRY
  285. );
  286. VOID
  287. STREAMAPI
  288. CodecReceivePacket(
  289. IN PHW_STREAM_REQUEST_BLOCK pSrb
  290. );
  291. BOOLEAN
  292. CodecInitialize (
  293. IN OUT PHW_STREAM_REQUEST_BLOCK pSrb
  294. );
  295. VOID
  296. STREAMAPI
  297. CodecCancelPacket(
  298. PHW_STREAM_REQUEST_BLOCK pSrb
  299. );
  300. VOID
  301. STREAMAPI
  302. CodecTimeoutPacket(
  303. PHW_STREAM_REQUEST_BLOCK pSrb
  304. );
  305. BOOL
  306. CompareGUIDsAndFormatSize(
  307. IN PKSDATARANGE pDataRange1,
  308. IN PKSDATARANGE pDataRange2,
  309. BOOLEAN bCheckSize
  310. );
  311. BOOL
  312. CompareStreamFormat (
  313. IN PHW_STREAM_REQUEST_BLOCK pSrb
  314. );
  315. BOOLEAN
  316. VerifyFormat(
  317. IN KSDATAFORMAT *pKSDataFormat,
  318. UINT StreamNumber,
  319. PKSDATARANGE pMatchedFormat
  320. );
  321. VOID
  322. OpenStream (
  323. PHW_STREAM_REQUEST_BLOCK pSrb
  324. );
  325. VOID
  326. CloseStream (
  327. PHW_STREAM_REQUEST_BLOCK pSrb
  328. );
  329. VOID
  330. STREAMAPI
  331. ReceiveDataPacket (
  332. IN PHW_STREAM_REQUEST_BLOCK pSrb
  333. );
  334. VOID
  335. STREAMAPI
  336. ReceiveCtrlPacket(
  337. IN PHW_STREAM_REQUEST_BLOCK pSrb
  338. );
  339. VOID
  340. MpeSetState(
  341. PHW_STREAM_REQUEST_BLOCK pSrb
  342. );
  343. VOID
  344. MpeGetState(
  345. PHW_STREAM_REQUEST_BLOCK pSrb
  346. );
  347. #endif // _MPE_H_
  348.