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