]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
added comments for CAPSULE_HOB_INFO in CapsuleVendor.h (MdeModuleModulePkg).
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Main.h
CommitLineData
83cbd279 1/** @file\r
dab714aa 2 TCP4 protocol services header file.\r
83cbd279 3\r
dfc1f033 4Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
83cbd279 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
dfc1f033 8http://opensource.org/licenses/bsd-license.php<BR>\r
83cbd279 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
83cbd279 13**/\r
14\r
15#ifndef _TCP4_MAIN_H_\r
16#define _TCP4_MAIN_H_\r
17\r
18#include "Socket.h"\r
19\r
20#include "Tcp4Proto.h"\r
dab714aa 21#include "Tcp4Func.h"\r
83cbd279 22#include "Tcp4Driver.h"\r
23\r
24\r
25extern UINT16 mTcp4RandomPort;\r
dfc1f033 26extern CHAR16 *mTcpStateName[];\r
83cbd279 27\r
28//\r
29// Driver Produced Protocol Prototypes\r
30//\r
31\r
83cbd279 32//\r
33// Function prototype for the Tcp4 socket request handler\r
34//\r
dfc1f033 35/**\r
36 The procotol handler provided to the socket layer, used to\r
37 dispatch the socket level requests by calling the corresponding\r
38 TCP layer functions.\r
39\r
40 @param Sock Pointer to the socket of this TCP instance.\r
41 @param Request The code of this operation request.\r
42 @param Data Pointer to the operation specific data passed in\r
43 together with the operation request.\r
44\r
45 @retval EFI_SUCCESS The socket request is completed successfully.\r
46 @retval other The error status returned by the corresponding TCP\r
47 layer function.\r
48\r
49**/\r
83cbd279 50EFI_STATUS\r
51Tcp4Dispatcher (\r
52 IN SOCKET *Sock,\r
53 IN SOCK_REQUEST Request,\r
54 IN VOID *Data OPTIONAL\r
55 );\r
dfc1f033 56 \r
57///\r
58/// TCP mode data\r
59///\r
83cbd279 60typedef struct _TCP4_MODE_DATA {\r
61 EFI_TCP4_CONNECTION_STATE *Tcp4State;\r
62 EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;\r
63 EFI_IP4_MODE_DATA *Ip4ModeData;\r
64 EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;\r
65 EFI_SIMPLE_NETWORK_MODE *SnpModeData;\r
66} TCP4_MODE_DATA;\r
67\r
dfc1f033 68///\r
69/// TCP route infomation data\r
70///\r
83cbd279 71typedef struct _TCP4_ROUTE_INFO {\r
72 BOOLEAN DeleteRoute;\r
73 EFI_IPv4_ADDRESS *SubnetAddress;\r
74 EFI_IPv4_ADDRESS *SubnetMask;\r
75 EFI_IPv4_ADDRESS *GatewayAddress;\r
76} TCP4_ROUTE_INFO;\r
77\r
dfc1f033 78/**\r
79 Get the current operational status of a TCP instance.\r
80 \r
81 The GetModeData() function copies the current operational settings of this \r
82 EFI TCPv4 Protocol instance into user-supplied buffers. This function can \r
83 also be used to retrieve the operational setting of underlying drivers \r
84 such as IPv4, MNP, or SNP.\r
85\r
86 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
87 @param Tcp4State Pointer to the buffer to receive the current TCP\r
88 state.\r
89 @param Tcp4ConfigData Pointer to the buffer to receive the current TCP\r
90 configuration.\r
91 @param Ip4ModeData Pointer to the buffer to receive the current IPv4 \r
92 configuration data used by the TCPv4 instance.\r
93 @param MnpConfigData Pointer to the buffer to receive the current MNP\r
94 configuration data indirectly used by the TCPv4\r
95 Instance.\r
96 @param SnpModeData Pointer to the buffer to receive the current SNP\r
97 configuration data indirectly used by the TCPv4\r
98 Instance.\r
99\r
100 @retval EFI_SUCCESS The mode data was read.\r
101 @retval EFI_NOT_STARTED No configuration data is available because this\r
102 instance hasn't been started.\r
103 @retval EFI_INVALID_PARAMETER This is NULL.\r
104\r
105**/\r
83cbd279 106EFI_STATUS\r
107EFIAPI\r
108Tcp4GetModeData (\r
dfc1f033 109 IN CONST EFI_TCP4_PROTOCOL *This,\r
110 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,\r
111 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,\r
112 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
113 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
114 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
83cbd279 115 );\r
116\r
dfc1f033 117\r
118/**\r
119 Initialize or brutally reset the operational parameters for\r
120 this EFI TCPv4 instance.\r
121 \r
122 The Configure() function does the following:\r
123 * Initialize this EFI TCPv4 instance, i.e., initialize the communication end \r
124 setting, specify active open or passive open for an instance.\r
125 * Reset this TCPv4 instance brutally, i.e., cancel all pending asynchronous \r
126 tokens, flush transmission and receiving buffer directly without informing \r
127 the communication peer.\r
128 No other TCPv4 Protocol operation can be executed by this instance \r
129 until it is configured properly. For an active TCP4 instance, after a proper \r
130 configuration it may call Connect() to initiates the three-way handshake. \r
131 For a passive TCP4 instance, its state will transit to Tcp4StateListen after \r
132 configuration, and Accept() may be called to listen the incoming TCP connection \r
133 request. If TcpConfigData is set to NULL, the instance is reset. Resetting \r
134 process will be done brutally, the state machine will be set to Tcp4StateClosed \r
135 directly, the receive queue and transmit queue will be flushed, and no traffic is \r
136 allowed through this instance.\r
137\r
138 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
139 @param TcpConfigData Pointer to the configure data to configure the\r
140 instance.\r
141\r
142 @retval EFI_SUCCESS The operational settings are set, changed, or\r
143 reset successfully.\r
144 @retval EFI_NO_MAPPING When using a default address, configuration\r
145 (through DHCP, BOOTP, RARP, etc.) is not\r
146 finished.\r
147 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
148 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already\r
149 configured.\r
150 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
151 @retval EFI_UNSUPPORTED One or more of the control options are not\r
152 supported in the implementation.\r
153 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.\r
154\r
155**/\r
83cbd279 156EFI_STATUS\r
157EFIAPI\r
158Tcp4Configure (\r
85511ddf 159 IN EFI_TCP4_PROTOCOL *This,\r
dfc1f033 160 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL\r
83cbd279 161 );\r
162\r
dfc1f033 163/**\r
164 Add or delete routing entries.\r
165 \r
166 The Routes() function adds or deletes a route from the instance's routing table.\r
167 The most specific route is selected by comparing the SubnetAddress with the \r
168 destination IP address's arithmetical AND to the SubnetMask.\r
169 The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0. \r
170 The default route matches all destination IP addresses if there is no more specific route.\r
171 Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to \r
172 the destination host if its address can be found in the Address Resolution Protocol (ARP) \r
173 cache or it is on the local subnet. If the instance is configured to use default \r
174 address, a direct route to the local network will be added automatically.\r
175 Each TCP instance has its own independent routing table. Instance that uses the \r
176 default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table. \r
177 The copy will be updated automatically whenever the IP driver reconfigures its \r
178 instance. As a result, the previous modification to the instance's local copy \r
179 will be lost. The priority of checking the route table is specific with IP \r
180 implementation and every IP implementation must comply with RFC 1122.\r
181\r
182 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
183 @param DeleteRoute If TRUE, delete the specified route from routing\r
184 table; if FALSE, add the specified route to\r
185 routing table.\r
186 DestinationAddress and SubnetMask are used as \r
187 the keywords to search route entry.\r
188 @param SubnetAddress The destination network.\r
189 @param SubnetMask The subnet mask for the destination network.\r
190 @param GatewayAddress The gateway address for this route. \r
191 It must be on the same subnet with the station \r
192 address unless a direct route is specified.\r
193 \r
194 @retval EFI_SUCCESS The operation completed successfully.\r
195 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been\r
196 configured.\r
197 @retval EFI_NO_MAPPING When using a default address, configuration\r
198 (through DHCP, BOOTP, RARP, etc.) is not\r
199 finished.\r
200 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
201 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the\r
202 entry to the routing table.\r
203 @retval EFI_NOT_FOUND This route is not in the routing table.\r
204 @retval EFI_ACCESS_DENIED This route is already in the routing table.\r
205 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.\r
206\r
207**/\r
83cbd279 208EFI_STATUS\r
209EFIAPI\r
210Tcp4Routes (\r
211 IN EFI_TCP4_PROTOCOL *This,\r
212 IN BOOLEAN DeleteRoute,\r
213 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
214 IN EFI_IPv4_ADDRESS *SubnetMask,\r
215 IN EFI_IPv4_ADDRESS *GatewayAddress\r
216 );\r
217\r
dfc1f033 218/**\r
219 Initiate a nonblocking TCP connection request for an active TCP instance.\r
220\r
221 The Connect() function will initiate an active open to the remote peer configured \r
222 in current TCP instance if it is configured active. If the connection succeeds \r
223 or fails due to any error, the ConnectionToken->CompletionToken.Event will be \r
224 signaled and ConnectionToken->CompletionToken.Status will be updated accordingly. \r
225 This function can only be called for the TCP instance in Tcp4StateClosed state. \r
226 The instance will transfer into Tcp4StateSynSent if the function returns EFI_SUCCESS. \r
227 If TCP three way handshake succeeds, its state will become Tcp4StateEstablished, \r
228 otherwise, the state will return to Tcp4StateClosed.\r
229 \r
230 @param This Pointer to the EFI_TCP4_PROTOCOL instance\r
231 @param ConnectionToken Pointer to the connection token to return when\r
232 the TCP three way handshake finishes.\r
233\r
234 @retval EFI_SUCCESS The connection request is successfully initiated \r
235 and the state of this TCPv4 instance has \r
236 been changed to Tcp4StateSynSent.\r
237 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been\r
238 configured.\r
239 @retval EFI_ACCESS_DENIED The instance is not configured as an active one\r
240 or it is not in Tcp4StateClosed state.\r
241 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
242 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to\r
243 initiate the active open.\r
244 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
245\r
246**/\r
83cbd279 247EFI_STATUS\r
248EFIAPI\r
249Tcp4Connect (\r
250 IN EFI_TCP4_PROTOCOL *This,\r
251 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken\r
252 );\r
253\r
dfc1f033 254/**\r
255 Listen on the passive instance to accept an incoming connection request.\r
256\r
257 The Accept() function initiates an asynchronous accept request to wait for an \r
258 incoming connection on the passive TCP instance. If a remote peer successfully \r
259 establishes a connection with this instance, a new TCP instance will be created \r
260 and its handle will be returned in ListenToken->NewChildHandle. The newly created \r
261 instance is configured by inheriting the passive instance's configuration and is \r
262 ready for use upon return. The instance is in the Tcp4StateEstablished state.\r
263 The ListenToken->CompletionToken.Event will be signaled when a new connection \r
264 is accepted, user aborts the listen or connection is reset. This function only \r
265 can be called when current TCP instance is in Tcp4StateListen state.\r
266\r
267 @param This Pointer to the EFI_TCP4_PROTOCOL instance\r
268 @param ListenToken Pointer to the listen token to return when\r
269 operation finishes.\r
270\r
271 @retval EFI_SUCCESS The listen token has been queued successfully.\r
272 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
273 configured.\r
274 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not\r
275 in Tcp4StateListen state or a same listen token\r
276 has already existed in the listen token queue of\r
277 this TCP instance.\r
278 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
279 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish\r
280 the operation.\r
281 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.\r
282\r
283**/\r
83cbd279 284EFI_STATUS\r
285EFIAPI\r
286Tcp4Accept (\r
287 IN EFI_TCP4_PROTOCOL *This,\r
288 IN EFI_TCP4_LISTEN_TOKEN *ListenToken\r
289 );\r
290\r
dfc1f033 291/**\r
292 Queues outgoing data into the transmit queue.\r
293\r
294 The Transmit() function queues a sending request to this TCPv4 instance along \r
295 with the user data. The status of the token is updated and the event in the token \r
296 will be signaled once the data is sent out or some error occurs.\r
297\r
298 @param This Pointer to the EFI_TCP4_PROTOCOL instance\r
299 @param Token Pointer to the completion token to queue to the\r
300 transmit queue\r
301\r
302 @retval EFI_SUCCESS The data has been queued for transmission.\r
303 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
304 configured.\r
305 @retval EFI_NO_MAPPING When using a default address, configuration\r
306 (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
307 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
308 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
309 * A transmit completion token with the same\r
310 Token-> CompletionToken.Event was already in the\r
311 transmission queue. \r
312 * The current instance is in Tcp4StateClosed state \r
313 * The current instance is a passive one and \r
314 it is in Tcp4StateListen state. \r
315 * User has called Close() to disconnect this \r
316 connection.\r
317 @retval EFI_NOT_READY The completion token could not be queued because\r
318 the transmit queue is full.\r
319 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of\r
320 resource shortage.\r
321 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or\r
322 address.\r
323\r
324**/\r
83cbd279 325EFI_STATUS\r
326EFIAPI\r
327Tcp4Transmit (\r
328 IN EFI_TCP4_PROTOCOL *This,\r
329 IN EFI_TCP4_IO_TOKEN *Token\r
330 );\r
331\r
dfc1f033 332/**\r
333 Place an asynchronous receive request into the receiving queue.\r
334\r
335 The Receive() function places a completion token into the receive packet queue. \r
336 This function is always asynchronous. The caller must allocate the \r
337 Token->CompletionToken.Event and the FragmentBuffer used to receive data. He also \r
338 must fill the DataLength which represents the whole length of all FragmentBuffer. \r
339 When the receive operation completes, the EFI TCPv4 Protocol driver updates the \r
340 Token->CompletionToken.Status and Token->Packet.RxData fields and the \r
341 Token->CompletionToken.Event is signaled. If got data the data and its length \r
342 will be copy into the FragmentTable, in the same time the full length of received \r
343 data will be recorded in the DataLength fields. Providing a proper notification \r
344 function and context for the event will enable the user to receive the notification \r
345 and receiving status. That notification function is guaranteed to not be re-entered.\r
346\r
347 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
348 @param Token Pointer to a token that is associated with the\r
349 receive data descriptor.\r
350\r
351 @retval EFI_SUCCESS The receive completion token was cached.\r
352 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
353 configured.\r
354 @retval EFI_NO_MAPPING When using a default address, configuration\r
355 (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
356 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
357 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued\r
358 due to a lack of system resources.\r
359 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
360 The EFI TCPv4 Protocol instance has been reset \r
361 to startup defaults.\r
362 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
363 * A receive completion token with the same\r
364 Token->CompletionToken.Event was already in \r
365 the receive queue. \r
366 * The current instance is in Tcp4StateClosed state. \r
367 * The current instance is a passive one and it \r
368 is in Tcp4StateListen state. \r
369 * User has called Close() to disconnect this \r
370 connection.\r
371 @retval EFI_CONNECTION_FIN The communication peer has closed the connection\r
372 and there is no any buffered data in the receive\r
373 buffer of this instance.\r
374 @retval EFI_NOT_READY The receive request could not be queued because\r
375 the receive queue is full.\r
376\r
377**/\r
83cbd279 378EFI_STATUS\r
85511ddf 379EFIAPI\r
83cbd279 380Tcp4Receive (\r
381 IN EFI_TCP4_PROTOCOL *This,\r
382 IN EFI_TCP4_IO_TOKEN *Token\r
383 );\r
384\r
dfc1f033 385/**\r
386 Disconnecting a TCP connection gracefully or reset a TCP connection.\r
387\r
388 Initiate an asynchronous close token to TCP driver. After Close() is called, \r
389 any buffered transmission data will be sent by TCP driver and the current \r
390 instance will have a graceful close working flow described as RFC 793 if \r
391 AbortOnClose is set to FALSE, otherwise, a rest packet will be sent by TCP \r
392 driver to fast disconnect this connection. When the close operation completes \r
393 successfully the TCP instance is in Tcp4StateClosed state, all pending \r
394 asynchronous operation is signaled and any buffers used for TCP network traffic \r
395 is flushed.\r
396\r
397 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
398 @param CloseToken Pointer to the close token to return when\r
399 operation finishes.\r
400\r
401 @retval EFI_SUCCESS The operation completed successfully.\r
402 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
403 configured.\r
404 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: \r
405 * Configure() has been called with TcpConfigData\r
406 set to NULL and this function has not returned.\r
407 * Previous Close() call on this instance has not\r
408 finished.\r
409 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.\r
410 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the\r
411 operation.\r
412 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above\r
413 category error.\r
414\r
415**/\r
83cbd279 416EFI_STATUS\r
417EFIAPI\r
418Tcp4Close (\r
419 IN EFI_TCP4_PROTOCOL *This,\r
420 IN EFI_TCP4_CLOSE_TOKEN *CloseToken\r
421 );\r
422\r
dfc1f033 423/**\r
424 Abort an asynchronous connection, listen, transmission or receive request.\r
425\r
426 The Cancel() function aborts a pending connection, listen, transmit or receive \r
427 request. If Token is not NULL and the token is in the connection, listen, \r
428 transmission or receive queue when it is being cancelled, its Token->Status \r
429 will be set to EFI_ABORTED and then Token->Event will be signaled. If the token \r
430 is not in one of the queues, which usually means that the asynchronous operation \r
431 has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token \r
432 issued by Connect(), Accept(), Transmit() and Receive()will be aborted.\r
433 NOTE: It has not been implemented currently.\r
434 \r
435 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
436 @param Token Pointer to a token that has been issued by\r
437 Connect(), Accept(), Transmit() or Receive(). If\r
438 NULL, all pending tokens issued by above four\r
439 functions will be aborted.\r
440 \r
441 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
442 is signaled.\r
443 @retval EFI_INVALID_PARAMETER This is NULL.\r
444 @retval EFI_NOT_STARTED This instance hasn's been configured.\r
445 @retval EFI_NO_MAPPING When using the default address, configuration\r
446 (DHCP, BOOTP,RARP, etc.) hasn's finished yet.\r
447 @retval EFI_NOT_FOUND The asynchronous I/O request isn's found in the \r
448 transmission or receive queue. It has either \r
449 completed or wasn's issued by Transmit() and Receive().\r
450 @retval EFI_UNSUPPORTED The operation is not supported in current\r
451 implementation.\r
452 \r
453**/\r
83cbd279 454EFI_STATUS\r
455EFIAPI\r
456Tcp4Cancel (\r
85511ddf 457 IN EFI_TCP4_PROTOCOL *This,\r
dfc1f033 458 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r
83cbd279 459 );\r
460\r
dfc1f033 461/**\r
462 Poll to receive incoming data and transmit outgoing segments.\r
463\r
464 The Poll() function increases the rate that data is moved between the network \r
465 and application and can be called when the TCP instance is created successfully. \r
466 Its use is optional. In some implementations, the periodical timer in the MNP \r
467 driver may not poll the underlying communications device fast enough to avoid \r
468 drop packets. Drivers and applications that are experiencing packet loss should \r
469 try calling the Poll() function in a high frequency.\r
470\r
471 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
472\r
473 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
474 @retval EFI_INVALID_PARAMETER This is NULL.\r
475 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
476 @retval EFI_NOT_READY No incoming or outgoing data was processed.\r
477 @retval EFI_TIMEOUT Data was dropped out of the transmission or\r
478 receive queue. Consider increasing the polling\r
479 rate.\r
480\r
481**/\r
83cbd279 482EFI_STATUS\r
483EFIAPI\r
484Tcp4Poll (\r
485 IN EFI_TCP4_PROTOCOL *This\r
486 );\r
487\r
488#endif\r