ReactOS 0.4.15-dev-7934-g1dc8d80
tcp.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: include/tcp.h
5 * PURPOSE: Transmission Control Protocol definitions
6 */
7
8#pragma once
9
10typedef VOID
12
13/* TCPv4 header structure */
14#include <pshpack1.h>
15typedef 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 */
26
27#define TCPOPT_END_OF_LIST 0x0
28#define TCPOPT_NO_OPERATION 0x1
29#define TCPOPT_MAX_SEG_SIZE 0x2
30
31#define TCPOPTLEN_MAX_SEG_SIZE 0x4
32
33/* Data offset; 32-bit words (leftmost 4 bits); convert to bytes */
34#define TCP_DATA_OFFSET(DataOffset)(((DataOffset) & 0xF0) >> (4-2))
35
36
37/* TCPv4 pseudo header */
38typedef 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 */
45#include <poppack.h>
46
47typedef struct _SLEEPING_THREAD {
52
53typedef struct _CLIENT_DATA {
58
59/* Retransmission timeout constants */
60
61/* Lower bound for retransmission timeout in TCP timer ticks */
62#define TCP_MIN_RETRANSMISSION_TIMEOUT 1*1000 /* 1 tick */
63
64/* Upper bound for retransmission timeout in TCP timer ticks */
65#define TCP_MAX_RETRANSMISSION_TIMEOUT 1*60*1000 /* 1 tick */
66
67/* Smoothing factor */
68#define TCP_ALPHA_RETRANSMISSION_TIMEOUT(x)(((x)*8)/10) /* 0.8 */
69
70/* Delay variance factor */
71#define TCP_BETA_RETRANSMISSION_TIMEOUT(x)(((x)*16)/10) /* 1.6 */
72
73#define SEL_CONNECT 1
74#define SEL_FIN 2
75#define SEL_RST 4
76#define SEL_ABRT 8
77#define SEL_READ 16
78#define SEL_WRITE 32
79#define SEL_ACCEPT 64
80#define SEL_OOB 128
81#define SEL_ERROR 256
82#define SEL_FINOUT 512
83
84#define FREAD 0x0001
85#define FWRITE 0x0002
86
87/* Datagram/segment send request flags */
88
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
95
98
99/* accept.c */
102NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog );
104 PCONNECTION_ENDPOINT Connection );
107 PCONNECTION_ENDPOINT Listener,
108 PCONNECTION_ENDPOINT Connection,
110 PVOID Context );
111
112/* tcp.c */
115
117 UINT Family, UINT Type, UINT Proto );
118
120
122 PIP_PACKET IPPacket,
124 ULONG SegmentLength);
125
128
130 PCONNECTION_ENDPOINT Connection,
132 PULONG Acknowledged);
133
135 PCONNECTION_ENDPOINT Connection,
139 PVOID Context);
140
142 PCONNECTION_ENDPOINT Connection,
143 UINT Flags,
148 PVOID Context);
149
151 PCONNECTION_ENDPOINT Connection,
153 ULONG ReceiveLength,
154 PULONG BytesReceived,
155 ULONG ReceiveFlags,
157 PVOID Context);
158
160 PCONNECTION_ENDPOINT Connection,
163 PULONG DataUsed,
164 ULONG Flags,
166 PVOID Context);
167
169
171
172UINT TCPAllocatePort( const UINT HintPort );
173
174VOID TCPFreePort( const UINT Port );
175
177( PCONNECTION_ENDPOINT Connection,
178 PTRANSPORT_ADDRESS TransportAddress,
180
182 VOID);
183
185 VOID);
186
188
190
191VOID
193
194VOID
196
197VOID
199
200VOID
202
203VOID
205
206VOID
208
209VOID
211
212VOID
214
215VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, const BOOLEAN Synchronous);
216
217void
219
unsigned char BOOLEAN
signed char INT8
Type
Definition: Type.h:7
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
pRequest Complete(RequestStatus)
Status
Definition: gdiplustypes.h:25
CPPORT Port[4]
Definition: headless.c:35
BOOLEAN TCPRemoveIRP(PCONNECTION_ENDPOINT Connection, PIRP Irp)
Definition: tcp.c:695
NTSTATUS TCPGetSocketStatus(PCONNECTION_ENDPOINT Connection, PULONG State)
Definition: tcp.c:749
VOID TCPFreeSegment(PTCP_SEGMENT Segment)
CLIENT_DATA ClientInfo
VOID FlushConnectQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
Definition: event.c:116
LONG TCP_IPIdentification
Definition: tcp.c:15
NTSTATUS TCPSendData(PCONNECTION_ENDPOINT Connection, PCHAR Buffer, ULONG DataSize, PULONG DataUsed, ULONG Flags, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:580
BOOLEAN TCPAbortListenForSocket(PCONNECTION_ENDPOINT Listener, PCONNECTION_ENDPOINT Connection)
Definition: accept.c:108
VOID TCPUpdateInterfaceIPInformation(PIP_INTERFACE IF)
Definition: if.c:144
void LibTCPDumpPcb(PVOID SocketContext)
Definition: tcp.c:36
VOID TCPUpdateInterfaceLinkStatus(PIP_INTERFACE IF)
Definition: if.c:82
VOID TCPAddSegment(PCONNECTION_ENDPOINT Connection, PTCP_SEGMENT Segment, PULONG Acknowledged)
NTSTATUS TCPSocket(PCONNECTION_ENDPOINT Connection, UINT Family, UINT Type, UINT Proto)
Definition: tcp.c:153
NTSTATUS TCPCheckPeerForAccept(PVOID Context, PTDI_REQUEST_KERNEL Request)
Definition: accept.c:17
VOID FlushShutdownQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
Definition: event.c:95
VOID FlushListenQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
Definition: event.c:136
NTSTATUS TCPShutdown(VOID)
Definition: tcp.c:243
NTSTATUS TCPListen(PCONNECTION_ENDPOINT Connection, UINT Backlog)
Definition: accept.c:47
VOID HandleSignalledConnection(PCONNECTION_ENDPOINT Connection)
VOID CompleteBucket(PCONNECTION_ENDPOINT Connection, PTDI_BUCKET Bucket, const BOOLEAN Synchronous)
Definition: event.c:38
NTSTATUS TCPAccept(PTDI_REQUEST Request, PCONNECTION_ENDPOINT Listener, PCONNECTION_ENDPOINT Connection, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: accept.c:139
NTSTATUS TCPTranslateError(const INT8 err)
Definition: tcp.c:267
VOID FlushReceiveQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
Definition: event.c:53
NTSTATUS TCPDisconnect(PCONNECTION_ENDPOINT Connection, UINT Flags, PLARGE_INTEGER Timeout, PTDI_CONNECTION_INFORMATION ConnInfo, PTDI_CONNECTION_INFORMATION ReturnInfo, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:427
VOID TCPFreePort(const UINT Port)
Definition: tcp.c:652
struct _CLIENT_DATA CLIENT_DATA
NTSTATUS TCPConnect(PCONNECTION_ENDPOINT Connection, PTDI_CONNECTION_INFORMATION ConnInfo, PTDI_CONNECTION_INFORMATION ReturnInfo, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:302
struct _CLIENT_DATA * PCLIENT_DATA
VOID(* PTCP_COMPLETION_ROUTINE)(PVOID Context, NTSTATUS Status, ULONG Count)
Definition: tcp.h:11
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint(PVOID ClientContext)
Definition: tcp.c:107
UINT TCPAllocatePort(const UINT HintPort)
Definition: tcp.c:636
NTSTATUS TCPReceiveData(PCONNECTION_ENDPOINT Connection, PNDIS_BUFFER Buffer, ULONG ReceiveLength, PULONG BytesReceived, ULONG ReceiveFlags, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
Definition: tcp.c:529
NTSTATUS TCPGetSockAddress(PCONNECTION_ENDPOINT Connection, PTRANSPORT_ADDRESS TransportAddress, BOOLEAN RemoteAddress)
Definition: tcp.c:658
struct _SLEEPING_THREAD SLEEPING_THREAD
NTSTATUS TCPStartup(VOID)
Definition: tcp.c:208
NTSTATUS TCPSetNoDelay(PCONNECTION_ENDPOINT Connection, BOOLEAN Set)
Definition: tcp.c:734
struct TCPv4_PSEUDO_HEADER * PTCPv4_PSEUDO_HEADER
VOID TCPFreeConnectionEndpoint(PCONNECTION_ENDPOINT Connection)
VOID FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status)
Definition: event.c:157
struct _SLEEPING_THREAD * PSLEEPING_THREAD
PTCP_SEGMENT TCPCreateSegment(PIP_PACKET IPPacket, PTCPv4_HEADER TCPHeader, ULONG SegmentLength)
NTSTATUS TCPClose(PCONNECTION_ENDPOINT Connection)
Definition: tcp.c:177
struct TCPv4_HEADER * PTCPv4_HEADER
VOID FlushSendQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status)
Definition: event.c:74
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
unsigned int UINT
Definition: ndis.h:50
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_In_ PVOID ClientContext
Definition: netioddk.h:55
int Count
Definition: noreturn.cpp:7
static BOOL Set
Definition: pageheap.c:10
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
static int Family
Definition: ping.c:62
#define err(...)
UCHAR Flags
Definition: eth.h:47
USHORT Window
Definition: eth.h:48
USHORT Checksum
Definition: eth.h:49
USHORT Urgent
Definition: eth.h:50
USHORT SourcePort
Definition: eth.h:42
USHORT DestinationPort
Definition: eth.h:43
ULONG AckNumber
Definition: eth.h:45
ULONG SequenceNumber
Definition: eth.h:44
UCHAR DataOffset
Definition: eth.h:46
UCHAR Protocol
Definition: tcp.h:42
ULONG DestinationAddress
Definition: tcp.h:40
ULONG SourceAddress
Definition: tcp.h:39
UCHAR Zero
Definition: tcp.h:41
USHORT TCPLength
Definition: tcp.h:43
BOOLEAN Unlocked
Definition: tcp.h:54
KSPIN_LOCK Lock
Definition: tcp.h:55
KIRQL OldIrql
Definition: tcp.h:56
Definition: ip.h:77
Definition: typedefs.h:120
PVOID SleepToken
Definition: tcp.h:49
LIST_ENTRY Entry
Definition: tcp.h:48
KEVENT Event
Definition: tcp.h:50
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID SocketContext
Definition: wsk.h:187
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR RemoteAddress
Definition: wsk.h:172
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
unsigned char UCHAR
Definition: xmlstorage.h:181