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>
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.
14 #ifndef _TCP4_OPTION_H_
15 #define _TCP4_OPTION_H_
18 /// The structure to store the parse option value.
19 /// ParseOption only parse the options, don't process them.
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
32 // supported TCP option type and their length
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
46 // recommend format of timestamp window scale
47 // option for fast process.
49 TCP_OPTION_TS_FAST
= ((TCP_OPTION_NOP
<< 24) |
50 (TCP_OPTION_NOP
<< 16) |
51 (TCP_OPTION_TS
<< 8) |
54 TCP_OPTION_WS_FAST
= ((TCP_OPTION_NOP
<< 24) |
55 (TCP_OPTION_WS
<< 16) |
56 (TCP_OPTION_WS_LEN
<< 8)),
58 TCP_OPTION_MSS_FAST
= ((TCP_OPTION_MSS
<< 24) |
59 (TCP_OPTION_MSS_LEN
<< 16)),
62 // Other misc definations
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
72 Compute the window scale value according to the given buffer size.
74 @param Tcb Pointer to the TCP_CB of this TCP instance.
76 @return The scale value.
85 Build the TCP option in three-way handshake.
87 @param Tcb Pointer to the TCP_CB of this TCP instance.
88 @param Nbuf Pointer to the buffer to store the options.
90 @return The total length of the TCP option field.
100 Build the TCP option in synchronized states.
102 @param Tcb Pointer to the TCP_CB of this TCP instance.
103 @param Nbuf Pointer to the buffer to store the options.
105 @return The total length of the TCP option field.
115 Parse the supported options.
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
121 @retval 0 The options are successfully pasrsed.
122 @retval -1 Ilegal option was found.
128 IN OUT TCP_OPTION
*Option
132 Check the segment against PAWS.
134 @param Tcb Pointer to the TCP_CB of this TCP instance.
135 @param TSVal The timestamp value.
137 @retval 1 The segment passed the PAWS check.
138 @retval 0 The segment failed to pass the PAWS check.