2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
5 * PURPOSE: Transmission Control Protocol definitions
11 (*PTCP_COMPLETION_ROUTINE
)( PVOID Context
, NTSTATUS Status
, ULONG Count
);
13 /* TCPv4 header structure */
15 typedef struct TCPv4_HEADER
{
16 USHORT SourcePort
; /* Source port */
17 USHORT DestinationPort
; /* Destination port */
18 ULONG SequenceNumber
; /* Sequence number */
19 ULONG AckNumber
; /* Acknowledgement number */
20 UCHAR DataOffset
; /* Data offset; 32-bit words (leftmost 4 bits) */
21 UCHAR Flags
; /* Control bits (rightmost 6 bits) */
22 USHORT Window
; /* Maximum acceptable receive window */
23 USHORT Checksum
; /* Checksum of segment */
24 USHORT Urgent
; /* Pointer to urgent data */
25 } TCPv4_HEADER
, *PTCPv4_HEADER
;
27 #define TCPOPT_END_OF_LIST 0x0
28 #define TCPOPT_NO_OPERATION 0x1
29 #define TCPOPT_MAX_SEG_SIZE 0x2
31 #define TCPOPTLEN_MAX_SEG_SIZE 0x4
33 /* Data offset; 32-bit words (leftmost 4 bits); convert to bytes */
34 #define TCP_DATA_OFFSET(DataOffset)(((DataOffset) & 0xF0) >> (4-2))
37 /* TCPv4 pseudo header */
38 typedef struct TCPv4_PSEUDO_HEADER
{
39 ULONG SourceAddress
; /* Source address */
40 ULONG DestinationAddress
; /* Destination address */
41 UCHAR Zero
; /* Reserved */
42 UCHAR Protocol
; /* Protocol */
43 USHORT TCPLength
; /* Size of TCP segment */
44 } TCPv4_PSEUDO_HEADER
, *PTCPv4_PSEUDO_HEADER
;
47 typedef struct _SLEEPING_THREAD
{
51 } SLEEPING_THREAD
, *PSLEEPING_THREAD
;
53 typedef struct _CLIENT_DATA
{
57 } CLIENT_DATA
, *PCLIENT_DATA
;
59 /* Retransmission timeout constants */
61 /* Lower bound for retransmission timeout in TCP timer ticks */
62 #define TCP_MIN_RETRANSMISSION_TIMEOUT 1*1000 /* 1 tick */
64 /* Upper bound for retransmission timeout in TCP timer ticks */
65 #define TCP_MAX_RETRANSMISSION_TIMEOUT 1*60*1000 /* 1 tick */
67 /* Smoothing factor */
68 #define TCP_ALPHA_RETRANSMISSION_TIMEOUT(x)(((x)*8)/10) /* 0.8 */
70 /* Delay variance factor */
71 #define TCP_BETA_RETRANSMISSION_TIMEOUT(x)(((x)*16)/10) /* 1.6 */
82 #define SEL_FINOUT 512
87 /* Datagram/segment send request flags */
89 #define SRF_URG TCP_URG
90 #define SRF_ACK TCP_ACK
91 #define SRF_PSH TCP_PSH
92 #define SRF_RST TCP_RST
93 #define SRF_SYN TCP_SYN
94 #define SRF_FIN TCP_FIN
96 extern LONG TCP_IPIdentification
;
97 extern CLIENT_DATA ClientInfo
;
100 NTSTATUS
TCPCheckPeerForAccept(PVOID Context
,
101 PTDI_REQUEST_KERNEL Request
);
102 NTSTATUS
TCPListen( PCONNECTION_ENDPOINT Connection
, UINT Backlog
);
103 BOOLEAN
TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener
,
104 PCONNECTION_ENDPOINT Connection
);
106 ( PTDI_REQUEST Request
,
107 PCONNECTION_ENDPOINT Listener
,
108 PCONNECTION_ENDPOINT Connection
,
109 PTCP_COMPLETION_ROUTINE Complete
,
113 PCONNECTION_ENDPOINT
TCPAllocateConnectionEndpoint( PVOID ClientContext
);
114 VOID
TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection
);
116 NTSTATUS
TCPSocket( PCONNECTION_ENDPOINT Connection
,
117 UINT Family
, UINT Type
, UINT Proto
);
119 VOID
HandleSignalledConnection(PCONNECTION_ENDPOINT Connection
);
121 PTCP_SEGMENT
TCPCreateSegment(
123 PTCPv4_HEADER TCPHeader
,
124 ULONG SegmentLength
);
127 PTCP_SEGMENT Segment
);
130 PCONNECTION_ENDPOINT Connection
,
131 PTCP_SEGMENT Segment
,
132 PULONG Acknowledged
);
135 PCONNECTION_ENDPOINT Connection
,
136 PTDI_CONNECTION_INFORMATION ConnInfo
,
137 PTDI_CONNECTION_INFORMATION ReturnInfo
,
138 PTCP_COMPLETION_ROUTINE Complete
,
141 NTSTATUS
TCPDisconnect(
142 PCONNECTION_ENDPOINT Connection
,
144 PLARGE_INTEGER Timeout
,
145 PTDI_CONNECTION_INFORMATION ConnInfo
,
146 PTDI_CONNECTION_INFORMATION ReturnInfo
,
147 PTCP_COMPLETION_ROUTINE Complete
,
150 NTSTATUS
TCPReceiveData(
151 PCONNECTION_ENDPOINT Connection
,
154 PULONG BytesReceived
,
156 PTCP_COMPLETION_ROUTINE Complete
,
159 NTSTATUS
TCPSendData(
160 PCONNECTION_ENDPOINT Connection
,
165 PTCP_COMPLETION_ROUTINE Complete
,
168 NTSTATUS
TCPClose( PCONNECTION_ENDPOINT Connection
);
170 NTSTATUS
TCPTranslateError( const INT8 err
);
172 UINT
TCPAllocatePort( const UINT HintPort
);
174 VOID
TCPFreePort( const UINT Port
);
176 NTSTATUS TCPGetSockAddress
177 ( PCONNECTION_ENDPOINT Connection
,
178 PTRANSPORT_ADDRESS TransportAddress
,
179 BOOLEAN RemoteAddress
);
184 NTSTATUS
TCPShutdown(
187 BOOLEAN
TCPRemoveIRP( PCONNECTION_ENDPOINT Connection
, PIRP Irp
);
190 TCPUpdateInterfaceLinkStatus(PIP_INTERFACE IF
);
193 TCPUpdateInterfaceIPInformation(PIP_INTERFACE IF
);
196 FlushListenQueue(PCONNECTION_ENDPOINT Connection
, const NTSTATUS Status
);
199 FlushConnectQueue(PCONNECTION_ENDPOINT Connection
, const NTSTATUS Status
);
202 FlushReceiveQueue(PCONNECTION_ENDPOINT Connection
, const NTSTATUS Status
, const BOOLEAN interlocked
);
205 FlushSendQueue(PCONNECTION_ENDPOINT Connection
, const NTSTATUS Status
, const BOOLEAN interlocked
);
208 FlushShutdownQueue(PCONNECTION_ENDPOINT Connection
, const NTSTATUS Status
, const BOOLEAN interlocked
);
211 FlushAllQueues(PCONNECTION_ENDPOINT Connection
, NTSTATUS Status
);
213 VOID
CompleteBucket(PCONNECTION_ENDPOINT Connection
, PTDI_BUCKET Bucket
, const BOOLEAN Synchronous
);
216 LibTCPDumpPcb(PVOID SocketContext
);