]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
dab714aa | 2 | Tcp option's routine header file.\r |
dfc1f033 | 3 | \r |
4 | Copyright (c) 2005 - 2006, Intel Corporation<BR>\r | |
83cbd279 | 5 | All rights reserved. This program and the accompanying materials\r |
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 | |
85511ddf | 30 | typedef enum {\r |
83cbd279 | 31 | \r |
32 | //\r | |
33 | // supported TCP option type and their length\r | |
34 | //\r | |
dfc1f033 | 35 | TCP_OPTION_EOP = 0, ///< End Of oPtion\r |
36 | TCP_OPTION_NOP = 1, ///< No-Option.\r | |
37 | TCP_OPTION_MSS = 2, ///< Maximum Segment Size\r | |
38 | TCP_OPTION_WS = 3, ///< Window scale\r | |
39 | TCP_OPTION_TS = 8, ///< Timestamp\r | |
40 | TCP_OPTION_MSS_LEN = 4, ///< Length of MSS option\r | |
41 | TCP_OPTION_WS_LEN = 3, ///< Length of window scale option\r | |
42 | TCP_OPTION_TS_LEN = 10, ///< Length of timestamp option\r | |
43 | TCP_OPTION_WS_ALIGNED_LEN = 4, ///< Length of window scale option, aligned\r | |
44 | TCP_OPTION_TS_ALIGNED_LEN = 12, ///< Length of timestamp option, aligned\r | |
83cbd279 | 45 | \r |
46 | //\r | |
47 | // recommend format of timestamp window scale\r | |
48 | // option for fast process.\r | |
49 | //\r | |
50 | TCP_OPTION_TS_FAST = ((TCP_OPTION_NOP << 24) |\r | |
51 | (TCP_OPTION_NOP << 16) |\r | |
52 | (TCP_OPTION_TS << 8) |\r | |
53 | TCP_OPTION_TS_LEN),\r | |
54 | \r | |
55 | TCP_OPTION_WS_FAST = ((TCP_OPTION_NOP << 24) |\r | |
56 | (TCP_OPTION_WS << 16) |\r | |
57 | (TCP_OPTION_WS_LEN << 8)),\r | |
58 | \r | |
59 | TCP_OPTION_MSS_FAST = ((TCP_OPTION_MSS << 24) |\r | |
60 | (TCP_OPTION_MSS_LEN << 16)),\r | |
61 | \r | |
62 | //\r | |
63 | // Other misc definations\r | |
64 | //\r | |
83cbd279 | 65 | TCP_OPTION_RCVD_MSS = 0x01,\r |
66 | TCP_OPTION_RCVD_WS = 0x02,\r | |
85511ddf | 67 | TCP_OPTION_RCVD_TS = 0x04,\r |
dfc1f033 | 68 | TCP_OPTION_MAX_WS = 14, ///< Maxium window scale value\r |
69 | TCP_OPTION_MAX_WIN = 0xffff ///< Max window size in TCP header\r | |
85511ddf | 70 | } TCP_OPTION_TYPE;\r |
83cbd279 | 71 | \r |
dfc1f033 | 72 | /**\r |
73 | Compute the window scale value according to the given buffer size.\r | |
74 | \r | |
75 | @param Tcb Pointer to the TCP_CB of this TCP instance.\r | |
76 | \r | |
77 | @return The scale value.\r | |
78 | \r | |
79 | **/\r | |
83cbd279 | 80 | UINT8\r |
81 | TcpComputeScale (\r | |
82 | IN TCP_CB *Tcb\r | |
83 | );\r | |
84 | \r | |
dfc1f033 | 85 | /**\r |
86 | Build the TCP option in three-way handshake.\r | |
87 | \r | |
88 | @param Tcb Pointer to the TCP_CB of this TCP instance.\r | |
89 | @param Nbuf Pointer to the buffer to store the options.\r | |
90 | \r | |
91 | @return The total length of the TCP option field.\r | |
92 | \r | |
93 | **/\r | |
83cbd279 | 94 | UINT16\r |
95 | TcpSynBuildOption (\r | |
96 | IN TCP_CB *Tcb,\r | |
dfc1f033 | 97 | IN NET_BUF *Nbuf\r |
83cbd279 | 98 | );\r |
99 | \r | |
dfc1f033 | 100 | /**\r |
101 | Build the TCP option in synchronized states.\r | |
102 | \r | |
103 | @param Tcb Pointer to the TCP_CB of this TCP instance.\r | |
104 | @param Nbuf Pointer to the buffer to store the options.\r | |
105 | \r | |
106 | @return The total length of the TCP option field.\r | |
107 | \r | |
108 | **/\r | |
83cbd279 | 109 | UINT16\r |
110 | TcpBuildOption (\r | |
111 | IN TCP_CB *Tcb,\r | |
dfc1f033 | 112 | IN NET_BUF *Nbuf\r |
83cbd279 | 113 | );\r |
114 | \r | |
dfc1f033 | 115 | /**\r |
116 | Parse the supported options.\r | |
117 | \r | |
118 | @param Tcp Pointer to the TCP_CB of this TCP instance.\r | |
119 | @param Option Pointer to the TCP_OPTION used to store the successfully pasrsed\r | |
120 | options.\r | |
121 | \r | |
122 | @retval 0 The options are successfully pasrsed.\r | |
123 | @retval -1 Ilegal option was found.\r | |
124 | \r | |
125 | **/\r | |
83cbd279 | 126 | INTN\r |
127 | TcpParseOption (\r | |
77f00155 | 128 | IN TCP_HEAD *Tcp,\r |
129 | IN OUT TCP_OPTION *Option\r | |
83cbd279 | 130 | );\r |
131 | \r | |
dfc1f033 | 132 | /**\r |
133 | Check the segment against PAWS.\r | |
134 | \r | |
135 | @param Tcb Pointer to the TCP_CB of this TCP instance.\r | |
136 | @param TSVal The timestamp value.\r | |
137 | \r | |
138 | @retval 1 The segment passed the PAWS check.\r | |
139 | @retval 0 The segment failed to pass the PAWS check.\r | |
140 | \r | |
141 | **/\r | |
83cbd279 | 142 | UINT32\r |
143 | TcpPawsOK (\r | |
144 | IN TCP_CB *Tcb,\r | |
145 | IN UINT32 TSVal\r | |
146 | );\r | |
147 | \r | |
148 | #endif\r |