2 Tcp option's routine header file.
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>
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.
15 #ifndef _TCP4_OPTION_H_
16 #define _TCP4_OPTION_H_
19 /// The structure to store the parse option value.
20 /// ParseOption only parse the options, don't process them.
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
33 // supported TCP option type and their length
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
47 // recommend format of timestamp window scale
48 // option for fast process.
50 TCP_OPTION_TS_FAST
= ((TCP_OPTION_NOP
<< 24) |
51 (TCP_OPTION_NOP
<< 16) |
52 (TCP_OPTION_TS
<< 8) |
55 TCP_OPTION_WS_FAST
= ((TCP_OPTION_NOP
<< 24) |
56 (TCP_OPTION_WS
<< 16) |
57 (TCP_OPTION_WS_LEN
<< 8)),
59 TCP_OPTION_MSS_FAST
= ((TCP_OPTION_MSS
<< 24) |
60 (TCP_OPTION_MSS_LEN
<< 16)),
63 // Other misc definations
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
73 Compute the window scale value according to the given buffer size.
75 @param Tcb Pointer to the TCP_CB of this TCP instance.
77 @return The scale value.
86 Build the TCP option in three-way handshake.
88 @param Tcb Pointer to the TCP_CB of this TCP instance.
89 @param Nbuf Pointer to the buffer to store the options.
91 @return The total length of the TCP option field.
101 Build the TCP option in synchronized states.
103 @param Tcb Pointer to the TCP_CB of this TCP instance.
104 @param Nbuf Pointer to the buffer to store the options.
106 @return The total length of the TCP option field.
116 Parse the supported options.
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
122 @retval 0 The options are successfully pasrsed.
123 @retval -1 Ilegal option was found.
129 IN OUT TCP_OPTION
*Option
133 Check the segment against PAWS.
135 @param Tcb Pointer to the TCP_CB of this TCP instance.
136 @param TSVal The timestamp value.
138 @retval 1 The segment passed the PAWS check.
139 @retval 0 The segment failed to pass the PAWS check.