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.

478 lines
10 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. // Copyright (c) 1996, 1997 Microsoft Corporation
  5. //
  6. //
  7. // Module Name:
  8. // slip.h
  9. //
  10. // Abstract:
  11. //
  12. //
  13. // Author:
  14. //
  15. // P Porzuczek
  16. //
  17. // Environment:
  18. //
  19. // Revision History:
  20. //
  21. //
  22. //////////////////////////////////////////////////////////////////////////////
  23. #ifndef _SLIP_H_
  24. #define _SLIP_H_
  25. #define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //
  28. //
  29. #define SLIPNAME "SLIP"
  30. #define SLIPNAMEUNICODE L"SLIP"
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // This defines the name of the WMI device that manages service IOCTLS
  34. //
  35. #define CodecDeviceName (L"\\\\.\\" SLIPNAMEUNICODE)
  36. #define CodecSymbolicName (L"\\DosDevices\\" SLIPNAMEUNICODE)
  37. ///////////////////////////////////////////////////////////////////////////////
  38. //
  39. //
  40. typedef enum
  41. {
  42. SLIP_STREAM = 0,
  43. SLIP_IPV4,
  44. SLIP_NET_CONTROL
  45. } SLIP_STREAMS;
  46. ///////////////////////////////////////////////////////////////////////////////
  47. //
  48. // The MAX_STREAM_COUNT value must be equal to DRIVER_STREAM_COUNT
  49. // This particular value must be defined here to avoid circular references
  50. //
  51. #define MAX_STREAM_COUNT DRIVER_STREAM_COUNT
  52. ///////////////////////////////////////////////////////////////////////////////
  53. //
  54. // We manage multiple instances of each pin up to this limit
  55. //
  56. #define MAX_PIN_INSTANCES 8
  57. #define BIT(n) (1L<<(n))
  58. #define BITSIZE(v) (sizeof(v)*8)
  59. #define SETBIT(array,n) (array[n/BITSIZE(*array)] |= BIT(n%BITSIZE(*array)))
  60. #define CLEARBIT(array,n) (array[n/BITSIZE(*array)] &= ~BIT(n%BITSIZE(*array)))
  61. #define MAX_FRAMES 64
  62. #define FRAME_LOW_WATER 5
  63. /////////////////////////////////////////////////////////////////////////////
  64. //
  65. //
  66. //
  67. typedef NTSTATUS (*QUERY_INTERFACE) (PVOID pvContext);
  68. typedef ULONG (*ADD_REF) (PVOID pvContext);
  69. typedef ULONG (*RELEASE) (PVOID pvContext);
  70. /////////////////////////////////////////////////////////////////////////////
  71. //
  72. //
  73. //
  74. typedef struct _STATS_
  75. {
  76. ULONG ulTotalDataSRBWrites;
  77. ULONG ulTotalBadPinSRBWrites;
  78. ULONG ulTotalDataSRBReads;
  79. ULONG ulTotalBadPinSRBReads;
  80. ULONG ulTotalSlipBuffersReceived;
  81. ULONG ulTotalSlipBuffersDropped;
  82. ULONG ulTotalSlipZeroLengthBuffers;
  83. ULONG ulTotalSlipBytesReceived;
  84. ULONG ulTotalSlipBytesDropped;
  85. ULONG ulTotalSlipFramesReceived;
  86. ULONG ulTotalSlipOldProtoFramesStarted;
  87. ULONG ulTotalSlipNewProtoFramesStarted;
  88. ULONG ulTotalSlipFramesIncomplete;
  89. ULONG ulTotalSlipFramesBadCRC;
  90. ULONG ulTotalSlipFramesTooBig;
  91. ULONG ulTotalSlipFramesTooSmall;
  92. ULONG ulTotalIPPacketsFound;
  93. ULONG ulTotalIPBytesFound;
  94. ULONG ulTotalIPPacketsSent;
  95. ULONG ulTotalIPBytesSent;
  96. ULONG ulTotalIPPacketsTooBig;
  97. ULONG ulTotalIPPacketsTooSmall;
  98. ULONG ulTotalIPPacketsDropped;
  99. ULONG ulTotalIPBytesDropped;
  100. ULONG ulTotalNabStreamsCreated;
  101. ULONG ulTotalNabStreamsTimedOut;
  102. } STATS, *PSTATS;
  103. /////////////////////////////////////////////////////////////////////////////
  104. //
  105. //
  106. //
  107. typedef struct
  108. {
  109. QUERY_INTERFACE QueryInterface;
  110. ADD_REF AddRef;
  111. RELEASE Release;
  112. } FILTER_VTABLE, *PFILTER_VTABLE;
  113. /////////////////////////////////////////////////////////////////////////////
  114. //
  115. //
  116. // definition of the full HW device extension structure This is the structure
  117. // that will be allocated in HW_INITIALIZATION by the stream class driver
  118. // Any information that is used in processing a device request (as opposed to
  119. // a STREAM based request) should be in this structure. A pointer to this
  120. // structure will be passed in all requests to the minidriver. (See
  121. // HW_STREAM_REQUEST_BLOCK in STRMINI.H)
  122. //
  123. typedef struct _SLIP_FILTER_
  124. {
  125. LIST_ENTRY AdapterSRBQueue;
  126. KSPIN_LOCK AdapterSRBSpinLock;
  127. BOOLEAN bAdapterQueueInitialized;
  128. //
  129. //
  130. //
  131. BOOLEAN bInitializationComplete;
  132. //
  133. // Statistics
  134. //
  135. STATS Stats;
  136. //
  137. //
  138. //
  139. PDEVICE_OBJECT DeviceObject;
  140. //
  141. //
  142. //
  143. PDRIVER_OBJECT DriverObject;
  144. //
  145. //
  146. //
  147. PFILTER_VTABLE lpVTable;
  148. //
  149. //
  150. //
  151. ULONG ulRefCount;
  152. //
  153. //
  154. //
  155. PVOID pStream [2][1];
  156. //
  157. //
  158. //
  159. ULONG ulActualInstances [2]; // Count of instances per stream
  160. //
  161. //
  162. //
  163. KSPIN_LOCK IpV4StreamDataSpinLock; // Data queue spin lock
  164. LIST_ENTRY IpV4StreamDataQueue; // Stream data queue
  165. KSPIN_LOCK StreamControlSpinLock; // Command queue spin lock
  166. LIST_ENTRY StreamControlQueue; // Stream command queue
  167. KSPIN_LOCK StreamDataSpinLock; // Data queue spin lock
  168. LIST_ENTRY StreamDataQueue; // Stream data queue
  169. //
  170. //
  171. //
  172. KSPIN_LOCK StreamUserSpinLock;
  173. LIST_ENTRY StreamContxList;
  174. LARGE_INTEGER liLastTimeChecked;
  175. LARGE_INTEGER liLastTimeStatsDumped;
  176. BOOLEAN bDiscontinuity;
  177. } SLIP_FILTER, *PSLIP_FILTER;
  178. /////////////////////////////////////////////////////////////////////////////
  179. //
  180. // this structure is our per stream extension structure. This stores
  181. // information that is relevant on a per stream basis. Whenever a new stream
  182. // is opened, the stream class driver will allocate whatever extension size
  183. // is specified in the HwInitData.PerStreamExtensionSize.
  184. //
  185. typedef struct _STREAM_
  186. {
  187. PSLIP_FILTER pFilter;
  188. PHW_STREAM_OBJECT pStreamObject; // For timer use
  189. KSSTATE KSState; // Run, Stop, Pause
  190. HANDLE hMasterClock;
  191. HANDLE hClock;
  192. ULONG ulStreamInstance; // 0..NumberOfPossibleInstances-1
  193. KSDATAFORMAT OpenedFormat; // Based on the actual open request.
  194. KSDATARANGE MatchedFormat;
  195. ULONG Type; // type of this structure
  196. ULONG Size; // size of this structure
  197. } STREAM, *PSTREAM;
  198. ///////////////////////////////////////////////////////////////////////////////
  199. //
  200. // This structure is our per SRB extension, and carries the forward and backward
  201. // links for the pending SRB queue.
  202. //
  203. typedef struct _SRB_EXTENSION
  204. {
  205. LIST_ENTRY ListEntry;
  206. PHW_STREAM_REQUEST_BLOCK pSrb;
  207. } SRB_EXTENSION, *PSRB_EXTENSION;
  208. //////////////////////////////////////////////////////////////////////////////
  209. //
  210. // the following section defines prototypes for the minidriver initialization
  211. // routines
  212. //
  213. BOOLEAN
  214. CodecInitialize (
  215. IN OUT PHW_STREAM_REQUEST_BLOCK pSrb
  216. );
  217. BOOLEAN
  218. CodecUnInitialize(
  219. PHW_STREAM_REQUEST_BLOCK pSrb
  220. );
  221. BOOLEAN
  222. CodecQueryUnload (
  223. PHW_STREAM_REQUEST_BLOCK pSrb
  224. ); // Not implemented currently
  225. BOOLEAN
  226. HwInterrupt (
  227. IN PSLIP_FILTER pFilter
  228. );
  229. VOID
  230. CodecStreamInfo(
  231. PHW_STREAM_REQUEST_BLOCK pSrb
  232. );
  233. VOID
  234. CodecOpenStream(
  235. PHW_STREAM_REQUEST_BLOCK pSrb
  236. );
  237. VOID
  238. CodecCloseStream(
  239. PHW_STREAM_REQUEST_BLOCK pSrb
  240. );
  241. VOID STREAMAPI
  242. CodecReceivePacket(
  243. IN PHW_STREAM_REQUEST_BLOCK Srb
  244. );
  245. VOID STREAMAPI
  246. CodecCancelPacket(
  247. IN PHW_STREAM_REQUEST_BLOCK Srb
  248. );
  249. VOID STREAMAPI
  250. CodecTimeoutPacket(
  251. IN PHW_STREAM_REQUEST_BLOCK Srb
  252. );
  253. VOID STREAMAPI
  254. CodecGetProperty(
  255. IN PHW_STREAM_REQUEST_BLOCK Srb
  256. );
  257. VOID STREAMAPI
  258. CodecSetProperty(
  259. IN PHW_STREAM_REQUEST_BLOCK Srb
  260. );
  261. BOOL
  262. CodecVerifyFormat(
  263. IN KSDATAFORMAT *pKSDataFormat,
  264. UINT StreamNumber,
  265. PKSDATARANGE pMatchedFormat
  266. );
  267. BOOL
  268. CodecFormatFromRange(
  269. IN PHW_STREAM_REQUEST_BLOCK pSrb
  270. );
  271. void
  272. CompleteStreamSRB (
  273. IN PHW_STREAM_REQUEST_BLOCK pSrb,
  274. STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE NotificationType1,
  275. BOOL fUseNotification2,
  276. STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE NotificationType2
  277. );
  278. void
  279. CompleteDeviceSRB (
  280. IN PHW_STREAM_REQUEST_BLOCK pSrb,
  281. IN STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE NotificationType,
  282. BOOL fReadyForNext
  283. );
  284. /////////////////////////////////////////////////////////////////////////////////////
  285. //
  286. // SRB Queue Management functions
  287. //
  288. BOOL STREAMAPI
  289. QueueAddIfNotEmpty(
  290. IN PHW_STREAM_REQUEST_BLOCK,
  291. IN PKSPIN_LOCK,
  292. IN PLIST_ENTRY
  293. );
  294. BOOL STREAMAPI
  295. QueueAdd(
  296. IN PHW_STREAM_REQUEST_BLOCK,
  297. IN PKSPIN_LOCK,
  298. IN PLIST_ENTRY
  299. );
  300. BOOL STREAMAPI
  301. QueueRemove(
  302. IN OUT PHW_STREAM_REQUEST_BLOCK *,
  303. IN PKSPIN_LOCK,
  304. IN PLIST_ENTRY
  305. );
  306. BOOL STREAMAPI
  307. QueuePush (
  308. IN PHW_STREAM_REQUEST_BLOCK pSrb,
  309. IN PKSPIN_LOCK pQueueSpinLock,
  310. IN PLIST_ENTRY pQueue
  311. );
  312. BOOL STREAMAPI
  313. QueueRemoveSpecific(
  314. IN PHW_STREAM_REQUEST_BLOCK,
  315. IN PKSPIN_LOCK,
  316. IN PLIST_ENTRY
  317. );
  318. BOOL STREAMAPI
  319. QueueEmpty(
  320. IN PKSPIN_LOCK,
  321. IN PLIST_ENTRY
  322. );
  323. VOID
  324. STREAMAPI
  325. CodecReceivePacket(
  326. IN PHW_STREAM_REQUEST_BLOCK pSrb
  327. );
  328. BOOLEAN
  329. CodecInitialize (
  330. IN OUT PHW_STREAM_REQUEST_BLOCK pSrb
  331. );
  332. VOID
  333. STREAMAPI
  334. CodecCancelPacket(
  335. PHW_STREAM_REQUEST_BLOCK pSrb
  336. );
  337. VOID
  338. STREAMAPI
  339. CodecTimeoutPacket(
  340. PHW_STREAM_REQUEST_BLOCK pSrb
  341. );
  342. BOOL
  343. CompareGUIDsAndFormatSize(
  344. IN PKSDATARANGE pDataRange1,
  345. IN PKSDATARANGE pDataRange2,
  346. BOOLEAN bCheckSize
  347. );
  348. BOOL
  349. CompareStreamFormat (
  350. IN PHW_STREAM_REQUEST_BLOCK pSrb
  351. );
  352. BOOLEAN
  353. VerifyFormat(
  354. IN KSDATAFORMAT *pKSDataFormat,
  355. UINT StreamNumber,
  356. PKSDATARANGE pMatchedFormat
  357. );
  358. VOID
  359. OpenStream (
  360. PHW_STREAM_REQUEST_BLOCK pSrb
  361. );
  362. VOID
  363. CloseStream (
  364. PHW_STREAM_REQUEST_BLOCK pSrb
  365. );
  366. VOID
  367. STREAMAPI
  368. ReceiveDataPacket (
  369. IN PHW_STREAM_REQUEST_BLOCK pSrb
  370. );
  371. VOID
  372. STREAMAPI
  373. ReceiveCtrlPacket(
  374. IN PHW_STREAM_REQUEST_BLOCK pSrb
  375. );
  376. VOID
  377. IpSinkSetState(
  378. PHW_STREAM_REQUEST_BLOCK pSrb
  379. );
  380. VOID
  381. SlipSetState(
  382. PHW_STREAM_REQUEST_BLOCK pSrb
  383. );
  384. VOID
  385. SlipGetState(
  386. PHW_STREAM_REQUEST_BLOCK pSrb
  387. );
  388. #endif // _SLIP_H_