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