]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
2 Tcp option's routine header file.
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>
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
31 // supported TCP option type and their length
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
45 // recommend format of timestamp window scale
46 // option for fast process.
48 #define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \
49 (TCP_OPTION_NOP << 16) | \
50 (TCP_OPTION_TS << 8) | \
53 #define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \
54 (TCP_OPTION_WS << 16) | \
55 (TCP_OPTION_WS_LEN << 8))
57 #define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16))
60 // Other misc definations
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
70 Compute the window scale value according to the given buffer size.
72 @param Tcb Pointer to the TCP_CB of this TCP instance.
74 @return The scale value.
83 Build the TCP option in three-way handshake.
85 @param Tcb Pointer to the TCP_CB of this TCP instance.
86 @param Nbuf Pointer to the buffer to store the options.
88 @return The total length of the TCP option field.
98 Build the TCP option in synchronized states.
100 @param Tcb Pointer to the TCP_CB of this TCP instance.
101 @param Nbuf Pointer to the buffer to store the options.
103 @return The total length of the TCP option field.
113 Parse the supported options.
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
119 @retval 0 The options are successfully pasrsed.
120 @retval -1 Ilegal option was found.
126 IN OUT TCP_OPTION
*Option
130 Check the segment against PAWS.
132 @param Tcb Pointer to the TCP_CB of this TCP instance.
133 @param TSVal The timestamp value.
135 @retval 1 The segment passed the PAWS check.
136 @retval 0 The segment failed to pass the PAWS check.