]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Option.h
1 /** @file
2 Tcp option's routine header file.
3
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php<BR>
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _TCP4_OPTION_H_
16 #define _TCP4_OPTION_H_
17
18 ///
19 /// The structure to store the parse option value.
20 /// ParseOption only parse the options, don't process them.
21 ///
22 typedef struct _TCP_OPTION {
23 UINT8 Flag; ///< Flag such as TCP_OPTION_RCVD_MSS
24 UINT8 WndScale; ///< The WndScale received
25 UINT16 Mss; ///< The Mss received
26 UINT32 TSVal; ///< The TSVal field in a timestamp option
27 UINT32 TSEcr; ///< The TSEcr field in a timestamp option
28 } TCP_OPTION;
29
30 //
31 // supported TCP option type and their length
32 //
33 #define TCP_OPTION_EOP 0 ///< End Of oPtion
34 #define TCP_OPTION_NOP 1 ///< No-Option.
35 #define TCP_OPTION_MSS 2 ///< Maximum Segment Size
36 #define TCP_OPTION_WS 3 ///< Window scale
37 #define TCP_OPTION_TS 8 ///< Timestamp
38 #define TCP_OPTION_MSS_LEN 4 ///< Length of MSS option
39 #define TCP_OPTION_WS_LEN 3 ///< Length of window scale option
40 #define TCP_OPTION_TS_LEN 10 ///< Length of timestamp option
41 #define TCP_OPTION_WS_ALIGNED_LEN 4 ///< Length of window scale option, aligned
42 #define TCP_OPTION_TS_ALIGNED_LEN 12 ///< Length of timestamp option, aligned
43
44 //
45 // recommend format of timestamp window scale
46 // option for fast process.
47 //
48 #define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \
49 (TCP_OPTION_NOP << 16) | \
50 (TCP_OPTION_TS << 8) | \
51 (TCP_OPTION_TS_LEN))
52
53 #define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \
54 (TCP_OPTION_WS << 16) | \
55 (TCP_OPTION_WS_LEN << 8))
56
57 #define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16))
58
59 //
60 // Other misc definations
61 //
62 #define TCP_OPTION_RCVD_MSS 0x01
63 #define TCP_OPTION_RCVD_WS 0x02
64 #define TCP_OPTION_RCVD_TS 0x04
65 #define TCP_OPTION_MAX_WS 14 ///< Maxium window scale value
66 #define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header
67
68
69 /**
70 Compute the window scale value according to the given buffer size.
71
72 @param Tcb Pointer to the TCP_CB of this TCP instance.
73
74 @return The scale value.
75
76 **/
77 UINT8
78 TcpComputeScale (
79 IN TCP_CB *Tcb
80 );
81
82 /**
83 Build the TCP option in three-way handshake.
84
85 @param Tcb Pointer to the TCP_CB of this TCP instance.
86 @param Nbuf Pointer to the buffer to store the options.
87
88 @return The total length of the TCP option field.
89
90 **/
91 UINT16
92 TcpSynBuildOption (
93 IN TCP_CB *Tcb,
94 IN NET_BUF *Nbuf
95 );
96
97 /**
98 Build the TCP option in synchronized states.
99
100 @param Tcb Pointer to the TCP_CB of this TCP instance.
101 @param Nbuf Pointer to the buffer to store the options.
102
103 @return The total length of the TCP option field.
104
105 **/
106 UINT16
107 TcpBuildOption (
108 IN TCP_CB *Tcb,
109 IN NET_BUF *Nbuf
110 );
111
112 /**
113 Parse the supported options.
114
115 @param Tcp Pointer to the TCP_CB of this TCP instance.
116 @param Option Pointer to the TCP_OPTION used to store the successfully pasrsed
117 options.
118
119 @retval 0 The options are successfully pasrsed.
120 @retval -1 Ilegal option was found.
121
122 **/
123 INTN
124 TcpParseOption (
125 IN TCP_HEAD *Tcp,
126 IN OUT TCP_OPTION *Option
127 );
128
129 /**
130 Check the segment against PAWS.
131
132 @param Tcb Pointer to the TCP_CB of this TCP instance.
133 @param TSVal The timestamp value.
134
135 @retval 1 The segment passed the PAWS check.
136 @retval 0 The segment failed to pass the PAWS check.
137
138 **/
139 UINT32
140 TcpPawsOK (
141 IN TCP_CB *Tcb,
142 IN UINT32 TSVal
143 );
144
145 #endif