]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/TcpDxe/TcpOption.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / NetworkPkg / TcpDxe / TcpOption.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Tcp option's routine header file.\r
3\r
8343c750 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
a3bcde70 5\r
ecf98fbc 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a3bcde70
HT
7\r
8**/\r
9\r
10#ifndef _TCP_OPTION_H_\r
11#define _TCP_OPTION_H_\r
12\r
13//\r
14// Supported TCP option types and their length.\r
15//\r
16#define TCP_OPTION_EOP 0 ///< End Of oPtion\r
17#define TCP_OPTION_NOP 1 ///< No-Option.\r
18#define TCP_OPTION_MSS 2 ///< Maximum Segment Size\r
19#define TCP_OPTION_WS 3 ///< Window scale\r
20#define TCP_OPTION_TS 8 ///< Timestamp\r
21#define TCP_OPTION_MSS_LEN 4 ///< Length of MSS option\r
22#define TCP_OPTION_WS_LEN 3 ///< Length of window scale option\r
23#define TCP_OPTION_TS_LEN 10 ///< Length of timestamp option\r
24#define TCP_OPTION_WS_ALIGNED_LEN 4 ///< Length of window scale option, aligned\r
25#define TCP_OPTION_TS_ALIGNED_LEN 12 ///< Length of timestamp option, aligned\r
26\r
27//\r
28// recommend format of timestamp window scale\r
29// option for fast process.\r
30//\r
d1050b9d 31#define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) |\\r
a3bcde70
HT
32 (TCP_OPTION_NOP << 16) | \\r
33 (TCP_OPTION_TS << 8) | \\r
34 (TCP_OPTION_TS_LEN))\r
35\r
d1050b9d 36#define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \\r
a3bcde70
HT
37 (TCP_OPTION_WS << 16) | \\r
38 (TCP_OPTION_WS_LEN << 8))\r
39\r
40#define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16))\r
41\r
42//\r
81c6f176 43// Other misc definitions\r
a3bcde70 44//\r
d1050b9d
MK
45#define TCP_OPTION_RCVD_MSS 0x01\r
46#define TCP_OPTION_RCVD_WS 0x02\r
47#define TCP_OPTION_RCVD_TS 0x04\r
48#define TCP_OPTION_MAX_WS 14 ///< Maximum window scale value\r
49#define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header\r
a3bcde70
HT
50\r
51///\r
52/// The structure to store the parse option value.\r
53/// ParseOption only parses the options, doesn't process them.\r
54///\r
55typedef struct _TCP_OPTION {\r
d1050b9d
MK
56 UINT8 Flag; ///< Flag such as TCP_OPTION_RCVD_MSS\r
57 UINT8 WndScale; ///< The WndScale received\r
58 UINT16 Mss; ///< The Mss received\r
59 UINT32 TSVal; ///< The TSVal field in a timestamp option\r
60 UINT32 TSEcr; ///< The TSEcr field in a timestamp option\r
a3bcde70
HT
61} TCP_OPTION;\r
62\r
63/**\r
64 Compute the window scale value according to the given buffer size.\r
65\r
66 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r
67\r
68 @return The scale value.\r
69\r
70**/\r
71UINT8\r
72TcpComputeScale (\r
d1050b9d 73 IN TCP_CB *Tcb\r
a3bcde70
HT
74 );\r
75\r
76/**\r
77 Build the TCP option in three-way handshake.\r
78\r
79 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r
80 @param[in] Nbuf Pointer to the buffer to store the options.\r
81\r
82 @return The total length of the TCP option field.\r
83\r
84**/\r
85UINT16\r
86TcpSynBuildOption (\r
d1050b9d
MK
87 IN TCP_CB *Tcb,\r
88 IN NET_BUF *Nbuf\r
a3bcde70
HT
89 );\r
90\r
91/**\r
92 Build the TCP option in synchronized states.\r
93\r
94 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r
95 @param[in] Nbuf Pointer to the buffer to store the options.\r
96\r
97 @return The total length of the TCP option field.\r
98\r
99**/\r
100UINT16\r
101TcpBuildOption (\r
d1050b9d
MK
102 IN TCP_CB *Tcb,\r
103 IN NET_BUF *Nbuf\r
a3bcde70
HT
104 );\r
105\r
106/**\r
107 Parse the supported options.\r
108\r
109 @param[in] Tcp Pointer to the TCP_CB of this TCP instance.\r
110 @param[in, out] Option Pointer to the TCP_OPTION used to store the\r
111 successfully pasrsed options.\r
112\r
113 @retval 0 The options successfully pasrsed.\r
81c6f176 114 @retval -1 Illegal option was found.\r
a3bcde70
HT
115\r
116**/\r
117INTN\r
118TcpParseOption (\r
d1050b9d
MK
119 IN TCP_HEAD *Tcp,\r
120 IN OUT TCP_OPTION *Option\r
a3bcde70
HT
121 );\r
122\r
a3bcde70 123#endif\r