]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/TcpDxe/TcpMain.c
NetworkPkg: Support TCP Cancel function
[mirror_edk2.git] / NetworkPkg / TcpDxe / TcpMain.c
CommitLineData
a3bcde70
HT
1/** @file\r
2 Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r
3\r
8f586b85 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
5ffe214a 5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
6\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include "TcpMain.h"\r
18\r
19/**\r
20 Check the integrity of the data buffer.\r
21\r
22 @param[in] DataLen The total length of the data buffer.\r
23 @param[in] FragmentCount The fragment count of the fragment table.\r
24 @param[in] FragmentTable Pointer to the fragment table of the data\r
25 buffer.\r
26\r
27 @retval EFI_SUCCESS The integrity check passed.\r
28 @retval EFI_INVALID_PARAMETER The integrity check failed.\r
29\r
30**/\r
31EFI_STATUS\r
32TcpChkDataBuf (\r
33 IN UINT32 DataLen,\r
34 IN UINT32 FragmentCount,\r
35 IN EFI_TCP4_FRAGMENT_DATA *FragmentTable\r
36 )\r
37{\r
38 UINT32 Index;\r
39\r
40 UINT32 Len;\r
41\r
42 for (Index = 0, Len = 0; Index < FragmentCount; Index++) {\r
43 Len = Len + FragmentTable[Index].FragmentLength;\r
44 }\r
45\r
46 if (DataLen != Len) {\r
47 return EFI_INVALID_PARAMETER;\r
48 }\r
49\r
50 return EFI_SUCCESS;\r
51}\r
52\r
53/**\r
54 Get the current operational status.\r
55\r
56 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
57 @param[out] Tcp4State Pointer to the buffer to receive the current TCP\r
58 state. Optional parameter that may be NULL.\r
59 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP\r
60 configuration. Optional parameter that may be NULL.\r
61 @param[out] Ip4ModeData Pointer to the buffer to receive the current\r
62 IPv4 configuration. Optional parameter that may be NULL.\r
63 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP\r
64 configuration data indirectly used by the TCPv4\r
65 Instance. Optional parameter that may be NULL.\r
66 @param[out] SnpModeData Pointer to the buffer to receive the current SNP\r
67 configuration data indirectly used by the TCPv4\r
68 Instance. Optional parameter that may be NULL.\r
69\r
70 @retval EFI_SUCCESS The mode data was read.\r
71 @retval EFI_NOT_STARTED No configuration data is available because this\r
72 instance hasn't been started.\r
73 @retval EFI_INVALID_PARAMETER This is NULL.\r
74\r
75**/\r
76EFI_STATUS\r
77EFIAPI\r
78Tcp4GetModeData (\r
581900d9 79 IN EFI_TCP4_PROTOCOL *This,\r
80 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,\r
81 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,\r
82 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
83 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
84 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
a3bcde70
HT
85 )\r
86{\r
87 TCP4_MODE_DATA TcpMode;\r
88 SOCKET *Sock;\r
89\r
90 if (NULL == This) {\r
91 return EFI_INVALID_PARAMETER;\r
92 }\r
93\r
94 Sock = SOCK_FROM_THIS (This);\r
95\r
96 TcpMode.Tcp4State = Tcp4State;\r
97 TcpMode.Tcp4ConfigData = Tcp4ConfigData;\r
98 TcpMode.Ip4ModeData = Ip4ModeData;\r
99 TcpMode.MnpConfigData = MnpConfigData;\r
100 TcpMode.SnpModeData = SnpModeData;\r
101\r
102 return SockGetMode (Sock, &TcpMode);\r
103}\r
104\r
105/**\r
106 Initialize or brutally reset the operational parameters for\r
107 this EFI TCPv4 instance.\r
108\r
109 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
110 @param[in] TcpConfigData Pointer to the configure data to configure the\r
111 instance. Optional parameter that may be NULL.\r
112\r
113 @retval EFI_SUCCESS The operational settings were set, changed, or\r
114 reset successfully.\r
115 @retval EFI_NO_MAPPING When using a default address, configuration\r
116 (through DHCP, BOOTP, RARP, etc.) is not\r
117 finished.\r
118 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
119 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already\r
120 configured.\r
121 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
122 @retval EFI_UNSUPPORTED One or more of the control options are not\r
123 supported in the implementation.\r
124 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.\r
125\r
126**/\r
127EFI_STATUS\r
128EFIAPI\r
129Tcp4Configure (\r
130 IN EFI_TCP4_PROTOCOL * This,\r
131 IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL\r
132 )\r
133{\r
134 EFI_TCP4_OPTION *Option;\r
135 SOCKET *Sock;\r
136 EFI_STATUS Status;\r
137 IP4_ADDR Ip;\r
138 IP4_ADDR SubnetMask;\r
139\r
140 if (NULL == This) {\r
141 return EFI_INVALID_PARAMETER;\r
142 }\r
143\r
144 //\r
145 // Tcp protocol related parameter check will be conducted here\r
146 //\r
147 if (NULL != TcpConfigData) {\r
148\r
149 CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));\r
150 if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
151 return EFI_INVALID_PARAMETER;\r
152 }\r
153\r
154 if (TcpConfigData->AccessPoint.ActiveFlag && (0 == TcpConfigData->AccessPoint.RemotePort || (Ip == 0))) {\r
155 return EFI_INVALID_PARAMETER;\r
156 }\r
157\r
158 if (!TcpConfigData->AccessPoint.UseDefaultAddress) {\r
159\r
160 CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));\r
161 CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));\r
162 if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) {\r
163 return EFI_INVALID_PARAMETER;\r
164 }\r
165 }\r
166\r
167 Option = TcpConfigData->ControlOption;\r
168 if ((NULL != Option) && (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {\r
169 return EFI_UNSUPPORTED;\r
170 }\r
171 }\r
172\r
173 Sock = SOCK_FROM_THIS (This);\r
174\r
175 if (NULL == TcpConfigData) {\r
176 return SockFlush (Sock);\r
177 }\r
178\r
179 Status = SockConfigure (Sock, TcpConfigData);\r
180\r
181 if (EFI_NO_MAPPING == Status) {\r
182 Sock->ConfigureState = SO_NO_MAPPING;\r
183 }\r
184\r
185 return Status;\r
186}\r
187\r
188/**\r
189 Add or delete routing entries.\r
190\r
191 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
192 @param[in] DeleteRoute If TRUE, delete the specified route from routing\r
193 table; if FALSE, add the specified route to\r
194 routing table.\r
195 @param[in] SubnetAddress The destination network.\r
196 @param[in] SubnetMask The subnet mask for the destination network.\r
197 @param[in] GatewayAddress The gateway address for this route.\r
198\r
199 @retval EFI_SUCCESS The operation completed successfully.\r
200 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been\r
201 configured.\r
202 @retval EFI_NO_MAPPING When using a default address, configuration\r
203 (through DHCP, BOOTP, RARP, etc.) is not\r
204 finished.\r
205 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
206 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the\r
207 entry to the routing table.\r
208 @retval EFI_NOT_FOUND This route is not in the routing table.\r
209 @retval EFI_ACCESS_DENIED This route is already in the routing table.\r
210 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.\r
211\r
212**/\r
213EFI_STATUS\r
214EFIAPI\r
215Tcp4Routes (\r
216 IN EFI_TCP4_PROTOCOL *This,\r
217 IN BOOLEAN DeleteRoute,\r
218 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
219 IN EFI_IPv4_ADDRESS *SubnetMask,\r
220 IN EFI_IPv4_ADDRESS *GatewayAddress\r
221 )\r
222{\r
223 SOCKET *Sock;\r
224 TCP4_ROUTE_INFO RouteInfo;\r
225\r
226 if (NULL == This) {\r
227 return EFI_INVALID_PARAMETER;\r
228 }\r
229\r
230 Sock = SOCK_FROM_THIS (This);\r
231\r
232 RouteInfo.DeleteRoute = DeleteRoute;\r
2594a98e
FS
233 RouteInfo.SubnetAddress = SubnetAddress;\r
234 RouteInfo.SubnetMask = SubnetMask;\r
235 RouteInfo.GatewayAddress = GatewayAddress;\r
a3bcde70
HT
236\r
237 return SockRoute (Sock, &RouteInfo);\r
238}\r
239\r
240/**\r
241 Initiate a non-blocking TCP connection request for an active TCP instance.\r
242\r
243 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
244 @param[in] ConnectionToken Pointer to the connection token to return when\r
245 the TCP three way handshake finishes.\r
246\r
247 @retval EFI_SUCCESS The connection request successfully\r
248 initiated.\r
249 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been\r
250 configured.\r
251 @retval EFI_ACCESS_DENIED The instance is not configured as an active one,\r
252 or it is not in Tcp4StateClosed state.\r
253 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
254 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to\r
255 initiate the active open.\r
256 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
257\r
258**/\r
259EFI_STATUS\r
260EFIAPI\r
261Tcp4Connect (\r
262 IN EFI_TCP4_PROTOCOL *This,\r
263 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken\r
264 )\r
265{\r
266 SOCKET *Sock;\r
267\r
268 if (NULL == This || NULL == ConnectionToken || NULL == ConnectionToken->CompletionToken.Event) {\r
269 return EFI_INVALID_PARAMETER;\r
270 }\r
271\r
272 Sock = SOCK_FROM_THIS (This);\r
273\r
274 return SockConnect (Sock, ConnectionToken);\r
275}\r
276\r
277/**\r
278 Listen on the passive instance to accept an incoming connection request.\r
279\r
280 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
281 @param[in] ListenToken Pointer to the listen token to return when\r
282 operation finishes.\r
283\r
284 @retval EFI_SUCCESS The listen token was queued successfully.\r
285 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
286 configured.\r
287 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not\r
288 in Tcp4StateListen state or a same listen token\r
289 has already existed in the listen token queue of\r
290 this TCP instance.\r
291 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
292 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish\r
293 the operation.\r
294 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
295\r
296**/\r
297EFI_STATUS\r
298EFIAPI\r
299Tcp4Accept (\r
300 IN EFI_TCP4_PROTOCOL *This,\r
301 IN EFI_TCP4_LISTEN_TOKEN *ListenToken\r
302 )\r
303{\r
304 SOCKET *Sock;\r
305\r
306 if (NULL == This || NULL == ListenToken || NULL == ListenToken->CompletionToken.Event) {\r
307 return EFI_INVALID_PARAMETER;\r
308 }\r
309\r
310 Sock = SOCK_FROM_THIS (This);\r
311\r
312 return SockAccept (Sock, ListenToken);\r
313}\r
314\r
315/**\r
316 Queues outgoing data into the transmit queue\r
317\r
318 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
319 @param[in] Token Pointer to the completion token to queue to the\r
320 transmit queue.\r
321\r
322 @retval EFI_SUCCESS The data has been queued for transmission.\r
323 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
324 configured.\r
325 @retval EFI_NO_MAPPING When using a default address, configuration\r
326 (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
327 @retval EFI_INVALID_PARAMETER One or more parameters are invalid\r
328 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
329 * A transmit completion token with the same\r
330 Token-> CompletionToken.Event was already in the\r
331 transmission queue. * The current instance is in\r
332 Tcp4StateClosed state. * The current instance is\r
333 a passive one and it is in Tcp4StateListen\r
334 state. * User has called Close() to disconnect\r
335 this connection.\r
336 @retval EFI_NOT_READY The completion token could not be queued because\r
337 the transmit queue is full.\r
338 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a\r
339 resource shortage.\r
340 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or\r
341 address.\r
342\r
343**/\r
344EFI_STATUS\r
345EFIAPI\r
346Tcp4Transmit (\r
347 IN EFI_TCP4_PROTOCOL *This,\r
348 IN EFI_TCP4_IO_TOKEN *Token\r
349 )\r
350{\r
351 SOCKET *Sock;\r
352 EFI_STATUS Status;\r
353\r
354 if (NULL == This ||\r
355 NULL == Token ||\r
356 NULL == Token->CompletionToken.Event ||\r
357 NULL == Token->Packet.TxData ||\r
358 0 == Token->Packet.TxData->FragmentCount ||\r
359 0 == Token->Packet.TxData->DataLength\r
360 ) {\r
361 return EFI_INVALID_PARAMETER;\r
362 }\r
363\r
364 Status = TcpChkDataBuf (\r
365 Token->Packet.TxData->DataLength,\r
366 Token->Packet.TxData->FragmentCount,\r
367 Token->Packet.TxData->FragmentTable\r
368 );\r
369 if (EFI_ERROR (Status)) {\r
370 return Status;\r
371 }\r
372\r
373 Sock = SOCK_FROM_THIS (This);\r
374\r
375 return SockSend (Sock, Token);\r
376}\r
377\r
378/**\r
379 Place an asynchronous receive request into the receiving queue.\r
380\r
381 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
382 @param[in] Token Pointer to a token that is associated with the\r
383 receive data descriptor.\r
384\r
385 @retval EFI_SUCCESS The receive completion token was cached\r
386 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
387 configured.\r
388 @retval EFI_NO_MAPPING When using a default address, configuration\r
389 (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
390 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
391 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued\r
392 due to a lack of system resources.\r
393 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
394 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
395 * A receive completion token with the same\r
396 Token->CompletionToken.Event was already in the\r
397 receive queue. * The current instance is in\r
398 Tcp4StateClosed state. * The current instance is\r
399 a passive one and it is in Tcp4StateListen\r
400 state. * User has called Close() to disconnect\r
401 this connection.\r
402 @retval EFI_CONNECTION_FIN The communication peer has closed the connection,\r
403 and there is no any buffered data in the receive\r
404 buffer of this instance.\r
405 @retval EFI_NOT_READY The receive request could not be queued because\r
406 the receive queue is full.\r
407\r
408**/\r
409EFI_STATUS\r
410EFIAPI\r
411Tcp4Receive (\r
412 IN EFI_TCP4_PROTOCOL *This,\r
413 IN EFI_TCP4_IO_TOKEN *Token\r
414 )\r
415{\r
416 SOCKET *Sock;\r
417 EFI_STATUS Status;\r
418\r
419 if (NULL == This ||\r
420 NULL == Token ||\r
421 NULL == Token->CompletionToken.Event ||\r
422 NULL == Token->Packet.RxData ||\r
423 0 == Token->Packet.RxData->FragmentCount ||\r
424 0 == Token->Packet.RxData->DataLength\r
425 ) {\r
426 return EFI_INVALID_PARAMETER;\r
427 }\r
428\r
429 Status = TcpChkDataBuf (\r
430 Token->Packet.RxData->DataLength,\r
431 Token->Packet.RxData->FragmentCount,\r
432 Token->Packet.RxData->FragmentTable\r
433 );\r
434 if (EFI_ERROR (Status)) {\r
435 return Status;\r
436 }\r
437\r
438 Sock = SOCK_FROM_THIS (This);\r
439\r
440 return SockRcv (Sock, Token);\r
441\r
442}\r
443\r
444/**\r
445 Disconnecting a TCP connection gracefully or reset a TCP connection.\r
446\r
447 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
448 @param[in] CloseToken Pointer to the close token to return when\r
449 operation finishes.\r
450\r
451 @retval EFI_SUCCESS The operation completed successfully.\r
452 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r
453 configured.\r
454 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *\r
455 Configure() has been called with TcpConfigData\r
456 set to NULL, and this function has not returned.\r
457 * Previous Close() call on this instance has not\r
458 finished.\r
459 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.\r
460 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the\r
461 operation.\r
462 @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those\r
463 listed above.\r
464\r
465**/\r
466EFI_STATUS\r
467EFIAPI\r
468Tcp4Close (\r
469 IN EFI_TCP4_PROTOCOL *This,\r
470 IN EFI_TCP4_CLOSE_TOKEN *CloseToken\r
471 )\r
472{\r
473 SOCKET *Sock;\r
474\r
475 if (NULL == This || NULL == CloseToken || NULL == CloseToken->CompletionToken.Event) {\r
476 return EFI_INVALID_PARAMETER;\r
477 }\r
478\r
479 Sock = SOCK_FROM_THIS (This);\r
480\r
481 return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);\r
482}\r
483\r
484/**\r
485 Abort an asynchronous connection, listen, transmission or receive request.\r
486\r
5ffe214a
JW
487 @param This The pointer to the EFI_TCP4_PROTOCOL instance.\r
488 @param Token The pointer to a token that has been issued by\r
489 EFI_TCP4_PROTOCOL.Connect(),\r
490 EFI_TCP4_PROTOCOL.Accept(),\r
491 EFI_TCP4_PROTOCOL.Transmit() or\r
492 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r
493 tokens issued by above four functions will be aborted. Type\r
494 EFI_TCP4_COMPLETION_TOKEN is defined in\r
495 EFI_TCP4_PROTOCOL.Connect().\r
496\r
497 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
498 is signaled.\r
499 @retval EFI_INVALID_PARAMETER This is NULL.\r
500 @retval EFI_NOT_STARTED This instance hasn't been configured.\r
501 @retval EFI_NO_MAPPING When using the default address, configuration\r
502 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.\r
503 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the\r
504 transmission or receive queue. It has either\r
505 completed or wasn't issued by Transmit() and Receive().\r
a3bcde70
HT
506\r
507**/\r
508EFI_STATUS\r
509EFIAPI\r
510Tcp4Cancel (\r
511 IN EFI_TCP4_PROTOCOL *This,\r
512 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r
513 )\r
514{\r
5ffe214a
JW
515 SOCKET *Sock;\r
516\r
517 if (NULL == This) {\r
518 return EFI_INVALID_PARAMETER;\r
519 }\r
520\r
521 Sock = SOCK_FROM_THIS (This);\r
522\r
523 return SockCancel (Sock, Token);\r
a3bcde70
HT
524}\r
525\r
526/**\r
527 Poll to receive incoming data and transmit outgoing segments.\r
528\r
529 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r
530\r
531 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
532 @retval EFI_INVALID_PARAMETER This is NULL.\r
533 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
534 @retval EFI_NOT_READY No incoming or outgoing data was processed.\r
535 @retval EFI_TIMEOUT Data was dropped out of the transmission or\r
536 receive queue. Consider increasing the polling\r
537 rate.\r
538\r
539**/\r
540EFI_STATUS\r
541EFIAPI\r
542Tcp4Poll (\r
543 IN EFI_TCP4_PROTOCOL *This\r
544 )\r
545{\r
546 SOCKET *Sock;\r
547 EFI_STATUS Status;\r
548\r
549 if (NULL == This) {\r
550 return EFI_INVALID_PARAMETER;\r
551 }\r
552\r
553 Sock = SOCK_FROM_THIS (This);\r
554\r
555 Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);\r
556\r
557 return Status;\r
558}\r
559\r
560/**\r
561 Get the current operational status.\r
562\r
563 The GetModeData() function copies the current operational settings of this EFI TCPv6\r
564 Protocol instance into user-supplied buffers. This function can also be used to retrieve\r
565 the operational setting of underlying drivers such as IPv6, MNP, or SNP.\r
566\r
567 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
568 @param[out] Tcp6State The buffer in which the current TCP state is\r
569 returned. Optional parameter that may be NULL.\r
570 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration\r
571 is returned. Optional parameter that may be NULL.\r
572 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration\r
573 data used by the TCP instance is returned.\r
574 Optional parameter that may be NULL.\r
575 @param[out] MnpConfigData The buffer in which the current MNP configuration\r
576 data indirectly used by the TCP instance is returned.\r
577 Optional parameter that may be NULL.\r
578 @param[out] SnpModeData The buffer in which the current SNP mode data\r
579 indirectly used by the TCP instance is returned.\r
580 Optional parameter that may be NULL.\r
581\r
582 @retval EFI_SUCCESS The mode data was read.\r
583 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't\r
584 been started.\r
585 @retval EFI_INVALID_PARAMETER This is NULL.\r
586\r
587**/\r
588EFI_STATUS\r
589EFIAPI\r
590Tcp6GetModeData (\r
591 IN EFI_TCP6_PROTOCOL *This,\r
592 OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,\r
593 OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,\r
594 OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,\r
595 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
596 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
597 )\r
598{\r
599 TCP6_MODE_DATA TcpMode;\r
600 SOCKET *Sock;\r
601\r
602 if (NULL == This) {\r
603 return EFI_INVALID_PARAMETER;\r
604 }\r
605\r
606 Sock = SOCK_FROM_THIS (This);\r
607\r
608 TcpMode.Tcp6State = Tcp6State;\r
609 TcpMode.Tcp6ConfigData = Tcp6ConfigData;\r
610 TcpMode.Ip6ModeData = Ip6ModeData;\r
611 TcpMode.MnpConfigData = MnpConfigData;\r
612 TcpMode.SnpModeData = SnpModeData;\r
613\r
614 return SockGetMode (Sock, &TcpMode);\r
615}\r
616\r
617/**\r
618 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.\r
619\r
620 The Configure() function does the following:\r
621 - Initialize this TCP instance, i.e., initialize the communication end settings and\r
622 specify active open or passive open for an instance.\r
623 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush\r
624 transmission and receiving buffer directly without informing the communication peer.\r
625\r
626 No other TCPv6 Protocol operation except Poll() can be executed by this instance until\r
627 it is configured properly. For an active TCP instance, after a proper configuration it\r
628 may call Connect() to initiate a three-way handshake. For a passive TCP instance,\r
629 its state transits to Tcp6StateListen after configuration, and Accept() may be\r
630 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,\r
631 the instance is reset. The resetting process will be done brutally, the state machine will\r
632 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,\r
633 and no traffic is allowed through this instance.\r
634\r
635 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
636 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.\r
637 If Tcp6ConfigData is set to NULL, the instance is reset.\r
638\r
639 @retval EFI_SUCCESS The operational settings were set, changed, or reset\r
640 successfully.\r
641 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
642 address for this instance, but no source address was available for\r
643 use.\r
644 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:\r
645 - This is NULL.\r
646 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor\r
647 one of the configured IP addresses in the underlying IPv6 driver.\r
648 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast\r
649 IPv6 address.\r
650 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or\r
651 Tcp6ConfigData->AccessPoint.RemotePort is zero when\r
652 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.\r
653 - A same access point has been configured in other TCP\r
654 instance properly.\r
655 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without\r
656 calling Configure() with NULL to reset it.\r
657 @retval EFI_UNSUPPORTED One or more of the control options are not supported in\r
658 the implementation.\r
659 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
660 executing Configure().\r
661 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
662\r
663**/\r
664EFI_STATUS\r
665EFIAPI\r
666Tcp6Configure (\r
667 IN EFI_TCP6_PROTOCOL *This,\r
668 IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL\r
669 )\r
670{\r
671 EFI_TCP6_OPTION *Option;\r
672 SOCKET *Sock;\r
673 EFI_STATUS Status;\r
674 EFI_IPv6_ADDRESS *Ip;\r
675\r
676 if (NULL == This) {\r
677 return EFI_INVALID_PARAMETER;\r
678 }\r
679\r
680 //\r
681 // Tcp protocol related parameter check will be conducted here\r
682 //\r
683 if (NULL != Tcp6ConfigData) {\r
684\r
685 Ip = &Tcp6ConfigData->AccessPoint.RemoteAddress;\r
686 if (!NetIp6IsUnspecifiedAddr (Ip) && !NetIp6IsValidUnicast (Ip)) {\r
687 return EFI_INVALID_PARAMETER;\r
688 }\r
689\r
690 if (Tcp6ConfigData->AccessPoint.ActiveFlag &&\r
691 (0 == Tcp6ConfigData->AccessPoint.RemotePort || NetIp6IsUnspecifiedAddr (Ip))\r
692 ) {\r
693 return EFI_INVALID_PARAMETER;\r
694 }\r
695\r
696 Ip = &Tcp6ConfigData->AccessPoint.StationAddress;\r
697 if (!NetIp6IsUnspecifiedAddr (Ip) && !NetIp6IsValidUnicast (Ip)) {\r
698 return EFI_INVALID_PARAMETER;\r
699 }\r
700\r
701 Option = Tcp6ConfigData->ControlOption;\r
702 if ((NULL != Option) && (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {\r
703 return EFI_UNSUPPORTED;\r
704 }\r
705 }\r
706\r
707 Sock = SOCK_FROM_THIS (This);\r
708\r
709 if (NULL == Tcp6ConfigData) {\r
710 return SockFlush (Sock);\r
711 }\r
712\r
713 Status = SockConfigure (Sock, Tcp6ConfigData);\r
714\r
715 if (EFI_NO_MAPPING == Status) {\r
716 Sock->ConfigureState = SO_NO_MAPPING;\r
717 }\r
718\r
719 return Status;\r
720}\r
721\r
722/**\r
723 Initiate a nonblocking TCP connection request for an active TCP instance.\r
724\r
725 The Connect() function will initiate an active open to the remote peer configured\r
726 in a current TCP instance if it is configured active. If the connection succeeds or\r
727 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled\r
728 and ConnectionToken->CompletionToken.Status will be updated accordingly. This\r
729 function can only be called for the TCP instance in the Tcp6StateClosed state. The\r
730 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.\r
731 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.\r
732 Otherwise, the state will return to Tcp6StateClosed.\r
733\r
734 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
735 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three\r
736 way handshake finishes.\r
737\r
738 @retval EFI_SUCCESS The connection request successfully initiated and the state of\r
739 this TCP instance has been changed to Tcp6StateSynSent.\r
740 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r
741 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:\r
742 - This instance is not configured as an active one.\r
743 - This instance is not in Tcp6StateClosed state.\r
744 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
745 - This is NULL.\r
746 - ConnectionToken is NULL.\r
747 - ConnectionToken->CompletionToken.Event is NULL.\r
748 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.\r
749 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
750\r
751**/\r
752EFI_STATUS\r
753EFIAPI\r
754Tcp6Connect (\r
755 IN EFI_TCP6_PROTOCOL *This,\r
756 IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken\r
757 )\r
758{\r
759 SOCKET *Sock;\r
760\r
761 if (NULL == This || NULL == ConnectionToken || NULL == ConnectionToken->CompletionToken.Event) {\r
762 return EFI_INVALID_PARAMETER;\r
763 }\r
764\r
765 Sock = SOCK_FROM_THIS (This);\r
766\r
767 return SockConnect (Sock, ConnectionToken);\r
768}\r
769\r
770/**\r
771 Listen on the passive instance to accept an incoming connection request. This is a\r
772 nonblocking operation.\r
773\r
774 The Accept() function initiates an asynchronous accept request to wait for an incoming\r
775 connection on the passive TCP instance. If a remote peer successfully establishes a\r
776 connection with this instance, a new TCP instance will be created and its handle will\r
777 be returned in ListenToken->NewChildHandle. The newly created instance is configured\r
778 by inheriting the passive instance's configuration and is ready for use upon return.\r
779 The new instance is in the Tcp6StateEstablished state.\r
780\r
781 The ListenToken->CompletionToken.Event will be signaled when a new connection is\r
782 accepted, when a user aborts the listen or when a connection is reset.\r
783\r
784 This function only can be called when a current TCP instance is in Tcp6StateListen state.\r
785\r
786 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
787 @param[in] ListenToken Pointer to the listen token to return when operation finishes.\r
788\r
789\r
790 @retval EFI_SUCCESS The listen token queued successfully.\r
791 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r
792 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r
793 - This instance is not a passive instance.\r
794 - This instance is not in Tcp6StateListen state.\r
795 - The same listen token has already existed in the listen\r
796 token queue of this TCP instance.\r
797 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
798 - This is NULL.\r
799 - ListenToken is NULL.\r
800 - ListentToken->CompletionToken.Event is NULL.\r
801 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r
802 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.\r
803\r
804**/\r
805EFI_STATUS\r
806EFIAPI\r
807Tcp6Accept (\r
808 IN EFI_TCP6_PROTOCOL *This,\r
809 IN EFI_TCP6_LISTEN_TOKEN *ListenToken\r
810 )\r
811{\r
812 SOCKET *Sock;\r
813\r
814 if (NULL == This || NULL == ListenToken || NULL == ListenToken->CompletionToken.Event) {\r
815 return EFI_INVALID_PARAMETER;\r
816 }\r
817\r
818 Sock = SOCK_FROM_THIS (This);\r
819\r
820 return SockAccept (Sock, ListenToken);\r
821}\r
822\r
823/**\r
824 Queues outgoing data into the transmit queue.\r
825\r
826 The Transmit() function queues a sending request to this TCP instance along with the\r
827 user data. The status of the token is updated and the event in the token will be\r
828 signaled once the data is sent out or an error occurs.\r
829\r
830 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
831 @param[in] Token Pointer to the completion token to queue to the transmit queue.\r
832\r
833 @retval EFI_SUCCESS The data has been queued for transmission.\r
834 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r
835 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a\r
836 source address for this instance, but no source address was\r
837 available for use.\r
838 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
839 - This is NULL.\r
840 - Token is NULL.\r
841 - Token->CompletionToken.Event is NULL.\r
842 - Token->Packet.TxData is NULL.\r
843 - Token->Packet.FragmentCount is zero.\r
844 - Token->Packet.DataLength is not equal to the sum of fragment lengths.\r
845 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:\r
846 - A transmit completion token with the same Token->\r
847 CompletionToken.Event was already in the\r
848 transmission queue.\r
849 - The current instance is in Tcp6StateClosed state.\r
850 - The current instance is a passive one and it is in\r
851 Tcp6StateListen state.\r
852 - User has called Close() to disconnect this connection.\r
853 @retval EFI_NOT_READY The completion token could not be queued because the\r
854 transmit queue is full.\r
855 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource\r
856 shortage.\r
857 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.\r
858\r
859**/\r
860EFI_STATUS\r
861EFIAPI\r
862Tcp6Transmit (\r
863 IN EFI_TCP6_PROTOCOL *This,\r
864 IN EFI_TCP6_IO_TOKEN *Token\r
865 )\r
866{\r
867 SOCKET *Sock;\r
868 EFI_STATUS Status;\r
869\r
870 if (NULL == This ||\r
871 NULL == Token ||\r
872 NULL == Token->CompletionToken.Event ||\r
873 NULL == Token->Packet.TxData ||\r
874 0 == Token->Packet.TxData->FragmentCount ||\r
875 0 == Token->Packet.TxData->DataLength\r
876 ) {\r
877 return EFI_INVALID_PARAMETER;\r
878 }\r
879\r
880 Status = TcpChkDataBuf (\r
881 Token->Packet.TxData->DataLength,\r
882 Token->Packet.TxData->FragmentCount,\r
883 (EFI_TCP4_FRAGMENT_DATA *) Token->Packet.TxData->FragmentTable\r
884 );\r
885 if (EFI_ERROR (Status)) {\r
886 return Status;\r
887 }\r
888\r
889 Sock = SOCK_FROM_THIS (This);\r
890\r
891 return SockSend (Sock, Token);\r
892}\r
893\r
894/**\r
895 Places an asynchronous receive request into the receiving queue.\r
896\r
897 The Receive() function places a completion token into the receive packet queue. This\r
898 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event\r
899 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that\r
900 represents the whole length of all FragmentBuffer. When the receive operation completes, the\r
901 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData\r
902 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length\r
903 will be copied into the FragmentTable; at the same time the full length of received data will\r
904 be recorded in the DataLength fields. Providing a proper notification function and context\r
905 for the event enables the user to receive the notification and receiving status. That\r
906 notification function is guaranteed to not be re-entered.\r
907\r
908 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
909 @param[in] Token Pointer to a token that is associated with the receive data\r
910 descriptor.\r
911\r
912 @retval EFI_SUCCESS The receive completion token was cached.\r
913 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r
914 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
915 address for this instance, but no source address was available for use.\r
916 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
917 - This is NULL.\r
918 - Token is NULL.\r
919 - Token->CompletionToken.Event is NULL.\r
920 - Token->Packet.RxData is NULL.\r
921 - Token->Packet.RxData->DataLength is 0.\r
922 - The Token->Packet.RxData->DataLength is not the\r
923 sum of all FragmentBuffer length in FragmentTable.\r
924 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of\r
925 system resources (usually memory).\r
926 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
927 The EFI TCPv6 Protocol instance has been reset to startup defaults.\r
928 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
929 - A receive completion token with the same Token->CompletionToken.Event\r
930 was already in the receive queue.\r
931 - The current instance is in Tcp6StateClosed state.\r
932 - The current instance is a passive one and it is in\r
933 Tcp6StateListen state.\r
934 - User has called Close() to disconnect this connection.\r
935 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no\r
936 buffered data in the receive buffer of this instance.\r
937 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
938\r
939**/\r
940EFI_STATUS\r
941EFIAPI\r
942Tcp6Receive (\r
943 IN EFI_TCP6_PROTOCOL *This,\r
944 IN EFI_TCP6_IO_TOKEN *Token\r
945 )\r
946{\r
947 SOCKET *Sock;\r
948 EFI_STATUS Status;\r
949\r
950 if (NULL == This ||\r
951 NULL == Token ||\r
952 NULL == Token->CompletionToken.Event ||\r
953 NULL == Token->Packet.RxData ||\r
954 0 == Token->Packet.RxData->FragmentCount ||\r
955 0 == Token->Packet.RxData->DataLength\r
956 ) {\r
957 return EFI_INVALID_PARAMETER;\r
958 }\r
959\r
960 Status = TcpChkDataBuf (\r
961 Token->Packet.RxData->DataLength,\r
962 Token->Packet.RxData->FragmentCount,\r
963 (EFI_TCP4_FRAGMENT_DATA *) Token->Packet.RxData->FragmentTable\r
964 );\r
965 if (EFI_ERROR (Status)) {\r
966 return Status;\r
967 }\r
968\r
969 Sock = SOCK_FROM_THIS (This);\r
970\r
971 return SockRcv (Sock, Token);\r
972}\r
973\r
974/**\r
975 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a\r
976 nonblocking operation.\r
977\r
978 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered\r
979 transmission data will be sent by the TCP driver, and the current instance will have a graceful close\r
980 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet\r
981 will be sent by TCP driver to fast disconnect this connection. When the close operation completes\r
982 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous\r
983 operations are signaled, and any buffers used for TCP network traffic are flushed.\r
984\r
985 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
986 @param[in] CloseToken Pointer to the close token to return when operation finishes.\r
987\r
988 @retval EFI_SUCCESS The Close() was called successfully.\r
989 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r
990 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r
991 - CloseToken or CloseToken->CompletionToken.Event is already in use.\r
992 - Previous Close() call on this instance has not finished.\r
993 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
994 - This is NULL.\r
995 - CloseToken is NULL.\r
996 - CloseToken->CompletionToken.Event is NULL.\r
997 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r
998 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.\r
999\r
1000**/\r
1001EFI_STATUS\r
1002EFIAPI\r
1003Tcp6Close (\r
1004 IN EFI_TCP6_PROTOCOL *This,\r
1005 IN EFI_TCP6_CLOSE_TOKEN *CloseToken\r
1006 )\r
1007{\r
1008 SOCKET *Sock;\r
1009\r
1010 if (NULL == This || NULL == CloseToken || NULL == CloseToken->CompletionToken.Event) {\r
1011 return EFI_INVALID_PARAMETER;\r
1012 }\r
1013\r
1014 Sock = SOCK_FROM_THIS (This);\r
1015\r
1016 return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);\r
1017}\r
1018\r
1019/**\r
5ffe214a 1020 Abort an asynchronous connection, listen, transmission or receive request.\r
a3bcde70 1021\r
5ffe214a 1022 The Cancel() function aborts a pending connection, listen, transmit or\r
a3bcde70
HT
1023 receive request.\r
1024\r
5ffe214a 1025 If Token is not NULL and the token is in the connection, listen, transmission\r
a3bcde70 1026 or receive queue when it is being cancelled, its Token->Status will be set\r
5ffe214a 1027 to EFI_ABORTED and then Token->Event will be signaled.\r
a3bcde70
HT
1028\r
1029 If the token is not in one of the queues, which usually means that the\r
1030 asynchronous operation has completed, EFI_NOT_FOUND is returned.\r
1031\r
1032 If Token is NULL all asynchronous token issued by Connect(), Accept(),\r
5ffe214a 1033 Transmit() and Receive() will be aborted.\r
a3bcde70
HT
1034\r
1035 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
1036 @param[in] Token Pointer to a token that has been issued by\r
1037 EFI_TCP6_PROTOCOL.Connect(),\r
1038 EFI_TCP6_PROTOCOL.Accept(),\r
1039 EFI_TCP6_PROTOCOL.Transmit() or\r
1040 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending\r
1041 tokens issued by above four functions will be aborted. Type\r
1042 EFI_TCP6_COMPLETION_TOKEN is defined in\r
1043 EFI_TCP_PROTOCOL.Connect().\r
1044\r
5ffe214a
JW
1045 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r
1046 is signaled.\r
1047 @retval EFI_INVALID_PARAMETER This is NULL.\r
1048 @retval EFI_NOT_STARTED This instance hasn't been configured.\r
1049 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or\r
1050 receive queue. It has either completed or wasn't issued by\r
1051 Transmit() and Receive().\r
a3bcde70
HT
1052\r
1053**/\r
1054EFI_STATUS\r
1055EFIAPI\r
1056Tcp6Cancel (\r
1057 IN EFI_TCP6_PROTOCOL *This,\r
1058 IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL\r
1059 )\r
1060{\r
5ffe214a
JW
1061 SOCKET *Sock;\r
1062\r
1063 if (NULL == This) {\r
1064 return EFI_INVALID_PARAMETER;\r
1065 }\r
1066\r
1067 Sock = SOCK_FROM_THIS (This);\r
1068\r
1069 return SockCancel (Sock, Token);\r
a3bcde70
HT
1070}\r
1071\r
1072/**\r
1073 Poll to receive incoming data and transmit outgoing segments.\r
1074\r
1075 The Poll() function increases the rate that data is moved between the network\r
1076 and application, and can be called when the TCP instance is created successfully.\r
1077 Its use is optional.\r
1078\r
1079 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r
1080\r
1081 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
1082 @retval EFI_INVALID_PARAMETER This is NULL.\r
1083 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
1084 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
1085 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.\r
1086 Consider increasing the polling rate.\r
1087\r
1088**/\r
1089EFI_STATUS\r
1090EFIAPI\r
1091Tcp6Poll (\r
1092 IN EFI_TCP6_PROTOCOL *This\r
1093 )\r
1094{\r
1095 SOCKET *Sock;\r
1096 EFI_STATUS Status;\r
1097\r
1098 if (NULL == This) {\r
1099 return EFI_INVALID_PARAMETER;\r
1100 }\r
1101\r
1102 Sock = SOCK_FROM_THIS (This);\r
1103\r
1104 Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);\r
1105\r
1106 return Status;\r
1107}\r
1108\r