]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
243def839aa1fbcc5c3ef0f2c47125bb8f93a607
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Option.h
1 /** @file
2 Tcp option's routine header file.
3
4 Copyright (c) 2005 - 2006, Intel Corporation<BR>
5 All rights reserved. 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 typedef enum {
31
32 //
33 // supported TCP option type and their length
34 //
35 TCP_OPTION_EOP = 0, ///< End Of oPtion
36 TCP_OPTION_NOP = 1, ///< No-Option.
37 TCP_OPTION_MSS = 2, ///< Maximum Segment Size
38 TCP_OPTION_WS = 3, ///< Window scale
39 TCP_OPTION_TS = 8, ///< Timestamp
40 TCP_OPTION_MSS_LEN = 4, ///< Length of MSS option
41 TCP_OPTION_WS_LEN = 3, ///< Length of window scale option
42 TCP_OPTION_TS_LEN = 10, ///< Length of timestamp option
43 TCP_OPTION_WS_ALIGNED_LEN = 4, ///< Length of window scale option, aligned
44 TCP_OPTION_TS_ALIGNED_LEN = 12, ///< Length of timestamp option, aligned
45
46 //
47 // recommend format of timestamp window scale
48 // option for fast process.
49 //
50 TCP_OPTION_TS_FAST = ((TCP_OPTION_NOP << 24) |
51 (TCP_OPTION_NOP << 16) |
52 (TCP_OPTION_TS << 8) |
53 TCP_OPTION_TS_LEN),
54
55 TCP_OPTION_WS_FAST = ((TCP_OPTION_NOP << 24) |
56 (TCP_OPTION_WS << 16) |
57 (TCP_OPTION_WS_LEN << 8)),
58
59 TCP_OPTION_MSS_FAST = ((TCP_OPTION_MSS << 24) |
60 (TCP_OPTION_MSS_LEN << 16)),
61
62 //
63 // Other misc definations
64 //
65 TCP_OPTION_RCVD_MSS = 0x01,
66 TCP_OPTION_RCVD_WS = 0x02,
67 TCP_OPTION_RCVD_TS = 0x04,
68 TCP_OPTION_MAX_WS = 14, ///< Maxium window scale value
69 TCP_OPTION_MAX_WIN = 0xffff ///< Max window size in TCP header
70 } TCP_OPTION_TYPE;
71
72 /**
73 Compute the window scale value according to the given buffer size.
74
75 @param Tcb Pointer to the TCP_CB of this TCP instance.
76
77 @return The scale value.
78
79 **/
80 UINT8
81 TcpComputeScale (
82 IN TCP_CB *Tcb
83 );
84
85 /**
86 Build the TCP option in three-way handshake.
87
88 @param Tcb Pointer to the TCP_CB of this TCP instance.
89 @param Nbuf Pointer to the buffer to store the options.
90
91 @return The total length of the TCP option field.
92
93 **/
94 UINT16
95 TcpSynBuildOption (
96 IN TCP_CB *Tcb,
97 IN NET_BUF *Nbuf
98 );
99
100 /**
101 Build the TCP option in synchronized states.
102
103 @param Tcb Pointer to the TCP_CB of this TCP instance.
104 @param Nbuf Pointer to the buffer to store the options.
105
106 @return The total length of the TCP option field.
107
108 **/
109 UINT16
110 TcpBuildOption (
111 IN TCP_CB *Tcb,
112 IN NET_BUF *Nbuf
113 );
114
115 /**
116 Parse the supported options.
117
118 @param Tcp Pointer to the TCP_CB of this TCP instance.
119 @param Option Pointer to the TCP_OPTION used to store the successfully pasrsed
120 options.
121
122 @retval 0 The options are successfully pasrsed.
123 @retval -1 Ilegal option was found.
124
125 **/
126 INTN
127 TcpParseOption (
128 IN TCP_HEAD *Tcp,
129 IN OUT TCP_OPTION *Option
130 );
131
132 /**
133 Check the segment against PAWS.
134
135 @param Tcb Pointer to the TCP_CB of this TCP instance.
136 @param TSVal The timestamp value.
137
138 @retval 1 The segment passed the PAWS check.
139 @retval 0 The segment failed to pass the PAWS check.
140
141 **/
142 UINT32
143 TcpPawsOK (
144 IN TCP_CB *Tcb,
145 IN UINT32 TSVal
146 );
147
148 #endif