]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Tcp option's routine header file.\r | |
3 | \r | |
4 | Copyright (c) 2005 - 2009, Intel Corporation<BR>\r | |
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 | |
8 | http://opensource.org/licenses/bsd-license.php<BR>\r | |
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 | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _TCP4_OPTION_H_\r | |
16 | #define _TCP4_OPTION_H_\r | |
17 | \r | |
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 | |
28 | } TCP_OPTION;\r | |
29 | \r | |
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 | |
68 | \r | |
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 | |
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 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 | |
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 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 | |
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 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 | |
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 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 | |
139 | UINT32\r | |
140 | TcpPawsOK (\r | |
141 | IN TCP_CB *Tcb,\r | |
142 | IN UINT32 TSVal\r | |
143 | );\r | |
144 | \r | |
145 | #endif\r |