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