]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Main.c
1 /** @file
2 Implementation of TCP4 protocol services.
3
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php<BR>
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15
16 #include "Tcp4Main.h"
17
18
19 /**
20 Check the integrity of the data buffer.
21
22 @param DataLen The total length of the data buffer.
23 @param FragmentCount The fragment count of the fragment table.
24 @param FragmentTable Pointer to the fragment table of the data
25 buffer.
26
27 @retval EFI_SUCCESS The integrity check is passed.
28 @retval EFI_INVALID_PARAMETER The integrity check is failed.
29
30 **/
31 EFI_STATUS
32 Tcp4ChkDataBuf (
33 IN UINT32 DataLen,
34 IN UINT32 FragmentCount,
35 IN EFI_TCP4_FRAGMENT_DATA *FragmentTable
36 )
37 {
38 UINT32 Index;
39
40 UINT32 Len;
41
42 for (Index = 0, Len = 0; Index < FragmentCount; Index++) {
43 Len = Len + (UINT32) FragmentTable[Index].FragmentLength;
44 }
45
46 if (DataLen != Len) {
47 return EFI_INVALID_PARAMETER;
48 }
49
50 return EFI_SUCCESS;
51 }
52
53
54 /**
55 Get the current operational status.
56
57 The GetModeData() function copies the current operational settings of this
58 EFI TCPv4 Protocol instance into user-supplied buffers. This function can
59 also be used to retrieve the operational setting of underlying drivers
60 such as IPv4, MNP, or SNP.
61
62 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
63 @param Tcp4State Pointer to the buffer to receive the current TCP
64 state.
65 @param Tcp4ConfigData Pointer to the buffer to receive the current TCP
66 configuration.
67 @param Ip4ModeData Pointer to the buffer to receive the current IPv4
68 configuration data used by the TCPv4 instance.
69 @param MnpConfigData Pointer to the buffer to receive the current MNP
70 configuration data indirectly used by the TCPv4
71 Instance.
72 @param SnpModeData Pointer to the buffer to receive the current SNP
73 configuration data indirectly used by the TCPv4
74 Instance.
75
76 @retval EFI_SUCCESS The mode data was read.
77 @retval EFI_NOT_STARTED No configuration data is available because this
78 instance hasn't been started.
79 @retval EFI_INVALID_PARAMETER This is NULL.
80
81 **/
82 EFI_STATUS
83 EFIAPI
84 Tcp4GetModeData (
85 IN EFI_TCP4_PROTOCOL *This,
86 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
87 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
88 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
89 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
90 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
91 )
92 {
93 TCP4_MODE_DATA TcpMode;
94 SOCKET *Sock;
95
96 if (NULL == This) {
97 return EFI_INVALID_PARAMETER;
98 }
99
100 Sock = SOCK_FROM_THIS (This);
101
102 TcpMode.Tcp4State = Tcp4State;
103 TcpMode.Tcp4ConfigData = Tcp4ConfigData;
104 TcpMode.Ip4ModeData = Ip4ModeData;
105 TcpMode.MnpConfigData = MnpConfigData;
106 TcpMode.SnpModeData = SnpModeData;
107
108 return SockGetMode (Sock, &TcpMode);
109 }
110
111
112 /**
113 Initialize or brutally reset the operational parameters for
114 this EFI TCPv4 instance.
115
116 The Configure() function does the following:
117 * Initialize this EFI TCPv4 instance, i.e., initialize the communication end
118 setting, specify active open or passive open for an instance.
119 * Reset this TCPv4 instance brutally, i.e., cancel all pending asynchronous
120 tokens, flush transmission and receiving buffer directly without informing
121 the communication peer.
122 No other TCPv4 Protocol operation can be executed by this instance
123 until it is configured properly. For an active TCP4 instance, after a proper
124 configuration it may call Connect() to initiates the three-way handshake.
125 For a passive TCP4 instance, its state will transit to Tcp4StateListen after
126 configuration, and Accept() may be called to listen the incoming TCP connection
127 request. If TcpConfigData is set to NULL, the instance is reset. Resetting
128 process will be done brutally, the state machine will be set to Tcp4StateClosed
129 directly, the receive queue and transmit queue will be flushed, and no traffic is
130 allowed through this instance.
131
132 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
133 @param TcpConfigData Pointer to the configure data to configure the
134 instance.
135
136 @retval EFI_SUCCESS The operational settings are set, changed, or
137 reset successfully.
138 @retval EFI_NO_MAPPING When using a default address, configuration
139 (through DHCP, BOOTP, RARP, etc.) is not
140 finished.
141 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
142 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already
143 configured.
144 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
145 @retval EFI_UNSUPPORTED One or more of the control options are not
146 supported in the implementation.
147 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
148
149 **/
150 EFI_STATUS
151 EFIAPI
152 Tcp4Configure (
153 IN EFI_TCP4_PROTOCOL *This,
154 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
155 )
156 {
157 EFI_TCP4_OPTION *Option;
158 SOCKET *Sock;
159 EFI_STATUS Status;
160 IP4_ADDR Ip;
161 IP4_ADDR SubnetMask;
162
163 if (NULL == This) {
164 return EFI_INVALID_PARAMETER;
165 }
166
167 //
168 // Tcp protocol related parameter check will be conducted here
169 //
170 if (NULL != TcpConfigData) {
171
172 CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));
173 if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
174 return EFI_INVALID_PARAMETER;
175 }
176
177 if (TcpConfigData->AccessPoint.ActiveFlag &&
178 (0 == TcpConfigData->AccessPoint.RemotePort || (Ip == 0))) {
179 return EFI_INVALID_PARAMETER;
180 }
181
182 if (!TcpConfigData->AccessPoint.UseDefaultAddress) {
183
184 CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));
185 CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));
186 if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) ||
187 (SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) {
188 return EFI_INVALID_PARAMETER;
189 }
190 }
191
192 Option = TcpConfigData->ControlOption;
193 if ((NULL != Option) &&
194 (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {
195 return EFI_UNSUPPORTED;
196 }
197 }
198
199 Sock = SOCK_FROM_THIS (This);
200
201 if (NULL == TcpConfigData) {
202 return SockFlush (Sock);
203 }
204
205 Status = SockConfigure (Sock, TcpConfigData);
206
207 if (EFI_NO_MAPPING == Status) {
208 Sock->ConfigureState = SO_NO_MAPPING;
209 }
210
211 return Status;
212 }
213
214
215 /**
216 Add or delete routing entries.
217
218 The Routes() function adds or deletes a route from the instance's routing table.
219 The most specific route is selected by comparing the SubnetAddress with the
220 destination IP address's arithmetical AND to the SubnetMask.
221 The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0.
222 The default route matches all destination IP addresses if there is no more specific route.
223 Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to
224 the destination host if its address can be found in the Address Resolution Protocol (ARP)
225 cache or it is on the local subnet. If the instance is configured to use default
226 address, a direct route to the local network will be added automatically.
227 Each TCP instance has its own independent routing table. Instance that uses the
228 default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table.
229 The copy will be updated automatically whenever the IP driver reconfigures its
230 instance. As a result, the previous modification to the instance's local copy
231 will be lost. The priority of checking the route table is specific with IP
232 implementation and every IP implementation must comply with RFC 1122.
233
234 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
235 @param DeleteRoute If TRUE, delete the specified route from routing
236 table; if FALSE, add the specified route to
237 routing table.
238 DestinationAddress and SubnetMask are used as
239 the keywords to search route entry.
240 @param SubnetAddress The destination network.
241 @param SubnetMask The subnet mask for the destination network.
242 @param GatewayAddress The gateway address for this route.
243 It must be on the same subnet with the station
244 address unless a direct route is specified.
245
246 @retval EFI_SUCCESS The operation completed successfully.
247 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
248 configured.
249 @retval EFI_NO_MAPPING When using a default address, configuration
250 (through DHCP, BOOTP, RARP, etc.) is not
251 finished.
252 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
253 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
254 entry to the routing table.
255 @retval EFI_NOT_FOUND This route is not in the routing table.
256 @retval EFI_ACCESS_DENIED This route is already in the routing table.
257 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
258
259 **/
260 EFI_STATUS
261 EFIAPI
262 Tcp4Routes (
263 IN EFI_TCP4_PROTOCOL *This,
264 IN BOOLEAN DeleteRoute,
265 IN EFI_IPv4_ADDRESS *SubnetAddress,
266 IN EFI_IPv4_ADDRESS *SubnetMask,
267 IN EFI_IPv4_ADDRESS *GatewayAddress
268 )
269 {
270 SOCKET *Sock;
271 TCP4_ROUTE_INFO RouteInfo;
272
273 if (NULL == This) {
274 return EFI_INVALID_PARAMETER;
275 }
276
277 Sock = SOCK_FROM_THIS (This);
278
279 RouteInfo.DeleteRoute = DeleteRoute;
280 RouteInfo.SubnetAddress = SubnetAddress;
281 RouteInfo.SubnetMask = SubnetMask;
282 RouteInfo.GatewayAddress = GatewayAddress;
283
284 return SockRoute (Sock, &RouteInfo);
285 }
286
287
288 /**
289 Initiate a nonblocking TCP connection request for an active TCP instance.
290
291 The Connect() function will initiate an active open to the remote peer configured
292 in current TCP instance if it is configured active. If the connection succeeds
293 or fails due to any error, the ConnectionToken->CompletionToken.Event will be
294 signaled and ConnectionToken->CompletionToken.Status will be updated accordingly.
295 This function can only be called for the TCP instance in Tcp4StateClosed state.
296 The instance will transfer into Tcp4StateSynSent if the function returns EFI_SUCCESS.
297 If TCP three way handshake succeeds, its state will become Tcp4StateEstablished,
298 otherwise, the state will return to Tcp4StateClosed.
299
300 @param This Pointer to the EFI_TCP4_PROTOCOL instance
301 @param ConnectionToken Pointer to the connection token to return when
302 the TCP three way handshake finishes.
303
304 @retval EFI_SUCCESS The connection request is successfully initiated
305 and the state of this TCPv4 instance has
306 been changed to Tcp4StateSynSent.
307 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
308 configured.
309 @retval EFI_ACCESS_DENIED The instance is not configured as an active one
310 or it is not in Tcp4StateClosed state.
311 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
312 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to
313 initiate the active open.
314 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
315
316 **/
317 EFI_STATUS
318 EFIAPI
319 Tcp4Connect (
320 IN EFI_TCP4_PROTOCOL *This,
321 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
322 )
323 {
324 SOCKET *Sock;
325
326 if (NULL == This ||
327 NULL == ConnectionToken ||
328 NULL == ConnectionToken->CompletionToken.Event) {
329 return EFI_INVALID_PARAMETER;
330 }
331
332 Sock = SOCK_FROM_THIS (This);
333
334 return SockConnect (Sock, ConnectionToken);
335 }
336
337
338 /**
339 Listen on the passive instance to accept an incoming connection request.
340
341 The Accept() function initiates an asynchronous accept request to wait for an
342 incoming connection on the passive TCP instance. If a remote peer successfully
343 establishes a connection with this instance, a new TCP instance will be created
344 and its handle will be returned in ListenToken->NewChildHandle. The newly created
345 instance is configured by inheriting the passive instance's configuration and is
346 ready for use upon return. The instance is in the Tcp4StateEstablished state.
347 The ListenToken->CompletionToken.Event will be signaled when a new connection
348 is accepted, user aborts the listen or connection is reset. This function only
349 can be called when current TCP instance is in Tcp4StateListen state.
350
351 @param This Pointer to the EFI_TCP4_PROTOCOL instance
352 @param ListenToken Pointer to the listen token to return when
353 operation finishes.
354
355 @retval EFI_SUCCESS The listen token has been queued successfully.
356 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
357 configured.
358 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
359 in Tcp4StateListen state or a same listen token
360 has already existed in the listen token queue of
361 this TCP instance.
362 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
363 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
364 the operation.
365 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
366
367 **/
368 EFI_STATUS
369 EFIAPI
370 Tcp4Accept (
371 IN EFI_TCP4_PROTOCOL *This,
372 IN EFI_TCP4_LISTEN_TOKEN *ListenToken
373 )
374 {
375 SOCKET *Sock;
376
377 if (NULL == This ||
378 NULL == ListenToken ||
379 NULL == ListenToken->CompletionToken.Event) {
380 return EFI_INVALID_PARAMETER;
381 }
382
383 Sock = SOCK_FROM_THIS (This);
384
385 return SockAccept (Sock, ListenToken);
386 }
387
388
389 /**
390 Queues outgoing data into the transmit queue.
391
392 The Transmit() function queues a sending request to this TCPv4 instance along
393 with the user data. The status of the token is updated and the event in the token
394 will be signaled once the data is sent out or some error occurs.
395
396 @param This Pointer to the EFI_TCP4_PROTOCOL instance
397 @param Token Pointer to the completion token to queue to the
398 transmit queue
399
400 @retval EFI_SUCCESS The data has been queued for transmission.
401 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
402 configured.
403 @retval EFI_NO_MAPPING When using a default address, configuration
404 (DHCP, BOOTP, RARP, etc.) is not finished yet.
405 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
406 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
407 * A transmit completion token with the same
408 Token-> CompletionToken.Event was already in the
409 transmission queue.
410 * The current instance is in Tcp4StateClosed state
411 * The current instance is a passive one and
412 it is in Tcp4StateListen state.
413 * User has called Close() to disconnect this
414 connection.
415 @retval EFI_NOT_READY The completion token could not be queued because
416 the transmit queue is full.
417 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of
418 resource shortage.
419 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
420 address.
421
422 **/
423 EFI_STATUS
424 EFIAPI
425 Tcp4Transmit (
426 IN EFI_TCP4_PROTOCOL *This,
427 IN EFI_TCP4_IO_TOKEN *Token
428 )
429 {
430 SOCKET *Sock;
431 EFI_STATUS Status;
432
433 if (NULL == This ||
434 NULL == Token ||
435 NULL == Token->CompletionToken.Event ||
436 NULL == Token->Packet.TxData ||
437 0 == Token->Packet.TxData->FragmentCount ||
438 0 == Token->Packet.TxData->DataLength
439 ) {
440 return EFI_INVALID_PARAMETER;
441 }
442
443 Status = Tcp4ChkDataBuf (
444 (UINT32) Token->Packet.TxData->DataLength,
445 (UINT32) Token->Packet.TxData->FragmentCount,
446 Token->Packet.TxData->FragmentTable
447 );
448 if (EFI_ERROR (Status)) {
449 return Status;
450 }
451
452 Sock = SOCK_FROM_THIS (This);
453
454 return SockSend (Sock, Token);
455
456 }
457
458
459 /**
460 Place an asynchronous receive request into the receiving queue.
461
462 The Receive() function places a completion token into the receive packet queue.
463 This function is always asynchronous. The caller must allocate the
464 Token->CompletionToken.Event and the FragmentBuffer used to receive data. He also
465 must fill the DataLength which represents the whole length of all FragmentBuffer.
466 When the receive operation completes, the EFI TCPv4 Protocol driver updates the
467 Token->CompletionToken.Status and Token->Packet.RxData fields and the
468 Token->CompletionToken.Event is signaled. If got data the data and its length
469 will be copy into the FragmentTable, in the same time the full length of received
470 data will be recorded in the DataLength fields. Providing a proper notification
471 function and context for the event will enable the user to receive the notification
472 and receiving status. That notification function is guaranteed to not be re-entered.
473
474 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
475 @param Token Pointer to a token that is associated with the
476 receive data descriptor.
477
478 @retval EFI_SUCCESS The receive completion token was cached.
479 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
480 configured.
481 @retval EFI_NO_MAPPING When using a default address, configuration
482 (DHCP, BOOTP, RARP, etc.) is not finished yet.
483 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
484 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
485 due to a lack of system resources.
486 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
487 The EFI TCPv4 Protocol instance has been reset
488 to startup defaults.
489 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
490 * A receive completion token with the same
491 Token->CompletionToken.Event was already in
492 the receive queue.
493 * The current instance is in Tcp4StateClosed state.
494 * The current instance is a passive one and it
495 is in Tcp4StateListen state.
496 * User has called Close() to disconnect this
497 connection.
498 @retval EFI_CONNECTION_FIN The communication peer has closed the connection
499 and there is no any buffered data in the receive
500 buffer of this instance.
501 @retval EFI_NOT_READY The receive request could not be queued because
502 the receive queue is full.
503
504 **/
505 EFI_STATUS
506 EFIAPI
507 Tcp4Receive (
508 IN EFI_TCP4_PROTOCOL *This,
509 IN EFI_TCP4_IO_TOKEN *Token
510 )
511 {
512 SOCKET *Sock;
513 EFI_STATUS Status;
514
515 if (NULL == This ||
516 NULL == Token ||
517 NULL == Token->CompletionToken.Event ||
518 NULL == Token->Packet.RxData ||
519 0 == Token->Packet.RxData->FragmentCount ||
520 0 == Token->Packet.RxData->DataLength
521 ) {
522 return EFI_INVALID_PARAMETER;
523 }
524
525 Status = Tcp4ChkDataBuf (
526 (UINT32) Token->Packet.RxData->DataLength,
527 (UINT32) Token->Packet.RxData->FragmentCount,
528 Token->Packet.RxData->FragmentTable
529 );
530 if (EFI_ERROR (Status)) {
531 return Status;
532 }
533
534 Sock = SOCK_FROM_THIS (This);
535
536 return SockRcv (Sock, Token);
537
538 }
539
540
541 /**
542 Disconnecting a TCP connection gracefully or reset a TCP connection.
543
544 Initiate an asynchronous close token to TCP driver. After Close() is called,
545 any buffered transmission data will be sent by TCP driver and the current
546 instance will have a graceful close working flow described as RFC 793 if
547 AbortOnClose is set to FALSE, otherwise, a rest packet will be sent by TCP
548 driver to fast disconnect this connection. When the close operation completes
549 successfully the TCP instance is in Tcp4StateClosed state, all pending
550 asynchronous operation is signaled and any buffers used for TCP network traffic
551 is flushed.
552
553 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
554 @param CloseToken Pointer to the close token to return when
555 operation finishes.
556
557 @retval EFI_SUCCESS The operation completed successfully.
558 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
559 configured.
560 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
561 * Configure() has been called with TcpConfigData
562 set to NULL and this function has not returned.
563 * Previous Close() call on this instance has not
564 finished.
565 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
566 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the
567 operation.
568 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above
569 category error.
570
571 **/
572 EFI_STATUS
573 EFIAPI
574 Tcp4Close (
575 IN EFI_TCP4_PROTOCOL *This,
576 IN EFI_TCP4_CLOSE_TOKEN *CloseToken
577 )
578 {
579 SOCKET *Sock;
580
581 if (NULL == This ||
582 NULL == CloseToken ||
583 NULL == CloseToken->CompletionToken.Event) {
584 return EFI_INVALID_PARAMETER;
585 }
586
587 Sock = SOCK_FROM_THIS (This);
588
589 return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);
590 }
591
592
593 /**
594 Abort an asynchronous connection, listen, transmission or receive request.
595
596 The Cancel() function aborts a pending connection, listen, transmit or receive
597 request. If Token is not NULL and the token is in the connection, listen,
598 transmission or receive queue when it is being cancelled, its Token->Status
599 will be set to EFI_ABORTED and then Token->Event will be signaled. If the token
600 is not in one of the queues, which usually means that the asynchronous operation
601 has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token
602 issued by Connect(), Accept(), Transmit() and Receive()will be aborted.
603 NOTE: It has not been implemented currently.
604
605 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
606 @param Token Pointer to a token that has been issued by
607 Connect(), Accept(), Transmit() or Receive(). If
608 NULL, all pending tokens issued by above four
609 functions will be aborted.
610
611 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
612 is signaled.
613 @retval EFI_INVALID_PARAMETER This is NULL.
614 @retval EFI_NOT_STARTED This instance hasn's been configured.
615 @retval EFI_NO_MAPPING When using the default address, configuration
616 (DHCP, BOOTP,RARP, etc.) hasn's finished yet.
617 @retval EFI_NOT_FOUND The asynchronous I/O request isn's found in the
618 transmission or receive queue. It has either
619 completed or wasn's issued by Transmit() and Receive().
620 @retval EFI_UNSUPPORTED The operation is not supported in current
621 implementation.
622
623 **/
624 EFI_STATUS
625 EFIAPI
626 Tcp4Cancel (
627 IN EFI_TCP4_PROTOCOL *This,
628 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
629 )
630 {
631 return EFI_UNSUPPORTED;
632 }
633
634
635 /**
636 Poll to receive incoming data and transmit outgoing segments.
637
638 The Poll() function increases the rate that data is moved between the network
639 and application and can be called when the TCP instance is created successfully.
640 Its use is optional. In some implementations, the periodical timer in the MNP
641 driver may not poll the underlying communications device fast enough to avoid
642 drop packets. Drivers and applications that are experiencing packet loss should
643 try calling the Poll() function in a high frequency.
644
645 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
646
647 @retval EFI_SUCCESS Incoming or outgoing data was processed.
648 @retval EFI_INVALID_PARAMETER This is NULL.
649 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
650 @retval EFI_NOT_READY No incoming or outgoing data was processed.
651 @retval EFI_TIMEOUT Data was dropped out of the transmission or
652 receive queue. Consider increasing the polling
653 rate.
654
655 **/
656 EFI_STATUS
657 EFIAPI
658 Tcp4Poll (
659 IN EFI_TCP4_PROTOCOL *This
660 )
661 {
662 SOCKET *Sock;
663 EFI_STATUS Status;
664
665 if (NULL == This) {
666 return EFI_INVALID_PARAMETER;
667 }
668
669 Sock = SOCK_FROM_THIS (This);
670
671 Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);
672
673 return Status;
674 }