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.

152 lines
6.3 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990-2000 **/
  4. /********************************************************************/
  5. /* :ts=4 */
  6. //** TCPCONN.H - TCP connection related definitions.
  7. //
  8. // This file contains the definitions for connection related structures,
  9. // such as the TCPConnReq structure.
  10. //
  11. #define INVALID_CONN_INDEX 0xffffff
  12. //* Structure used for tracking Connect/Listen/Accept/Disconnect requests.
  13. #define tcr_signature 0x20524354 // 'TCR '
  14. typedef struct TCPConnReq {
  15. struct TCPReq tcr_req; // General request structure.
  16. #if DBG
  17. ulong tcr_sig;
  18. #endif
  19. struct _TDI_CONNECTION_INFORMATION *tcr_conninfo; // Where to return info.
  20. struct _TDI_CONNECTION_INFORMATION *tcr_addrinfo;
  21. ushort tcr_flags; // Flags for this request.
  22. ushort tcr_timeout; // Timeout value for this request.
  23. } TCPConnReq;
  24. #define TCR_FLAG_QUERY_ACCEPT 0x0001 // Consult client before accepting
  25. // connections.
  26. typedef void (*ConnDoneRtn)(struct TCPConn *, CTELockHandle);
  27. //* Structure of a TCB Connection. A TCP Connection points to a TCP and an
  28. // address object.
  29. #define MAX_CONN_PER_BLOCK 256
  30. // Structure of a ConnTable.
  31. typedef struct TCPConnBlock {
  32. DEFINE_LOCK_STRUCTURE(cb_lock)
  33. #if DBG
  34. uchar *module;
  35. uint line;
  36. #endif
  37. uint cb_freecons;
  38. uint cb_nextfree;
  39. uint cb_blockid;
  40. uint cb_conninst;
  41. void *cb_conn[MAX_CONN_PER_BLOCK];
  42. } TCPConnBlock;
  43. #define tc_signature 0x20204354 // 'TC '
  44. typedef struct TCPConn {
  45. #if DBG
  46. ulong tc_sig;
  47. #endif
  48. Queue tc_q; // Linkage on AO.
  49. struct TCB *tc_tcb; // Pointer to TCB for connection.
  50. struct AddrObj *tc_ao; // Back pointer to AddrObj.
  51. uchar tc_inst; // Instance number.
  52. uchar tc_flags; // Flags for connection.
  53. ushort tc_refcnt; // Count of TCBs which reference this connection.
  54. void *tc_context; // User's context.
  55. CTEReqCmpltRtn tc_rtn; // Completion routine.
  56. void *tc_rtncontext; // User context for completion routine.
  57. ConnDoneRtn tc_donertn; // Routine to call when refcnt goes to 0.
  58. uint tc_tcbflags; // Flags for TCB when it comes in.
  59. ulong tc_owningpid; // Owning process id
  60. uint tc_tcbkatime; // Initial keep alive time value for this conn.
  61. uint tc_tcbkainterval; // Keep alive interval for this conn.
  62. uint tc_window; // Default window for TCB.
  63. struct TCB *tc_LastTCB;
  64. TCPConnBlock *tc_ConnBlock; //Back pointer to the conn block
  65. uint tc_connid;
  66. } TCPConn;
  67. #define CONN_CLOSING 1 // Connection is closing.
  68. #define CONN_DISACC 2 // Conn. is disassociating.
  69. #define CONN_WINSET 4 // Window explictly set.
  70. #define CONN_INVALID (CONN_CLOSING | CONN_DISACC)
  71. #define CONN_INDEX(c) ((c) & 0xff)
  72. #define CONN_BLOCKID(c) (((c) & 0xffff00) >> 8 )
  73. #define CONN_INST(c) ((uchar)((c) >> 24))
  74. #define MAKE_CONN_ID(index,block,instance) ((((uint)(instance)) << 24) | (((uint)(block)) << 8) | ((uint)(index)))
  75. #define INVALID_CONN_ID 0xffffffff
  76. #define DEFAULT_CONN_BLOCKS 2;
  77. typedef struct TCPAddrCheck {
  78. IPAddr SourceAddress;
  79. uint TickCount;
  80. } TCPAddrCheckElement;
  81. extern TCPAddrCheckElement *AddrCheckTable;
  82. //* External definitions for TDI entry points.
  83. extern TDI_STATUS TdiOpenConnection(PTDI_REQUEST Request, PVOID Context);
  84. extern TDI_STATUS TdiCloseConnection(PTDI_REQUEST Request);
  85. extern TDI_STATUS TdiAssociateAddress(PTDI_REQUEST Request, HANDLE AddrHandle);
  86. extern TDI_STATUS TdiDisAssociateAddress(PTDI_REQUEST Request);
  87. extern TDI_STATUS TdiConnect(PTDI_REQUEST Request, void *Timeout,
  88. PTDI_CONNECTION_INFORMATION RequestAddr,
  89. PTDI_CONNECTION_INFORMATION ReturnAddr);
  90. extern TDI_STATUS TdiListen(PTDI_REQUEST Request, ushort Flags,
  91. PTDI_CONNECTION_INFORMATION AcceptableAddr,
  92. PTDI_CONNECTION_INFORMATION ConnectedAddr);
  93. extern TDI_STATUS TdiAccept(PTDI_REQUEST Request,
  94. PTDI_CONNECTION_INFORMATION AcceptInfo,
  95. PTDI_CONNECTION_INFORMATION ConnectedInfo);
  96. extern TDI_STATUS TdiDisconnect(PTDI_REQUEST Request, void *TO, ushort Flags,
  97. PTDI_CONNECTION_INFORMATION DiscConnInfo,
  98. PTDI_CONNECTION_INFORMATION ReturnInfo);
  99. extern void FreeConn(TCPConn *Conn);
  100. extern TCPConn *GetConn(void);
  101. extern struct TCPConnReq *GetConnReq(void);
  102. extern void FreeConnReq(struct TCPConnReq *FreedReq);
  103. extern void DerefTCB(struct TCB *DoneTCB, CTELockHandle Handle);
  104. extern void DerefSynTCB(struct SYNTCB *DoneTCB, CTELockHandle Handle);
  105. extern void InitRCE(struct TCB *NewTCB);
  106. extern void AcceptConn(struct TCB *AcceptTCB, CTELockHandle Handle);
  107. extern void FreeConnID(TCPConn *Conn);
  108. extern void NotifyOfDisc(struct TCB *DiscTCB, struct IPOptInfo *DiscInfo,
  109. TDI_STATUS Status);
  110. extern TCPConn *GetConnFromConnID(uint ConnID, CTELockHandle *Handle);
  111. extern void TryToCloseTCB(struct TCB *ClosedTCB, uchar Reason,
  112. CTELockHandle Handle);
  113. extern TDI_STATUS InitTCBFromConn(struct TCPConn *Conn, struct TCB *NewTCB,
  114. PTDI_CONNECTION_INFORMATION Addr, uint AOLocked);
  115. extern void PushData(struct TCB *PushTCB);
  116. extern TDI_STATUS MapIPError(IP_STATUS IPError, TDI_STATUS Default);
  117. extern void GracefulClose(struct TCB *CloseTCB, uint ToTimeWait, uint Notify,
  118. CTELockHandle Handle);
  119. extern void RemoveTCBFromConn(struct TCB *RemovedTCB);
  120. extern void InitAddrChecks();
  121. extern int ConnCheckPassed(IPAddr Src, ulong Prt);
  122. extern void EnumerateConnectionList(uchar *Buffer, ulong BufferSize,
  123. ulong *EntriesReturned, ulong *EntriesAvailable);
  124. extern void ValidateMSS(TCB* MssTCB);