:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / drivers / net / tcpip / include / tcp.h
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 #ifndef __TCP_H
8 #define __TCP_H
9
10
11 /* TCPv4 header structure */
12 typedef struct TCP_HEADER {
13   USHORT SourcePort; /* Source port */
14   USHORT DestPort;   /* Destination port */
15   USHORT SeqNum;     /* Sequence number */
16   USHORT AckNum;     /* Acknowledgment number */
17   UCHAR  DataOfs;    /* Data offset (leftmost 4 bits) */
18   UCHAR  Flags;      /* Control bits (rightmost 6 bits) */
19   USHORT Window;     /* Maximum acceptable receive window */
20   USHORT Checksum;   /* Checksum of segment */
21   USHORT Urgent;     /* Pointer to urgent data */
22 } __attribute__((packed)) TCP_HEADER, *PTCP_HEADER;
23
24 /* TCPv4 header flags */
25 #define TCP_URG   0x04
26 #define TCP_ACK   0x08
27 #define TCP_PSH   0x10
28 #define TCP_RST   0x20
29 #define TCP_SYN   0x40
30 #define TCP_FIN   0x80
31
32
33 #define TCPOPT_END_OF_LIST  0x0
34 #define TCPOPT_NO_OPERATION 0x1
35 #define TCPOPT_MAX_SEG_SIZE 0x2
36
37 #define TCPOPTLEN_MAX_SEG_SIZE  0x4
38
39
40 /* TCPv4 pseudo header */
41 typedef struct TCP_PSEUDO_HEADER {
42   ULONG SourceAddress; /* Source address */
43   ULONG DestAddress;   /* Destination address */
44   UCHAR Zero;          /* Reserved */
45   UCHAR Protocol;      /* Protocol */
46   USHORT TCPLength;    /* Size of TCP segment */
47 } __attribute__((packed)) TCP_PSEUDO_HEADER, *PTCP_PSEUDO_HEADER;
48
49
50 /* Retransmission timeout constants */
51
52 /* Lower bound for retransmission timeout in TCP timer ticks */
53 #define TCP_MIN_RETRANSMISSION_TIMEOUT    1*1000          /* 1 tick */
54
55 /* Upper bound for retransmission timeout in TCP timer ticks */
56 #define TCP_MAX_RETRANSMISSION_TIMEOUT    1*60*1000       /* 1 tick */
57
58 /* Smoothing factor */
59 #define TCP_ALPHA_RETRANSMISSION_TIMEOUT(x)(((x)*8)/10)   /* 0.8 */
60
61 /* Delay variance factor */
62 #define TCP_BETA_RETRANSMISSION_TIMEOUT(x)(((x)*16)/10)   /* 1.6 */
63
64
65 /* Datagram/segment send request flags */
66
67 #define SRF_URG   TCP_URG
68 #define SRF_ACK   TCP_ACK
69 #define SRF_PSH   TCP_PSH
70 #define SRF_RST   TCP_RST
71 #define SRF_SYN   TCP_SYN
72 #define SRF_FIN   TCP_FIN
73
74
75 inline NTSTATUS TCPBuildSendRequest(
76     PTCP_SEND_REQUEST *SendRequest,
77     PDATAGRAM_SEND_REQUEST *DGSendRequest,
78     PCONNECTION_ENDPOINT Connection,
79     DATAGRAM_COMPLETION_ROUTINE Complete,
80     PVOID Context,
81     PNDIS_BUFFER Buffer,
82     DWORD BufferSize,
83     ULONG Flags);
84
85 inline NTSTATUS TCPBuildAndTransmitSendRequest(
86     PCONNECTION_ENDPOINT Connection,
87     DATAGRAM_COMPLETION_ROUTINE Complete,
88     PVOID Context,
89     PNDIS_BUFFER Buffer,
90     DWORD BufferSize,
91     ULONG Flags);
92
93 NTSTATUS TCPConnect(
94   PTDI_REQUEST Request,
95   PTDI_CONNECTION_INFORMATION ConnInfo,
96   PTDI_CONNECTION_INFORMATION ReturnInfo);
97
98 NTSTATUS TCPSendDatagram(
99   PTDI_REQUEST Request,
100   PTDI_CONNECTION_INFORMATION ConnInfo,
101   PNDIS_BUFFER Buffer,
102   ULONG DataSize);
103
104 NTSTATUS TCPStartup(
105   VOID);
106
107 NTSTATUS TCPShutdown(
108   VOID);
109
110 #endif /* __TCP_H */
111
112 /* EOF */