]>
git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/TcpDxe/TcpOption.h
2 Tcp option's routine header file.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _TCP_OPTION_H_
11 #define _TCP_OPTION_H_
14 // Supported TCP option types and their length.
16 #define TCP_OPTION_EOP 0 ///< End Of oPtion
17 #define TCP_OPTION_NOP 1 ///< No-Option.
18 #define TCP_OPTION_MSS 2 ///< Maximum Segment Size
19 #define TCP_OPTION_WS 3 ///< Window scale
20 #define TCP_OPTION_TS 8 ///< Timestamp
21 #define TCP_OPTION_MSS_LEN 4 ///< Length of MSS option
22 #define TCP_OPTION_WS_LEN 3 ///< Length of window scale option
23 #define TCP_OPTION_TS_LEN 10 ///< Length of timestamp option
24 #define TCP_OPTION_WS_ALIGNED_LEN 4 ///< Length of window scale option, aligned
25 #define TCP_OPTION_TS_ALIGNED_LEN 12 ///< Length of timestamp option, aligned
28 // recommend format of timestamp window scale
29 // option for fast process.
31 #define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \
32 (TCP_OPTION_NOP << 16) | \
33 (TCP_OPTION_TS << 8) | \
36 #define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \
37 (TCP_OPTION_WS << 16) | \
38 (TCP_OPTION_WS_LEN << 8))
40 #define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16))
43 // Other misc definations
45 #define TCP_OPTION_RCVD_MSS 0x01
46 #define TCP_OPTION_RCVD_WS 0x02
47 #define TCP_OPTION_RCVD_TS 0x04
48 #define TCP_OPTION_MAX_WS 14 ///< Maxium window scale value
49 #define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header
52 /// The structure to store the parse option value.
53 /// ParseOption only parses the options, doesn't process them.
55 typedef struct _TCP_OPTION
{
56 UINT8 Flag
; ///< Flag such as TCP_OPTION_RCVD_MSS
57 UINT8 WndScale
; ///< The WndScale received
58 UINT16 Mss
; ///< The Mss received
59 UINT32 TSVal
; ///< The TSVal field in a timestamp option
60 UINT32 TSEcr
; ///< The TSEcr field in a timestamp option
64 Compute the window scale value according to the given buffer size.
66 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
68 @return The scale value.
77 Build the TCP option in three-way handshake.
79 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
80 @param[in] Nbuf Pointer to the buffer to store the options.
82 @return The total length of the TCP option field.
92 Build the TCP option in synchronized states.
94 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
95 @param[in] Nbuf Pointer to the buffer to store the options.
97 @return The total length of the TCP option field.
107 Parse the supported options.
109 @param[in] Tcp Pointer to the TCP_CB of this TCP instance.
110 @param[in, out] Option Pointer to the TCP_OPTION used to store the
111 successfully pasrsed options.
113 @retval 0 The options successfully pasrsed.
114 @retval -1 Ilegal option was found.
120 IN OUT TCP_OPTION
*Option