]>
Commit | Line | Data |
---|---|---|
a3bcde70 HT |
1 | /** @file\r |
2 | Tcp option's routine header file.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php.\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _TCP_OPTION_H_\r | |
17 | #define _TCP_OPTION_H_\r | |
18 | \r | |
19 | //\r | |
20 | // Supported TCP option types and their length.\r | |
21 | //\r | |
22 | #define TCP_OPTION_EOP 0 ///< End Of oPtion\r | |
23 | #define TCP_OPTION_NOP 1 ///< No-Option.\r | |
24 | #define TCP_OPTION_MSS 2 ///< Maximum Segment Size\r | |
25 | #define TCP_OPTION_WS 3 ///< Window scale\r | |
26 | #define TCP_OPTION_TS 8 ///< Timestamp\r | |
27 | #define TCP_OPTION_MSS_LEN 4 ///< Length of MSS option\r | |
28 | #define TCP_OPTION_WS_LEN 3 ///< Length of window scale option\r | |
29 | #define TCP_OPTION_TS_LEN 10 ///< Length of timestamp option\r | |
30 | #define TCP_OPTION_WS_ALIGNED_LEN 4 ///< Length of window scale option, aligned\r | |
31 | #define TCP_OPTION_TS_ALIGNED_LEN 12 ///< Length of timestamp option, aligned\r | |
32 | \r | |
33 | //\r | |
34 | // recommend format of timestamp window scale\r | |
35 | // option for fast process.\r | |
36 | //\r | |
37 | #define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \\r | |
38 | (TCP_OPTION_NOP << 16) | \\r | |
39 | (TCP_OPTION_TS << 8) | \\r | |
40 | (TCP_OPTION_TS_LEN))\r | |
41 | \r | |
42 | #define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \\r | |
43 | (TCP_OPTION_WS << 16) | \\r | |
44 | (TCP_OPTION_WS_LEN << 8))\r | |
45 | \r | |
46 | #define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16))\r | |
47 | \r | |
48 | //\r | |
49 | // Other misc definations\r | |
50 | //\r | |
51 | #define TCP_OPTION_RCVD_MSS 0x01\r | |
52 | #define TCP_OPTION_RCVD_WS 0x02\r | |
53 | #define TCP_OPTION_RCVD_TS 0x04\r | |
54 | #define TCP_OPTION_MAX_WS 14 ///< Maxium window scale value\r | |
55 | #define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header\r | |
56 | \r | |
57 | ///\r | |
58 | /// The structure to store the parse option value.\r | |
59 | /// ParseOption only parses the options, doesn't process them.\r | |
60 | ///\r | |
61 | typedef struct _TCP_OPTION {\r | |
62 | UINT8 Flag; ///< Flag such as TCP_OPTION_RCVD_MSS\r | |
63 | UINT8 WndScale; ///< The WndScale received\r | |
64 | UINT16 Mss; ///< The Mss received\r | |
65 | UINT32 TSVal; ///< The TSVal field in a timestamp option\r | |
66 | UINT32 TSEcr; ///< The TSEcr field in a timestamp option\r | |
67 | } TCP_OPTION;\r | |
68 | \r | |
69 | /**\r | |
70 | Compute the window scale value according to the given buffer size.\r | |
71 | \r | |
72 | @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r | |
73 | \r | |
74 | @return The scale value.\r | |
75 | \r | |
76 | **/\r | |
77 | UINT8\r | |
78 | TcpComputeScale (\r | |
79 | IN TCP_CB *Tcb\r | |
80 | );\r | |
81 | \r | |
82 | /**\r | |
83 | Build the TCP option in three-way handshake.\r | |
84 | \r | |
85 | @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r | |
86 | @param[in] Nbuf Pointer to the buffer to store the options.\r | |
87 | \r | |
88 | @return The total length of the TCP option field.\r | |
89 | \r | |
90 | **/\r | |
91 | UINT16\r | |
92 | TcpSynBuildOption (\r | |
93 | IN TCP_CB *Tcb,\r | |
94 | IN NET_BUF *Nbuf\r | |
95 | );\r | |
96 | \r | |
97 | /**\r | |
98 | Build the TCP option in synchronized states.\r | |
99 | \r | |
100 | @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r | |
101 | @param[in] Nbuf Pointer to the buffer to store the options.\r | |
102 | \r | |
103 | @return The total length of the TCP option field.\r | |
104 | \r | |
105 | **/\r | |
106 | UINT16\r | |
107 | TcpBuildOption (\r | |
108 | IN TCP_CB *Tcb,\r | |
109 | IN NET_BUF *Nbuf\r | |
110 | );\r | |
111 | \r | |
112 | /**\r | |
113 | Parse the supported options.\r | |
114 | \r | |
115 | @param[in] Tcp Pointer to the TCP_CB of this TCP instance.\r | |
116 | @param[in, out] Option Pointer to the TCP_OPTION used to store the\r | |
117 | successfully pasrsed options.\r | |
118 | \r | |
119 | @retval 0 The options successfully pasrsed.\r | |
120 | @retval -1 Ilegal option was found.\r | |
121 | \r | |
122 | **/\r | |
123 | INTN\r | |
124 | TcpParseOption (\r | |
125 | IN TCP_HEAD *Tcp,\r | |
126 | IN OUT TCP_OPTION *Option\r | |
127 | );\r | |
128 | \r | |
129 | /**\r | |
130 | Check the segment against PAWS.\r | |
131 | \r | |
132 | @param[in] Tcb Pointer to the TCP_CB of this TCP instance.\r | |
133 | @param[in] TSVal The timestamp value.\r | |
134 | \r | |
135 | @retval 1 The segment passed the PAWS check.\r | |
136 | @retval 0 The segment failed to pass the PAWS check.\r | |
137 | \r | |
138 | **/\r | |
139 | UINT32\r | |
140 | TcpPawsOK (\r | |
141 | IN TCP_CB *Tcb,\r | |
142 | IN UINT32 TSVal\r | |
143 | );\r | |
144 | \r | |
145 | #endif\r |