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