]>
Commit | Line | Data |
---|---|---|
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 | |
31 | #define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \\r | |
32 | (TCP_OPTION_NOP << 16) | \\r | |
33 | (TCP_OPTION_TS << 8) | \\r | |
34 | (TCP_OPTION_TS_LEN))\r | |
35 | \r | |
36 | #define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \\r | |
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 | |
43 | // Other misc definations\r | |
44 | //\r | |
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 ///< Maxium window scale value\r | |
49 | #define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header\r | |
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 | |
55 | typedef struct _TCP_OPTION {\r | |
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 | |
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 | |
71 | UINT8\r | |
72 | TcpComputeScale (\r | |
73 | IN TCP_CB *Tcb\r | |
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 | |
85 | UINT16\r | |
86 | TcpSynBuildOption (\r | |
87 | IN TCP_CB *Tcb,\r | |
88 | IN NET_BUF *Nbuf\r | |
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 | |
100 | UINT16\r | |
101 | TcpBuildOption (\r | |
102 | IN TCP_CB *Tcb,\r | |
103 | IN NET_BUF *Nbuf\r | |
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 | |
114 | @retval -1 Ilegal option was found.\r | |
115 | \r | |
116 | **/\r | |
117 | INTN\r | |
118 | TcpParseOption (\r | |
119 | IN TCP_HEAD *Tcp,\r | |
120 | IN OUT TCP_OPTION *Option\r | |
121 | );\r | |
122 | \r | |
a3bcde70 | 123 | #endif\r |