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.

782 lines
23 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. pap.h
  5. Abstract:
  6. This module contains definitions for the PAP code.
  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 _PAP_
  15. #define _PAP_
  16. // PAP command type bytes:
  17. #define PAP_OPEN_CONN 1
  18. #define PAP_OPEN_CONNREPLY 2
  19. #define PAP_SEND_DATA 3
  20. #define PAP_DATA 4
  21. #define PAP_TICKLE 5
  22. #define PAP_CLOSE_CONN 6
  23. #define PAP_CLOSE_CONN_REPLY 7
  24. #define PAP_SEND_STATUS 8
  25. #define PAP_STATUS_REPLY 9
  26. // Error codes for OpenConnectionReply:
  27. #define PAP_NO_ERROR 0x0000
  28. #define PAP_PRINTER_BUSY 0xFFFF
  29. // PAP sizes:
  30. #define PAP_MAX_DATA_PACKET_SIZE 512
  31. #define PAP_SEND_USER_BYTES_ALL TRUE
  32. #define PAP_MAX_STATUS_SIZE 255
  33. #define PAP_MAX_FLOW_QUANTUM 8
  34. #define PAP_MAX_ATP_BYTES_TO_SL 4
  35. // PAP timer values:
  36. #define PAP_OPENCONN_REQ_RETRYCOUNT 5
  37. #define PAP_OPENCONN_INTERVAL 20 // In 100ms units
  38. #define PAP_TICKLE_INTERVAL 600 // In 100ms units
  39. #define PAP_CONNECTION_INTERVAL 1200 // In 100ms units
  40. #define PAP_MIN_SENDDATA_REQ_INTERVAL 10 // In 100ms units
  41. #define PAP_MAX_SENDDATA_REQ_INTERVAL 150 // In 100ms units
  42. #define PAP_INIT_SENDDATA_REQ_INTERVAL 10 // In 100ms units
  43. // The following aren't documented... so we'll take a wild guess...
  44. #define PAP_GETSTATUS_REQ_RETRYCOUNT 5
  45. #define PAP_GETSTATUS_ATP_INTERVAL 20 // In 100ms units
  46. // Offsets within ATP userBytes and data buffer for the various fields of the
  47. // PAP header:
  48. #define PAP_CONNECTIONID_OFF 0
  49. #define PAP_CMDTYPE_OFF 1
  50. #define PAP_EOFFLAG_OFF 2
  51. #define PAP_SEQNUM_OFF 2
  52. #define PAP_RESP_SOCKET_OFF 0
  53. #define PAP_FLOWQUANTUM_OFF 1
  54. #define PAP_WAITTIME_OFF 2
  55. #define PAP_RESULT_OFF 2
  56. #define PAP_STATUS_OFF 4
  57. #define PAP_MAX_WAIT_TIMEOUT 0x80 // Pretty randomly chosen
  58. // For resolving forward references
  59. struct _PAP_ADDROBJ;
  60. struct _PAP_CONNOBJ;
  61. // PAP Address Object
  62. // This is created whenever an address object is created on the Pap device.
  63. // This represents either a client or a server side pap address. The server
  64. // side address is represented by PAPAO_LISTENER flag.
  65. #define PAP_CONN_HASH_SIZE 7
  66. // PAP ADDRESS OBJECT STATES
  67. #define PAPAO_LISTENER 0x00000001
  68. #define PAPAO_CONNECT 0x00000002
  69. #define PAPAO_UNBLOCKED 0x00000004
  70. #define PAPAO_SLS_QUEUED 0x00000008
  71. #define PAPAO_CLEANUP 0x01000000
  72. #define PAPAO_BLOCKING 0x02000000
  73. #define PAPAO_BLOCKING 0x02000000
  74. #define PAPAO_CLOSING 0x80000000
  75. #define PAPAO_SIGNATURE (*(PULONG)"PAAO")
  76. #define VALID_PAPAO(pPapAddr) (((pPapAddr) != NULL) && \
  77. (((struct _PAP_ADDROBJ *)(pPapAddr))->papao_Signature == PAPAO_SIGNATURE))
  78. typedef struct _PAP_ADDROBJ
  79. {
  80. ULONG papao_Signature;
  81. // Global list of address objects.
  82. struct _PAP_ADDROBJ * papao_Next;
  83. struct _PAP_ADDROBJ ** papao_Prev;
  84. ULONG papao_Flags;
  85. ULONG papao_RefCount;
  86. // List of connections associated with this address object.
  87. // Potentially greater than one if this address object is a listener.
  88. struct _PAP_CONNOBJ * papao_pAssocConn;
  89. // List of connections that are associated, but also have a listen/connect
  90. // posted on them.
  91. union
  92. {
  93. struct _PAP_CONNOBJ * papao_pListenConn;
  94. struct _PAP_CONNOBJ * papao_pConnectConn;
  95. };
  96. // Lookup list of all active connections hashed by connId and remote
  97. // address.
  98. struct _PAP_CONNOBJ * papao_pActiveHash[PAP_CONN_HASH_SIZE];
  99. // Next connection to use.
  100. BYTE papao_NextConnId;
  101. // The following are valid only if this is a listener.
  102. SHORT papao_SrvQuantum;
  103. SHORT papao_StatusSize;
  104. PBYTE papao_pStatusBuf;
  105. // Event support routines.
  106. //
  107. // This function pointer points to a connection indication handler for this
  108. // Address. Any time a connect request is received on the address, this
  109. // routine is invoked.
  110. PTDI_IND_CONNECT papao_ConnHandler;
  111. PVOID papao_ConnHandlerCtx;
  112. // The following function pointer always points to a TDI_IND_DISCONNECT
  113. // handler for the address. If the NULL handler is specified in a
  114. // TdiSetEventHandler, this this points to an internal routine which
  115. // simply returns successfully.
  116. PTDI_IND_DISCONNECT papao_DisconnectHandler;
  117. PVOID papao_DisconnectHandlerCtx;
  118. // The following function pointer always points to a TDI_IND_RECEIVE
  119. // event handler for connections on this address. If the NULL handler
  120. // is specified in a TdiSetEventHandler, then this points to an internal
  121. // routine which does not accept the incoming data.
  122. PTDI_IND_RECEIVE papao_RecvHandler;
  123. PVOID papao_RecvHandlerCtx;
  124. // The following function pointer always points to a TDI_IND_SEND_POSSIBLE
  125. // handler for the address. If the NULL handler is specified in a
  126. // TdiSetEventHandler, this this points to an internal routine which
  127. // simply returns successfully.
  128. PTDI_IND_SEND_POSSIBLE papao_SendPossibleHandler;
  129. PVOID papao_SendPossibleHandlerCtx;
  130. // ATP Address for this pap address. If this is a listener, then the ATP
  131. // address will be what the listens effectively will be posted on, if this
  132. // is a connect address object, then this atp address will be what the
  133. // associated connection be active over.
  134. PATP_ADDROBJ papao_pAtpAddr;
  135. // Completion routine to be called when address is closed
  136. GENERIC_COMPLETION papao_CloseComp;
  137. PVOID papao_CloseCtx;
  138. PATALK_DEV_CTX papao_pDevCtx;
  139. ATALK_SPIN_LOCK papao_Lock;
  140. } PAP_ADDROBJ, *PPAP_ADDROBJ;
  141. #define PAPCO_ASSOCIATED 0x00000001
  142. #define PAPCO_LISTENING 0x00000002
  143. #define PAPCO_CONNECTING 0x00000004
  144. #define PAPCO_ACTIVE 0x00000008
  145. #define PAPCO_SENDDATA_RECD 0x00000010
  146. #define PAPCO_WRITEDATA_WAITING 0x00000020
  147. #define PAPCO_SEND_EOF_WRITE 0x00000040
  148. #define PAPCO_READDATA_PENDING 0x00000080
  149. #define PAPCO_DISCONNECTING 0x00000100
  150. #define PAPCO_LOCAL_DISCONNECT 0x00000200
  151. #define PAPCO_REMOTE_DISCONNECT 0x00000400
  152. #define PAPCO_SERVER_JOB 0x00000800
  153. #define PAPCO_REMOTE_CLOSE 0x00001000
  154. #define PAPCO_NONBLOCKING_READ 0x00002000
  155. #define PAPCO_READDATA_WAITING 0x00004000
  156. #define PAPCO_DELAYED_DISCONNECT 0x00008000
  157. #define PAPCO_RECVD_DISCONNECT 0x00010000
  158. #define PAPCO_ADDR_ACTIVE 0x00020000
  159. #define PAPCO_REJECT_READS 0x00040000
  160. #if DBG
  161. #define PAPCO_CLEANUP 0x01000000
  162. #define PAPCO_INDICATE_AFD_DISC 0x02000000
  163. #endif
  164. #define PAPCO_STOPPING 0x40000000
  165. #define PAPCO_CLOSING 0x80000000
  166. #define PAPCO_SIGNATURE (*(PULONG)"PACO")
  167. #define VALID_PAPCO(pPapConn) (((pPapConn) != NULL) && \
  168. (((struct _PAP_CONNOBJ *)(pPapConn))->papco_Signature == PAPCO_SIGNATURE))
  169. // This will represent a 'job' on the Pap address. This could either be a
  170. // workstation job or a server job. In the latter case it could either
  171. // be in a 'listen' state or active state. In the former case it is either
  172. // active or 'waiting'
  173. typedef struct _PAP_CONNOBJ
  174. {
  175. ULONG papco_Signature;
  176. // Global list of connection objects.
  177. struct _PAP_CONNOBJ * papco_Next;
  178. struct _PAP_CONNOBJ ** papco_Prev;
  179. ULONG papco_Flags;
  180. ULONG papco_RefCount;
  181. // Backpointer to the associated address
  182. struct _PAP_ADDROBJ * papco_pAssocAddr;
  183. // The address this connection uses for itself. In the case of a connect
  184. // this will be the same as the address object's ATP address.
  185. PATP_ADDROBJ papco_pAtpAddr;
  186. // Used to queue into the address object's associated list.
  187. struct _PAP_CONNOBJ * papco_pNextAssoc;
  188. // Used to queue into the address object's listen/connect list. When it
  189. // is removed from the listen/connect, it goes into the active list of the
  190. // address object. When active, pNextActive will be the overflow list.
  191. union
  192. {
  193. struct _PAP_CONNOBJ * papco_pNextListen;
  194. struct _PAP_CONNOBJ * papco_pNextConnect;
  195. struct _PAP_CONNOBJ * papco_pNextActive;
  196. };
  197. // Address of remote end of the connection
  198. ATALK_ADDR papco_RemoteAddr;
  199. // Connection id
  200. BYTE papco_ConnId;
  201. // WaitTime value for PapConnect call. We start with 0 and increment by 2
  202. // till we either succeed or reach PAP_MAX_WAIT_TIMEOUT
  203. BYTE papco_WaitTimeOut;
  204. // Max size we can write to the remote end. This is dictated by the
  205. // remote end. Our recv flow quantum will always be PAP_MAX_FLOW_QUANTUM.
  206. SHORT papco_SendFlowQuantum;
  207. LONG papco_LastContactTime;
  208. USHORT papco_TickleTid;
  209. // Adaptive Retry time support
  210. RT papco_RT;
  211. // Connection context
  212. PVOID papco_ConnCtx;
  213. // PAP handles only one read and one write per job at a time. So we
  214. // explicitly have the relevant information for the two cases in here.
  215. // PAPWRITE():
  216. // If the remote end did a papread() and we are waiting for our client
  217. // to do a papwrite(), then the PAPCO_SENDDATA_RECD will be true and the
  218. // following will be used for our papwrite() response. Note
  219. // that we will assume all send data responses to be exactly-once.
  220. PATP_RESP papco_pAtpResp;
  221. // Next expected sequence number of send data.
  222. USHORT papco_NextIncomingSeqNum;
  223. // Where did the senddata request come from. NOTE this may not be the
  224. // same as papco_RemoteAddr!!!
  225. ATALK_ADDR papco_SendDataSrc;
  226. // If the remote end has not done a send data, then our write will pend
  227. // and the PAPCO_WRITEDATA_WAITING will be set. Even if send credit is
  228. // available the write will pend until all the data is sent out. But in
  229. // that case both the PAPCO_WRITEDATA_WAITING and the PAPCO_SENDDATA_RECD will
  230. // be set. Note that whenever PAPCO_WRITEDATA_WAITING is set, no new writes
  231. // will be accepted by PAP for this job.
  232. PAMDL papco_pWriteBuf;
  233. SHORT papco_WriteLen;
  234. GENERIC_WRITE_COMPLETION papco_WriteCompletion;
  235. PVOID papco_WriteCtx;
  236. // PAPREAD():
  237. // In the case where we are doing a PapRead(). Pap only allows one read
  238. // at a time per connection. The last seq num we used for an outgoing senddata.
  239. // While a PAPREAD() is active, the PAPCO_READDATA_PENDING will be set.
  240. // NOTE: The user's buffer is passed on to ATP as a response buffer. For
  241. // nonblocking reads we prime with the users buffers which are stored here.
  242. ULONG papco_NbReadFlags;
  243. PACTREQ papco_NbReadActReq;
  244. USHORT papco_NbReadLen; // Number of bytes read
  245. USHORT papco_ReadDataTid;
  246. USHORT papco_NextOutgoingSeqNum;
  247. GENERIC_READ_COMPLETION papco_ReadCompletion;
  248. PVOID papco_ReadCtx;
  249. // The connection object can have either a CONNECT or a LISTEN posted
  250. // on it, but not both.
  251. union
  252. {
  253. struct
  254. {
  255. // Pending Listen routine.
  256. GENERIC_COMPLETION papco_ListenCompletion;
  257. PVOID papco_ListenCtx;
  258. };
  259. struct
  260. {
  261. // Pending Connect routine. The status buffer is remembered and
  262. // returned via socket options. The pConnectRespBuf is remembered
  263. // to avoid having to get the system address for it. It is freed
  264. // when connection is taken off the connectlist.
  265. GENERIC_COMPLETION papco_ConnectCompletion;
  266. PVOID papco_ConnectCtx;
  267. PBYTE papco_pConnectRespBuf;
  268. PBYTE papco_pConnectOpenBuf;
  269. USHORT papco_ConnectRespLen;
  270. USHORT papco_ConnectTid;
  271. };
  272. };
  273. // Disconnect inform routine
  274. GENERIC_COMPLETION papco_DisconnectInform;
  275. PVOID papco_DisconnectInformCtx;
  276. // Disconnect request completion
  277. ATALK_ERROR papco_DisconnectStatus;
  278. GENERIC_COMPLETION papco_DisconnectCompletion;
  279. PVOID papco_DisconnectCtx;
  280. // Completion routine to be called when socket cleanup is called
  281. GENERIC_COMPLETION papco_CleanupComp;
  282. PVOID papco_CleanupCtx;
  283. // Completion routine to be called when socket is closed
  284. GENERIC_COMPLETION papco_CloseComp;
  285. PVOID papco_CloseCtx;
  286. PATALK_DEV_CTX papco_pDevCtx;
  287. ATALK_SPIN_LOCK papco_Lock;
  288. } PAP_CONNOBJ, *PPAP_CONNOBJ;
  289. // Used for sending a status reply to a send status command.
  290. typedef struct _PAP_SEND_STATUS_REL
  291. {
  292. PPAP_ADDROBJ papss_pPapAddr;
  293. PATP_RESP papss_pAtpResp;
  294. PAMDL papss_pAmdl;
  295. BYTE papss_StatusBuf[PAP_STATUS_OFF + 1];
  296. // This will be followed by the actual status.
  297. } PAP_SEND_STATUS_REL, *PPAP_SEND_STATUS_REL;
  298. // Used for sending a open reply
  299. typedef struct _PAP_OPEN_REPLY_REL
  300. {
  301. PAMDL papor_pRespAmdl;
  302. PATP_RESP papor_pAtpResp;
  303. BYTE papor_pRespPkt[PAP_MAX_DATA_PACKET_SIZE];
  304. } PAP_OPEN_REPLY_REL, *PPAP_OPEN_REPLY_REL;
  305. // Routine prototypes
  306. VOID
  307. AtalkInitPapInitialize(
  308. VOID);
  309. ATALK_ERROR
  310. AtalkPapCreateAddress(
  311. IN PATALK_DEV_CTX pDevCtx OPTIONAL,
  312. OUT PPAP_ADDROBJ * ppPapAddr);
  313. ATALK_ERROR
  314. AtalkPapCleanupAddress(
  315. IN PPAP_ADDROBJ pPapAddr);
  316. ATALK_ERROR
  317. AtalkPapCloseAddress(
  318. IN PPAP_ADDROBJ pPapAddr,
  319. IN GENERIC_COMPLETION CompletionRoutine,
  320. IN PVOID pCloseCtx);
  321. ATALK_ERROR
  322. AtalkPapCreateConnection(
  323. IN PVOID pConnCtx, // Context to associate with the session
  324. IN PATALK_DEV_CTX pDevCtx OPTIONAL,
  325. OUT PPAP_CONNOBJ * ppPapConn);
  326. ATALK_ERROR
  327. AtalkPapCleanupConnection(
  328. IN PPAP_CONNOBJ pPapConn);
  329. ATALK_ERROR
  330. AtalkPapCloseConnection(
  331. IN PPAP_CONNOBJ pPapConn,
  332. IN GENERIC_COMPLETION CompletionRoutine,
  333. IN PVOID pCloseCtx);
  334. ATALK_ERROR
  335. AtalkPapConnStop(
  336. IN PPAP_CONNOBJ pPapConn);
  337. ATALK_ERROR
  338. AtalkPapAssociateAddress(
  339. IN PPAP_ADDROBJ pPapAddr,
  340. IN PPAP_CONNOBJ pPapConn);
  341. ATALK_ERROR
  342. AtalkPapDissociateAddress(
  343. IN PPAP_CONNOBJ pPapConn);
  344. ATALK_ERROR
  345. AtalkPapPostListen(
  346. IN PPAP_CONNOBJ pPapConn,
  347. IN PVOID pListenCtx,
  348. IN GENERIC_COMPLETION CompletionRoutine);
  349. ATALK_ERROR
  350. AtalkPapPrimeListener(
  351. IN PPAP_ADDROBJ pPapAddr);
  352. ATALK_ERROR
  353. AtalkPapCancelListen(
  354. IN PPAP_CONNOBJ pPapConn);
  355. ATALK_ERROR
  356. AtalkPapPostConnect(
  357. IN PPAP_CONNOBJ pPapConn,
  358. IN PATALK_ADDR pRemoteAddr,
  359. IN PVOID pConnectCtx,
  360. IN GENERIC_COMPLETION CompletionRoutine);
  361. ATALK_ERROR
  362. AtalkPapDisconnect(
  363. IN PPAP_CONNOBJ pPapConn,
  364. IN ATALK_DISCONNECT_TYPE DisconnectType,
  365. IN PVOID pDisconnectCtx,
  366. IN GENERIC_COMPLETION CompletionRoutine);
  367. ATALK_ERROR
  368. AtalkPapRead(
  369. IN PPAP_CONNOBJ pPapConn,
  370. IN PAMDL pReadBuf,
  371. IN USHORT ReadBufLen,
  372. IN ULONG ReadFlags,
  373. IN PVOID pReadCtx,
  374. IN GENERIC_READ_COMPLETION CompletionRoutine);
  375. ATALK_ERROR
  376. AtalkPapPrimeRead(
  377. IN PPAP_CONNOBJ pPapConn,
  378. IN PACTREQ pActReq);
  379. ATALK_ERROR
  380. AtalkPapWrite(
  381. IN PPAP_CONNOBJ pPapConn,
  382. IN PAMDL pWriteBuf,
  383. IN USHORT WriteBufLen,
  384. IN ULONG SendFlags,
  385. IN PVOID pWriteCtx,
  386. IN GENERIC_WRITE_COMPLETION CompletionRoutine);
  387. ATALK_ERROR
  388. AtalkPapSetStatus(
  389. IN PPAP_ADDROBJ pPapAddr,
  390. IN PAMDL pStatusMdl,
  391. IN PACTREQ pActReq);
  392. ATALK_ERROR
  393. AtalkPapGetStatus(
  394. IN PPAP_ADDROBJ pPapAddr,
  395. IN PATALK_ADDR pRemoteAddr,
  396. IN PAMDL pStatusAmdl,
  397. IN USHORT AmdlSize,
  398. IN PACTREQ pActReq);
  399. VOID
  400. AtalkPapQuery(
  401. IN PVOID pObject,
  402. IN ULONG ObjectType,
  403. IN PAMDL pAmdl,
  404. OUT PULONG BytesWritten);
  405. VOID FASTCALL
  406. atalkPapAddrDeref(
  407. IN PPAP_ADDROBJ pPapAddr);
  408. VOID FASTCALL
  409. atalkPapConnRefByPtrNonInterlock(
  410. IN PPAP_CONNOBJ pPapConn,
  411. OUT PATALK_ERROR pError);
  412. VOID
  413. atalkPapConnRefNextNc(
  414. IN PPAP_CONNOBJ pPapConn,
  415. IN PPAP_CONNOBJ * ppPapConnNext,
  416. OUT PATALK_ERROR pError);
  417. VOID
  418. atalkPapConnRefByCtx(
  419. IN PPAP_ADDROBJ pPapAddr,
  420. IN CONNECTION_CONTEXT pCtx,
  421. OUT PPAP_CONNOBJ * pPapConn,
  422. OUT PATALK_ERROR pError);
  423. VOID FASTCALL
  424. atalkPapConnDeref(
  425. IN PPAP_CONNOBJ pPapConn);
  426. // MACROS
  427. #define AtalkPapAddrReferenceNonInterlock(_pPapAddr, _pError) \
  428. { \
  429. if (((_pPapAddr)->papao_Flags & PAPAO_CLOSING) == 0) \
  430. { \
  431. ASSERT((_pPapAddr)->papao_RefCount >= 1); \
  432. (_pPapAddr)->papao_RefCount++; \
  433. *(_pError) = ATALK_NO_ERROR; \
  434. } \
  435. else \
  436. { \
  437. *(_pError) = ATALK_PAP_ADDR_CLOSING; \
  438. } \
  439. if (ATALK_SUCCESS(*(_pError))) \
  440. { \
  441. DBGPRINT(DBG_COMP_PAP, DBG_LEVEL_REFPAPADDR, \
  442. ("RefAddr %lx at %s(%d) = %d\n", \
  443. _pPapAddr, __FILE__, __LINE__, \
  444. ((_pPapAddr)->papao_RefCount))); \
  445. } \
  446. }
  447. #define AtalkPapAddrReference(pPapAddr, pError) \
  448. { \
  449. KIRQL OldIrql; \
  450. \
  451. ACQUIRE_SPIN_LOCK(&(pPapAddr)->papao_Lock, &OldIrql); \
  452. AtalkPapAddrReferenceNonInterlock(pPapAddr, pError); \
  453. RELEASE_SPIN_LOCK(&(pPapAddr)->papao_Lock, OldIrql); \
  454. }
  455. #define AtalkPapAddrDereference(pPapAddr) \
  456. { \
  457. DBGPRINT(DBG_COMP_PAP, DBG_LEVEL_REFPAPADDR, \
  458. ("DerefAddr %lx at %s %d = %d\n", \
  459. pPapAddr, __FILE__, __LINE__, \
  460. ((pPapAddr)->papao_RefCount-1))); \
  461. atalkPapAddrDeref(pPapAddr); \
  462. }
  463. #define AtalkPapConnReferenceByPtr(pPapConn, pError) \
  464. { \
  465. KIRQL OldIrql; \
  466. \
  467. ACQUIRE_SPIN_LOCK(&(pPapConn)->papco_Lock, &OldIrql); \
  468. AtalkPapConnReferenceByPtrNonInterlock(pPapConn, pError); \
  469. RELEASE_SPIN_LOCK(&(pPapConn)->papco_Lock, OldIrql); \
  470. }
  471. #define AtalkPapConnReferenceByPtrDpc(pPapConn, pError) \
  472. { \
  473. ACQUIRE_SPIN_LOCK_DPC(&(pPapConn)->papco_Lock); \
  474. AtalkPapConnReferenceByPtrNonInterlock(pPapConn, pError); \
  475. RELEASE_SPIN_LOCK_DPC(&(pPapConn)->papco_Lock); \
  476. }
  477. #define AtalkPapConnReferenceByPtrNonInterlock(pPapConn, pError) \
  478. { \
  479. atalkPapConnRefByPtrNonInterlock(pPapConn, pError); \
  480. if (ATALK_SUCCESS(*pError)) \
  481. { \
  482. DBGPRINT(DBG_COMP_PAP, DBG_LEVEL_REFPAPCONN, \
  483. ("RefConn %lx at %s (%ld): + 1 = %ld\n", \
  484. pPapConn, __FILE__, __LINE__, \
  485. (pPapConn)->papco_RefCount)); \
  486. } \
  487. else \
  488. { \
  489. DBGPRINT(DBG_COMP_PAP, DBG_LEVEL_REFPAPCONN, \
  490. ("RefConn %lx at %s (%ld): FAILED, Flags %lx\n",\
  491. pPapConn, __FILE__, __LINE__, \
  492. (pPapConn)->papco_Flags)); \
  493. } \
  494. }
  495. #define AtalkPapConnReferenceByCtxNonInterlock(pPapAddr, Ctx, ppPapConn, pError) \
  496. { \
  497. atalkPapConnRefByCtxNonInterlock(pPapAddr, Ctx, ppPapConn, pError); \
  498. if (ATALK_SUCCESS(*pError)) \
  499. { \
  500. DBGPRINT(DBG_COMP_PAP, DBG_LEVEL_REFPAPCONN, \
  501. ("RefConnByCtx %lx at %s(%ld) = %ld\n", \
  502. *ppPapConn, __FILE__, __LINE__, \
  503. ((*ppPapConn)->papco_RefCount))); \
  504. } \
  505. }
  506. #define AtalkPapConnDereference(pPapConn) \
  507. { \
  508. DBGPRINT(DBG_COMP_PAP, DBG_LEVEL_REFPAPCONN, \
  509. ("DerefConn %lx at %s(%ld) = %ld\n", \
  510. pPapConn, __FILE__, __LINE__, \
  511. (pPapConn)->papco_RefCount-1)); \
  512. atalkPapConnDeref(pPapConn); \
  513. }
  514. #define AtalkPapGetDdpAddress(pPapAddr) \
  515. AtalkAtpGetDdpAddress((pPapAddr)->papao_pAtpAddr)
  516. #define PAPCONN_DDPSOCKET(pPapConn) \
  517. AtalkAtpGetDdpAddress((pPapConn)->papco_pAtpAddr)->ddpao_Addr.ata_Socket
  518. #define PAPADDR_DDPSOCKET(pPapAddr) \
  519. AtalkAtpGetDdpAddress((pPapAddr)->papao_pAtpAddr)->ddpao_Addr.ata_Socket
  520. // List of all pap address/connection objects.
  521. extern PPAP_ADDROBJ atalkPapAddrList;
  522. extern PPAP_CONNOBJ atalkPapConnList;
  523. extern TIMERLIST atalkPapCMTTimer;
  524. extern ATALK_SPIN_LOCK atalkPapLock;
  525. #define PAP_HASH_ID_ADDR(_id, _pAddr) \
  526. (((_pAddr)->ata_Node+((_pAddr)->ata_Network & 0xFF)+_id)%PAP_CONN_HASH_SIZE)
  527. LOCAL ATALK_ERROR
  528. atalkPapRepostConnect(
  529. IN PPAP_CONNOBJ pPapConn,
  530. IN PAMDL pOpenAmdl,
  531. IN PAMDL pRespAmdl
  532. );
  533. LOCAL VOID
  534. atalkPapSlsHandler(
  535. IN ATALK_ERROR ErrorCode,
  536. IN PPAP_ADDROBJ pPapAddr, // Listener (our context)
  537. IN PVOID RespContext, // CancelResp/PostResp will need this
  538. IN PATALK_ADDR pSrcAddr, // Address of requestor
  539. IN USHORT PktLen,
  540. IN PBYTE pPkt,
  541. IN PBYTE pUserBytes);
  542. LOCAL VOID
  543. atalkPapIncomingReadComplete(
  544. IN ATALK_ERROR ErrorCode,
  545. IN PPAP_CONNOBJ pPapConn, // Our context
  546. IN PAMDL pReqAmdl,
  547. IN PAMDL pReadAmdl,
  548. IN USHORT ReadLen,
  549. IN PBYTE ReadUserBytes);
  550. LOCAL VOID
  551. atalkPapPrimedReadComplete(
  552. IN ATALK_ERROR ErrorCode,
  553. IN PPAP_CONNOBJ pPapConn, // Our context
  554. IN PAMDL pReqAmdl,
  555. IN PAMDL pReadAmdl,
  556. IN USHORT ReadLen,
  557. IN PBYTE ReadUserBytes);
  558. LOCAL VOID
  559. atalkPapIncomingStatus(
  560. IN ATALK_ERROR ErrorCode,
  561. IN PACTREQ pActReq, // Our Ctx
  562. IN PAMDL pReqAmdl,
  563. IN PAMDL pStatusAmdl,
  564. IN USHORT StatusLen,
  565. IN PBYTE ReadUserBytes);
  566. LOCAL VOID
  567. atalkPapIncomingReq(
  568. IN ATALK_ERROR ErrorCode,
  569. IN PPAP_CONNOBJ pPapConn, // Connection (our context)
  570. IN PVOID RespContext, // CancelResp/PostResp will need this
  571. IN PATALK_ADDR pSrcAddr, // Address of requestor
  572. IN USHORT PktLen,
  573. IN PBYTE pPkt,
  574. IN PBYTE pUserBytes);
  575. LOCAL VOID
  576. atalkPapIncomingOpenReply(
  577. IN ATALK_ERROR ErrorCode,
  578. IN PPAP_CONNOBJ pPapConn, // Our context
  579. IN PAMDL pReqAmdl,
  580. IN PAMDL pReadAmdl,
  581. IN USHORT ReadLen,
  582. IN PBYTE ReadUserBytes);
  583. LOCAL VOID FASTCALL
  584. atalkPapIncomingRel(
  585. IN ATALK_ERROR ErrorCode,
  586. IN PPAP_OPEN_REPLY_REL pOpenReply);
  587. LOCAL VOID FASTCALL
  588. atalkPapStatusRel(
  589. IN ATALK_ERROR ErrorCode,
  590. IN PPAP_SEND_STATUS_REL pSendSts);
  591. LOCAL ATALK_ERROR FASTCALL
  592. atalkPapPostSendDataResp(
  593. IN PPAP_CONNOBJ pPapConn);
  594. LOCAL BOOLEAN
  595. atalkPapConnAccept(
  596. IN PPAP_ADDROBJ pPapAddr, // Listener
  597. IN PATALK_ADDR pSrcAddr, // Address of requestor
  598. IN PBYTE pPkt,
  599. IN BYTE ConnId,
  600. IN PATP_RESP pAtpResp);
  601. LOCAL LONG FASTCALL
  602. atalkPapConnMaintenanceTimer(
  603. IN PTIMERLIST pTimer,
  604. IN BOOLEAN TimerShuttingDown);
  605. LOCAL VOID FASTCALL
  606. atalkPapSendDataRel(
  607. IN ATALK_ERROR ErrorCode,
  608. IN PPAP_CONNOBJ pPapConn);
  609. LOCAL BYTE
  610. atalkPapGetNextConnId(
  611. IN PPAP_ADDROBJ pPapAddr,
  612. OUT PATALK_ERROR pError);
  613. LOCAL VOID
  614. atalkPapQueueAddrGlobalList(
  615. IN PPAP_ADDROBJ pPapAddr);
  616. LOCAL VOID
  617. atalkPapConnDeQueueAssocList(
  618. IN PPAP_ADDROBJ pPapAddr,
  619. IN PPAP_CONNOBJ pPapConn);
  620. LOCAL VOID
  621. atalkPapConnDeQueueConnectList(
  622. IN PPAP_ADDROBJ pPapAddr,
  623. IN PPAP_CONNOBJ pPapConn);
  624. LOCAL BOOLEAN
  625. atalkPapConnDeQueueListenList(
  626. IN PPAP_ADDROBJ pPapAddr,
  627. IN PPAP_CONNOBJ pPapConn);
  628. LOCAL VOID
  629. atalkPapConnDeQueueActiveList(
  630. IN PPAP_ADDROBJ pPapAddr,
  631. IN PPAP_CONNOBJ pPapConn);
  632. LOCAL VOID
  633. atalkPapConnRefByCtxNonInterlock(
  634. IN PPAP_ADDROBJ pPapAddr,
  635. IN CONNECTION_CONTEXT Ctx,
  636. OUT PPAP_CONNOBJ * pPapConn,
  637. OUT PATALK_ERROR pError);
  638. #endif // _PAP_
  639.