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.

532 lines
13 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. atktdi.h
  5. Abstract:
  6. This module contains tdi related definitions.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com)
  9. Nikhil Kamkolkar (nikhilk@microsoft.com)
  10. Revision History:
  11. 19 Jun 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _ATKTDI_
  15. #define _ATKTDI_
  16. #define DFLAG_ADDR 0x0001
  17. #define DFLAG_CONN 0x0002
  18. #define DFLAG_CNTR 0x0004
  19. #define DFLAG_MDL 0x0008
  20. struct _ActionReq;
  21. // Typedef for the worker routine used in the dispatch tables
  22. typedef VOID (*GENERIC_COMPLETION)(IN ATALK_ERROR ErrorCode,
  23. IN PIRP pIrp);
  24. typedef VOID (*ACTION_COMPLETION)(IN ATALK_ERROR ErrorCode,
  25. IN struct _ActionReq *pActReq);
  26. typedef ATALK_ERROR (*DISPATCH_ROUTINE)(IN PVOID pObject,
  27. IN struct _ActionReq *pActReq);
  28. typedef VOID (*GENERIC_WRITE_COMPLETION)(
  29. IN ATALK_ERROR ErrorCode,
  30. IN PAMDL WriteBuf,
  31. IN USHORT WriteLen,
  32. IN PIRP pIrp);
  33. typedef VOID (*GENERIC_READ_COMPLETION)(
  34. IN ATALK_ERROR ErrorCode,
  35. IN PAMDL ReadBuf,
  36. IN USHORT ReadLen,
  37. IN ULONG ReadFlags,
  38. IN PIRP pIrp);
  39. // Define the Action dispatch table here.
  40. //
  41. // *IMPORTANT*
  42. // This table is tightly integrated with the action codes defined in
  43. // ATALKTDI.H.
  44. //
  45. // Order is NBP/ZIP/ADSP/ATP/ASP/PAP
  46. //
  47. // Each element of the array contains:
  48. // _MinBufLen - The minimum length of the MdlAddress buffer for the request
  49. // _OpCode - The action code of the request (sanity check)
  50. // _OpInfo - Bit flags give more information about the request
  51. // DFLAG_ADDR - Object for request must be an address object
  52. // DFLAG_CONN - Object for request must be connection object
  53. // DFLAG_CNTR - Object for request must be control channel
  54. // DFLAG_MDL1 - Request uses an mdl (submdl of MdlAddress)
  55. // DFLAG_MDL2 - Request uses a second mdl (submdl of MdlAddress)
  56. // _ActionBufSize - The size of the action header buffer for request
  57. // (beginning of the buffer described by MdlAddress)
  58. // _DeviceType - Valid device types for the request
  59. // ATALK_DEV_ANY => Any device
  60. // _MdlSizeOffset - Offset in action buffer where the size for the first
  61. // mdl can be found. Non-zero only when DFLAG_MDL2 is set.
  62. // _Dispatch - The dispatch routine for the request
  63. //
  64. typedef struct _ActionDispatch {
  65. USHORT _MinBufLen;
  66. USHORT _OpCode;
  67. USHORT _Flags;
  68. USHORT _ActionBufSize;
  69. ATALK_DEV_TYPE _DeviceType;
  70. DISPATCH_ROUTINE _Dispatch;
  71. } ACTION_DISPATCH, *PACTION_DISPATCH;
  72. extern POBJECT_TYPE *IoFileObjectType;
  73. extern ACTION_DISPATCH AtalkActionDispatch[];
  74. #define ACTREQ_SIGNATURE (*(PULONG)"ACRQ")
  75. #if DBG
  76. #define VALID_ACTREQ(pActReq) (((pActReq) != NULL) && \
  77. ((pActReq)->ar_Signature == ACTREQ_SIGNATURE))
  78. #else
  79. #define VALID_ACTREQ(pActReq) ((pActReq) != NULL)
  80. #endif
  81. typedef struct _ActionReq
  82. {
  83. #if DBG
  84. ULONG ar_Signature;
  85. #endif
  86. PIRP ar_pIrp; // Irp for the request
  87. PVOID ar_pParms; // Action parameter block
  88. PAMDL ar_pAMdl; // Mdl (OPTIONAL)
  89. SHORT ar_MdlSize; // And its size
  90. ULONG ar_ActionCode; // TDI Action code
  91. SHORT ar_DevType; // Which device ?
  92. ACTION_COMPLETION ar_Completion; // Tdi Completion routine
  93. PKEVENT ar_CmplEvent; // zone-list acquiring done
  94. PVOID ar_pZci; // ptr to zoneinfo struct
  95. ULONG ar_StatusCode;
  96. } ACTREQ, *PACTREQ;
  97. typedef enum {
  98. ATALK_INDICATE_DISCONNECT,
  99. ATALK_TIMER_DISCONNECT,
  100. ATALK_REMOTE_DISCONNECT,
  101. ATALK_LOCAL_DISCONNECT
  102. } ATALK_DISCONNECT_TYPE;
  103. #define DISCONN_STATUS(DiscType) \
  104. (((DiscType == ATALK_TIMER_DISCONNECT) ? ATALK_CONNECTION_TIMEOUT : \
  105. (DiscType == ATALK_REMOTE_DISCONNECT)) ? ATALK_REMOTE_CLOSE : \
  106. ATALK_NO_ERROR)
  107. extern
  108. NTSTATUS
  109. AtalkTdiOpenAddress(
  110. IN PIRP Irp,
  111. IN PIO_STACK_LOCATION IrpSp,
  112. IN PTA_APPLETALK_ADDRESS TdiAddress,
  113. IN UCHAR ProtocolType,
  114. IN UCHAR SocketType,
  115. IN OUT PATALK_DEV_CTX Context
  116. );
  117. extern
  118. NTSTATUS
  119. AtalkTdiOpenConnection(
  120. IN PIRP Irp,
  121. IN PIO_STACK_LOCATION IrpSp,
  122. IN CONNECTION_CONTEXT ConnectionContext,
  123. IN OUT PATALK_DEV_CTX Context
  124. );
  125. extern
  126. NTSTATUS
  127. AtalkTdiOpenControlChannel(
  128. IN PIRP Irp,
  129. IN PIO_STACK_LOCATION IrpSp,
  130. IN OUT PATALK_DEV_CTX Context
  131. );
  132. extern
  133. NTSTATUS
  134. AtalkTdiCleanupAddress(
  135. IN PIRP Irp,
  136. IN PIO_STACK_LOCATION IrpSp,
  137. IN OUT PATALK_DEV_CTX Context
  138. );
  139. extern
  140. NTSTATUS
  141. AtalkTdiCleanupConnection(
  142. IN PIRP Irp,
  143. IN PIO_STACK_LOCATION IrpSp,
  144. IN OUT PATALK_DEV_CTX Context
  145. );
  146. extern
  147. NTSTATUS
  148. AtalkTdiCloseAddress(
  149. IN PIRP Irp,
  150. IN PIO_STACK_LOCATION IrpSp,
  151. IN OUT PATALK_DEV_CTX Context
  152. );
  153. extern
  154. NTSTATUS
  155. AtalkTdiCloseConnection(
  156. IN PIRP Irp,
  157. IN PIO_STACK_LOCATION IrpSp,
  158. IN OUT PATALK_DEV_CTX Context
  159. );
  160. extern
  161. NTSTATUS
  162. AtalkTdiCloseControlChannel(
  163. IN PIRP Irp,
  164. IN PIO_STACK_LOCATION IrpSp,
  165. IN OUT PATALK_DEV_CTX Context
  166. );
  167. extern
  168. VOID
  169. AtalkTdiCancel(
  170. IN OUT PATALK_DEV_OBJ pDevObj,
  171. IN PIRP Irp
  172. );
  173. extern
  174. NTSTATUS
  175. AtalkTdiAssociateAddress(
  176. IN PIRP Irp,
  177. IN PIO_STACK_LOCATION IrpSp,
  178. IN OUT PATALK_DEV_CTX Context
  179. );
  180. extern
  181. NTSTATUS
  182. AtalkTdiDisassociateAddress(
  183. IN PIRP Irp,
  184. IN PIO_STACK_LOCATION IrpSp,
  185. IN OUT PATALK_DEV_CTX Context
  186. );
  187. extern
  188. NTSTATUS
  189. AtalkTdiConnect(
  190. IN PIRP Irp,
  191. IN PIO_STACK_LOCATION IrpSp,
  192. IN OUT PATALK_DEV_CTX Context
  193. );
  194. extern
  195. NTSTATUS
  196. AtalkTdiDisconnect(
  197. IN PIRP Irp,
  198. IN PIO_STACK_LOCATION IrpSp,
  199. IN OUT PATALK_DEV_CTX Context
  200. );
  201. extern
  202. NTSTATUS
  203. AtalkTdiAccept(
  204. IN PIRP Irp,
  205. IN PIO_STACK_LOCATION IrpSp,
  206. IN OUT PATALK_DEV_CTX Context
  207. );
  208. extern
  209. NTSTATUS
  210. AtalkTdiListen(
  211. IN PIRP Irp,
  212. IN PIO_STACK_LOCATION IrpSp,
  213. IN OUT PATALK_DEV_CTX Context
  214. );
  215. extern
  216. NTSTATUS
  217. AtalkTdiSendDgram(
  218. IN PIRP Irp,
  219. IN PIO_STACK_LOCATION IrpSp,
  220. IN OUT PATALK_DEV_CTX Context
  221. );
  222. extern
  223. NTSTATUS
  224. AtalkTdiReceiveDgram(
  225. IN PIRP Irp,
  226. IN PIO_STACK_LOCATION IrpSp,
  227. IN OUT PATALK_DEV_CTX Context
  228. );
  229. extern
  230. NTSTATUS
  231. AtalkTdiSend(
  232. IN PIRP Irp,
  233. IN PIO_STACK_LOCATION IrpSp,
  234. IN OUT PATALK_DEV_CTX Context
  235. );
  236. extern
  237. NTSTATUS
  238. AtalkTdiReceive(
  239. IN PIRP Irp,
  240. IN PIO_STACK_LOCATION IrpSp,
  241. IN OUT PATALK_DEV_CTX Context
  242. );
  243. extern
  244. NTSTATUS
  245. AtalkTdiAction(
  246. IN PIRP Irp,
  247. IN PIO_STACK_LOCATION IrpSp,
  248. IN OUT PATALK_DEV_CTX Context
  249. );
  250. extern
  251. NTSTATUS
  252. AtalkTdiQueryInformation(
  253. IN PIRP Irp,
  254. IN PIO_STACK_LOCATION IrpSp,
  255. IN OUT PATALK_DEV_CTX Context
  256. );
  257. extern
  258. NTSTATUS
  259. AtalkTdiSetInformation(
  260. IN PIRP Irp,
  261. IN PIO_STACK_LOCATION IrpSp,
  262. IN OUT PATALK_DEV_CTX Context
  263. );
  264. extern
  265. NTSTATUS
  266. AtalkTdiSetEventHandler(
  267. IN PIRP Irp,
  268. IN PIO_STACK_LOCATION IrpSp,
  269. IN OUT PATALK_DEV_CTX Context
  270. );
  271. extern
  272. ATALK_ERROR
  273. AtalkStatTdiAction(
  274. IN PVOID pObject, // Address or Connection object
  275. IN PACTREQ pActReq // Pointer to action request
  276. );
  277. extern
  278. ATALK_ERROR
  279. AtalkNbpTdiAction(
  280. IN PVOID pObject, // Address or Connection object
  281. IN PACTREQ pActReq // Pointer to action request
  282. );
  283. extern
  284. ATALK_ERROR
  285. AtalkZipTdiAction(
  286. IN PVOID pObject, // Address or Connection object
  287. IN PACTREQ pActReq // Pointer to action request
  288. );
  289. extern
  290. ATALK_ERROR
  291. AtalkAdspTdiAction(
  292. IN PVOID pObject, // Address or Connection object
  293. IN PACTREQ pActReq // Pointer to action request
  294. );
  295. extern
  296. ATALK_ERROR
  297. AtalkAspCTdiAction(
  298. IN PVOID pObject, // Address or Connection object
  299. IN PACTREQ pActReq // Pointer to action request
  300. );
  301. extern
  302. ATALK_ERROR
  303. AtalkPapTdiAction(
  304. IN PVOID pObject, // Address or Connection object
  305. IN PACTREQ pActReq // Pointer to action request
  306. );
  307. extern
  308. ATALK_ERROR
  309. AtalkAspTdiAction(
  310. IN PVOID pObject, // Address or Connection object
  311. IN PACTREQ pActReq // Pointer to action request
  312. );
  313. extern
  314. VOID
  315. atalkTdiGenericWriteComplete(
  316. IN ATALK_ERROR ErrorCode,
  317. IN PAMDL WriteBuf,
  318. IN USHORT WriteLen,
  319. IN PIRP pIrp
  320. );
  321. typedef struct
  322. {
  323. LONG ls_LockCount;
  324. PVOID ls_LockHandle;
  325. } LOCK_SECTION, *PLOCK_SECTION;
  326. #define AtalkLockAdspIfNecessary() AtalkLockUnlock(TRUE, \
  327. &AtalkPgLkSection[ADSP_SECTION])
  328. #define AtalkUnlockAdspIfNecessary() AtalkLockUnlock(FALSE, \
  329. &AtalkPgLkSection[ADSP_SECTION])
  330. #define AtalkLockPapIfNecessary() AtalkLockUnlock(TRUE, \
  331. &AtalkPgLkSection[PAP_SECTION])
  332. #define AtalkUnlockPapIfNecessary() AtalkLockUnlock(FALSE, \
  333. &AtalkPgLkSection[PAP_SECTION])
  334. #define AtalkLockNbpIfNecessary() AtalkLockUnlock(TRUE, \
  335. &AtalkPgLkSection[NBP_SECTION])
  336. #define AtalkUnlockNbpIfNecessary() AtalkLockUnlock(FALSE, \
  337. &AtalkPgLkSection[NBP_SECTION])
  338. #define AtalkLockZipIfNecessary() AtalkLockUnlock(TRUE, \
  339. &AtalkPgLkSection[ZIP_SECTION])
  340. #define AtalkUnlockZipIfNecessary() AtalkLockUnlock(FALSE, \
  341. &AtalkPgLkSection[ZIP_SECTION])
  342. #define AtalkLockRouterIfNecessary() AtalkLockUnlock(TRUE, \
  343. &AtalkPgLkSection[ROUTER_SECTION])
  344. #define AtalkUnlockRouterIfNecessary() AtalkLockUnlock(FALSE, \
  345. &AtalkPgLkSection[ROUTER_SECTION])
  346. #define AtalkLockTdiIfNecessary() AtalkLockUnlock(TRUE, \
  347. &AtalkPgLkSection[TDI_SECTION])
  348. #define AtalkUnlockTdiIfNecessary() AtalkLockUnlock(FALSE, \
  349. &AtalkPgLkSection[TDI_SECTION])
  350. #define AtalkLockAspIfNecessary() AtalkLockUnlock(TRUE, \
  351. &AtalkPgLkSection[ASP_SECTION])
  352. #define AtalkUnlockAspIfNecessary() AtalkLockUnlock(FALSE, \
  353. &AtalkPgLkSection[ASP_SECTION])
  354. #define AtalkLockAspCIfNecessary() AtalkLockUnlock(TRUE, \
  355. &AtalkPgLkSection[ASPC_SECTION])
  356. #define AtalkUnlockAspCIfNecessary() AtalkLockUnlock(FALSE, \
  357. &AtalkPgLkSection[ASPC_SECTION])
  358. #define AtalkLockAtpIfNecessary() AtalkLockUnlock(TRUE, \
  359. &AtalkPgLkSection[ATP_SECTION])
  360. #define AtalkUnlockAtpIfNecessary() AtalkLockUnlock(FALSE, \
  361. &AtalkPgLkSection[ATP_SECTION])
  362. #define AtalkLockInitIfNecessary() AtalkLockUnlock(TRUE, \
  363. &AtalkPgLkSection[INIT_SECTION])
  364. #define AtalkUnlockInitIfNecessary() AtalkLockUnlock(FALSE, \
  365. &AtalkPgLkSection[INIT_SECTION])
  366. #define AtalkLockArapIfNecessary() AtalkLockUnlock(TRUE, \
  367. &AtalkPgLkSection[ARAP_SECTION])
  368. #define AtalkUnlockArapIfNecessary() AtalkLockUnlock(FALSE, \
  369. &AtalkPgLkSection[ARAP_SECTION])
  370. #define AtalkLockPPPIfNecessary() AtalkLockUnlock(TRUE, \
  371. &AtalkPgLkSection[PPP_SECTION])
  372. #define AtalkUnlockPPPIfNecessary() AtalkLockUnlock(FALSE, \
  373. &AtalkPgLkSection[PPP_SECTION])
  374. extern
  375. VOID
  376. AtalkLockInit(
  377. IN PLOCK_SECTION pLs,
  378. IN PVOID Address
  379. );
  380. extern
  381. VOID
  382. AtalkLockUnlock(
  383. IN BOOLEAN Lock,
  384. IN PLOCK_SECTION pLs
  385. );
  386. #define ROUTER_SECTION 0
  387. #define NBP_SECTION 1 // NBP & ZIP share the sections
  388. #define ZIP_SECTION 1
  389. #define TDI_SECTION 2
  390. #define ATP_SECTION 3
  391. #define ASP_SECTION 4
  392. #define PAP_SECTION 5
  393. #define ADSP_SECTION 6
  394. #define ASPC_SECTION 7
  395. #define INIT_SECTION 8
  396. #define ARAP_SECTION 9
  397. #define PPP_SECTION 10
  398. #define LOCKABLE_SECTIONS 11
  399. extern KMUTEX AtalkPgLkMutex;
  400. extern ATALK_SPIN_LOCK AtalkPgLkLock;
  401. extern LOCK_SECTION AtalkPgLkSection[LOCKABLE_SECTIONS];
  402. // Used by AtalkLockUnlock & atalkQueuedLockUnlock to communicate. The latter is queued
  403. // up by the former whenever it is called at DISPACTH to unlock
  404. typedef struct
  405. {
  406. WORK_QUEUE_ITEM qlu_WQI;
  407. PLOCK_SECTION qlu_pLockSection;
  408. PPORT_DESCRIPTOR qlu_pPortDesc;
  409. } QLU, *PQLU;
  410. LOCAL VOID FASTCALL
  411. atalkTdiSendDgramComplete(
  412. IN NDIS_STATUS Status,
  413. IN struct _SEND_COMPL_INFO * pSendInfo
  414. );
  415. LOCAL VOID
  416. atalkTdiRecvDgramComplete(
  417. IN ATALK_ERROR ErrorCode,
  418. IN PAMDL pReadBuf,
  419. IN USHORT ReadLen,
  420. IN PATALK_ADDR pSrcAddr,
  421. IN PIRP pIrp);
  422. LOCAL VOID
  423. atalkTdiActionComplete(
  424. IN ATALK_ERROR ErrorCode,
  425. IN PACTREQ pActReq
  426. );
  427. LOCAL VOID
  428. atalkTdiGenericComplete(
  429. IN ATALK_ERROR ErrorCode,
  430. IN PIRP pIrp
  431. );
  432. LOCAL VOID
  433. atalkTdiCloseAddressComplete(
  434. IN ATALK_ERROR ErrorCode,
  435. IN PIRP pIrp
  436. );
  437. LOCAL VOID
  438. atalkTdiGenericReadComplete(
  439. IN ATALK_ERROR ErrorCode,
  440. IN PAMDL ReadBuf,
  441. IN USHORT ReadLen,
  442. IN ULONG ReadFlags,
  443. IN PIRP pIrp
  444. );
  445. LOCAL VOID
  446. atalkQueuedLockUnlock(
  447. IN PQLU pQLU
  448. );
  449. VOID
  450. atalkWaitDefaultPort(
  451. VOID
  452. );
  453. #endif // _ATKTDI_
  454.