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