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.

168 lines
7.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. //* Structure used for tracking abortive-disconnect requests.
  27. typedef struct TCPAbortReq {
  28. CTEReqCmpltRtn tar_rtn; // Completion routine.
  29. PVOID tar_context; // User context.
  30. } TCPAbortReq;
  31. #define MAX_CONN_PER_BLOCK 256
  32. //* Structure of a ConnTable.
  33. typedef struct TCPConnBlock {
  34. DEFINE_LOCK_STRUCTURE(cb_lock)
  35. #if DBG
  36. uchar *module;
  37. uint line;
  38. #endif
  39. uint cb_freecons;
  40. uint cb_nextfree;
  41. uint cb_blockid;
  42. uint cb_conninst;
  43. void *cb_conn[MAX_CONN_PER_BLOCK];
  44. } TCPConnBlock;
  45. //* Structure of a TCB Connection. A TCP Connection points to a TCP and an
  46. // address object.
  47. typedef void (*ConnDoneRtn)(struct TCPConn *, CTELockHandle);
  48. #define tc_signature 0x20204354 // 'TC '
  49. typedef struct TCPConn {
  50. #if DBG
  51. ulong tc_sig;
  52. #endif
  53. Queue tc_q; // Linkage on AO.
  54. struct TCB *tc_tcb; // Pointer to TCB for connection.
  55. struct AddrObj *tc_ao; // Back pointer to AddrObj.
  56. uchar tc_inst; // Instance number.
  57. uchar tc_flags; // Flags for connection.
  58. ushort tc_refcnt; // Count of TCBs which reference this connection.
  59. void *tc_context; // User's context.
  60. CTEReqCmpltRtn tc_rtn; // Completion routine.
  61. void *tc_rtncontext; // User context for completion routine.
  62. ConnDoneRtn tc_donertn; // Routine to call when refcnt goes to 0.
  63. uint tc_tcbflags; // Flags for TCB when it comes in.
  64. ulong tc_owningpid; // Owning process id
  65. uint tc_tcbkatime; // Initial keep alive time value for this conn.
  66. uint tc_tcbkainterval; // Keep alive interval for this conn.
  67. uint tc_window; // Default window for TCB.
  68. struct TCB *tc_LastTCB;
  69. TCPConnBlock *tc_ConnBlock; //Back pointer to the conn block
  70. uint tc_connid;
  71. } TCPConn;
  72. #define CONN_CLOSING 1 // Connection is closing.
  73. #define CONN_DISACC 2 // Conn. is disassociating.
  74. #define CONN_WINSET 4 // Window explictly set.
  75. #define CONN_WINCFG 8 // Window read from configuration.
  76. #define CONN_INVALID (CONN_CLOSING | CONN_DISACC)
  77. #define CONN_INDEX(c) ((c) & 0xff)
  78. #define CONN_BLOCKID(c) (((c) & 0xffff00) >> 8 )
  79. #define CONN_INST(c) ((uchar)((c) >> 24))
  80. #define MAKE_CONN_ID(index,block,instance) ((((uint)(instance)) << 24) | (((uint)(block)) << 8) | ((uint)(index)))
  81. #define INVALID_CONN_ID 0xffffffff
  82. #define DEFAULT_CONN_BLOCKS 2;
  83. typedef struct TCPAddrCheck {
  84. IPAddr SourceAddress;
  85. uint TickCount;
  86. } TCPAddrCheckElement;
  87. extern TCPAddrCheckElement *AddrCheckTable;
  88. //* External definitions for TDI entry points.
  89. extern TDI_STATUS TdiOpenConnection(PTDI_REQUEST Request, PVOID Context);
  90. extern TDI_STATUS TdiCloseConnection(PTDI_REQUEST Request);
  91. extern TDI_STATUS TdiAssociateAddress(PTDI_REQUEST Request, HANDLE AddrHandle);
  92. extern TDI_STATUS TdiDisAssociateAddress(PTDI_REQUEST Request);
  93. extern TDI_STATUS TdiConnect(PTDI_REQUEST Request, void *Timeout,
  94. PTDI_CONNECTION_INFORMATION RequestAddr,
  95. PTDI_CONNECTION_INFORMATION ReturnAddr);
  96. extern TDI_STATUS TdiListen(PTDI_REQUEST Request, ushort Flags,
  97. PTDI_CONNECTION_INFORMATION AcceptableAddr,
  98. PTDI_CONNECTION_INFORMATION ConnectedAddr);
  99. extern TDI_STATUS TdiAccept(PTDI_REQUEST Request,
  100. PTDI_CONNECTION_INFORMATION AcceptInfo,
  101. PTDI_CONNECTION_INFORMATION ConnectedInfo);
  102. extern TDI_STATUS TdiDisconnect(PTDI_REQUEST Request, void *TO, ushort Flags,
  103. PTDI_CONNECTION_INFORMATION DiscConnInfo,
  104. PTDI_CONNECTION_INFORMATION ReturnInfo,
  105. TCPAbortReq *AbortReq);
  106. extern TDI_STATUS UDPConnect(PTDI_REQUEST Request, void *Timeout,
  107. PTDI_CONNECTION_INFORMATION RequestAddr,
  108. PTDI_CONNECTION_INFORMATION ReturnAddr);
  109. extern TDI_STATUS UDPDisconnect(PTDI_REQUEST Request, void *TO,
  110. PTDI_CONNECTION_INFORMATION DiscConnInfo,
  111. PTDI_CONNECTION_INFORMATION ReturnInfo);
  112. extern void FreeConn(TCPConn *Conn);
  113. extern TCPConn *GetConn(void);
  114. extern struct TCPConnReq *GetConnReq(void);
  115. extern void FreeConnReq(struct TCPConnReq *FreedReq);
  116. extern void DerefTCB(struct TCB *DoneTCB, CTELockHandle Handle);
  117. extern void DerefSynTCB(struct SYNTCB *DoneTCB, CTELockHandle Handle);
  118. extern void InitRCE(struct TCB *NewTCB);
  119. extern void AcceptConn(struct TCB *AcceptTCB, BOOLEAN SYNSent,
  120. CTELockHandle Handle);
  121. extern void FreeConnID(TCPConn *Conn);
  122. extern void NotifyOfDisc(struct TCB *DiscTCB, struct IPOptInfo *DiscInfo,
  123. TDI_STATUS Status, CTELockHandle* Handle);
  124. extern TCPConn *GetConnFromConnID(uint ConnID, CTELockHandle *Handle);
  125. extern void TryToCloseTCB(struct TCB *ClosedTCB, uchar Reason,
  126. CTELockHandle Handle);
  127. extern TDI_STATUS InitTCBFromConn(struct TCPConn *Conn, struct TCB *NewTCB,
  128. PTDI_CONNECTION_INFORMATION Addr, uint AOLocked);
  129. extern void PushData(struct TCB *PushTCB, BOOLEAN PushAll);
  130. extern TDI_STATUS MapIPError(IP_STATUS IPError, TDI_STATUS Default);
  131. extern void GracefulClose(struct TCB *CloseTCB, uint ToTimeWait, uint Notify,
  132. CTELockHandle Handle);
  133. extern void RemoveTCBFromConn(struct TCB *RemovedTCB);
  134. extern void InitAddrChecks();
  135. extern int ConnCheckPassed(IPAddr Src, ulong Prt);
  136. extern void EnumerateConnectionList(uchar *Buffer, ulong BufferSize,
  137. ulong *EntriesReturned, ulong *EntriesAvailable);
  138. extern void ValidateMSS(TCB* MssTCB);
  139. extern void AdjustTCBFromRCE(TCB* RceTCB);