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