]>
git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/TcpDxe/TcpFunc.h
2 Declaration of external functions shared in TCP driver.
4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include "TcpOption.h"
15 #define TCP_COMP_VAL(Min, Max, Default, Val) \
16 ((((Val) <= (Max)) && ((Val) >= (Min))) ? (Val) : (Default))
19 Timeout handler prototype.
21 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
26 (*TCP_TIMER_HANDLER
) (
31 // Functions in TcpMisc.c
35 Initialize the Tcb locally related members.
37 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
46 Initialize the peer related members.
48 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
49 @param[in] Seg Pointer to the segment that contains the peer's intial information.
50 @param[in] Opt Pointer to the options announced by the peer.
61 Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.
63 @param[in] Addr Pointer to the IP address needs to match.
64 @param[in] Port The port number needs to match.
65 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack.
66 IP_VERSION_6 indicates TCP is running on IP6 stack.
69 @retval TRUE The Tcb which matches the <Addr Port> pairs exists.
70 @retval FALSE Otherwise
75 IN EFI_IP_ADDRESS
*Addr
,
81 Locate the TCP_CB related to the socket pair.
83 @param[in] LocalPort The local port number.
84 @param[in] LocalIp The local IP address.
85 @param[in] RemotePort The remote port number.
86 @param[in] RemoteIp The remote IP address.
87 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
88 IP_VERSION_6 indicates TCP is running on IP6 stack.
89 @param[in] Syn If TRUE, the listen sockets are searched.
91 @return Pointer to the related TCP_CB. If NULL, no match is found.
96 IN TCP_PORTNO LocalPort
,
97 IN EFI_IP_ADDRESS
*LocalIp
,
98 IN TCP_PORTNO RemotePort
,
99 IN EFI_IP_ADDRESS
*RemoteIp
,
105 Insert a Tcb into the proper queue.
107 @param[in] Tcb Pointer to the TCP_CB to be inserted.
109 @retval 0 The Tcb was inserted successfully.
110 @retval -1 An error condition occurred.
119 Clone a TCP_CB from Tcb.
121 @param[in] Tcb Pointer to the TCP_CB to be cloned.
123 @return Pointer to the new cloned TCP_CB. If NULL, an error condition occurred.
132 Compute an ISS to be used by a new connection.
134 @return The result ISS.
145 @param[in] Sock Pointer to the socket to get mss.
147 @return The mss size.
158 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
159 @param[in] State The state to be set.
169 Compute the TCP segment's checksum.
171 @param[in] Nbuf Pointer to the buffer that contains the TCP segment.
172 @param[in] HeadSum The checksum value of the fixed part of pseudo header.
174 @return The checksum value.
184 Translate the information from the head of the received TCP
185 segment Nbuf contains, and fill it into a TCP_SEG structure.
187 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
188 @param[in, out] Nbuf Pointer to the buffer contains the TCP segment.
190 @return Pointer to the TCP_SEG that contains the translated TCP head information.
200 Initialize an active connection,
202 @param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a
212 Application has consumed some data, check whether
213 to send a window update ack or a delayed ack.
215 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
224 Initiate the connection close procedure, called when
225 applications want to close the connection.
227 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
236 Check whether the application's newly delivered data can be sent out.
238 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
240 @retval 0 The data has been sent out successfully.
241 @retval -1 The Tcb is not in a state that data is permitted to
251 Abort the connection by sending a reset segment: called
252 when the application wants to abort the connection.
254 @param[in] Tcb Pointer to the TCP_CB of the TCP instance.
263 Reset the connection related with Tcb.
265 @param[in] Tcb Pointer to the TCP_CB of the connection to be reset.
274 Install the device path protocol on the TCP instance.
276 @param[in] Sock Pointer to the socket representing the TCP instance.
278 @retval EFI_SUCCESS The device path protocol installed.
279 @retval other Failed to install the device path protocol.
283 TcpInstallDevicePath (
289 // Functions in TcpOutput.c
293 Compute the sequence space left in the old receive window.
295 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
297 @return The sequence space left in the old receive window.
306 Compute the current receive window.
308 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
310 @return The size of the current receive window, in bytes.
319 Get the maximum SndNxt.
321 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
323 @return The sequence number of the maximum SndNxt.
332 Compute how much data to send.
334 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
335 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
336 and send out data by force.
338 @return The length of the data that can be sent. If 0, no data can be sent.
348 Retransmit the segment from sequence Seq.
350 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
351 @param[in] Seq The sequence number of the segment to be retransmitted.
353 @retval 0 The retransmission succeeded.
354 @retval -1 An error condition occurred.
364 Check whether to send data/SYN/FIN and piggyback an ACK.
366 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
367 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
368 and send out data by force.
370 @return The number of bytes sent.
380 Check whether to send an ACK or delayed ACK.
382 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
391 Send an ACK immediately.
393 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
402 Send a zero probe segment. It can be used by keepalive and zero window probe.
404 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
406 @retval 0 The zero probe segment was sent out successfully.
407 @retval other An error condition occurred.
416 Send a RESET segment in response to the segment received.
418 @param[in] Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
419 @param[in] Head TCP header of the segment that triggers the reset.
420 @param[in] Len Length of the segment that triggers the reset.
421 @param[in] Local Local IP address.
422 @param[in] Remote Remote peer's IP address.
423 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
424 IP_VERSION_6 indicates TCP is running on IP6 stack.
426 @retval 0 A reset is sent or no need to send it.
427 @retval -1 No reset is sent.
435 IN EFI_IP_ADDRESS
*Local
,
436 IN EFI_IP_ADDRESS
*Remote
,
441 Verify that the segment is in good shape.
443 @param[in] Nbuf Buffer that contains the segment to be checked.
445 @retval 0 The segment is broken.
446 @retval 1 The segment is in good shape.
455 // Functions from TcpInput.c
459 Process the received ICMP error messages for TCP.
461 @param[in] Nbuf Buffer that contains part of the TCP segment without IP header
462 truncated from the ICMP error packet.
463 @param[in] IcmpErr The ICMP error code interpreted from an ICMP error packet.
464 @param[in] Src Source address of the ICMP error message.
465 @param[in] Dst Destination address of the ICMP error message.
466 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
474 IN EFI_IP_ADDRESS
*Src
,
475 IN EFI_IP_ADDRESS
*Dst
,
480 Process the received TCP segments.
482 @param[in] Nbuf Buffer that contains received TCP segment without an IP header.
483 @param[in] Src Source address of the segment, or the peer's IP address.
484 @param[in] Dst Destination address of the segment, or the local end's IP
486 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
489 @retval 0 The segment processed successfully. It is either accepted or
490 discarded. But no connection is reset by the segment.
491 @retval -1 A connection is reset by the segment.
497 IN EFI_IP_ADDRESS
*Src
,
498 IN EFI_IP_ADDRESS
*Dst
,
503 // Functions in TcpTimer.c
507 Close the TCP connection.
509 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
518 Heart beat timer handler, queues the DPC at TPL_CALLBACK.
520 @param[in] Event Timer event signaled, ignored.
521 @param[in] Context Context of the timer event, ignored.
534 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
535 @param[in] Timer The index of the timer to be enabled.
536 @param[in] TimeOut The timeout value of this timer.
549 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
550 @param[in] Timer The index of the timer to be cleared.
560 Clear all TCP timers.
562 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
571 Enable the window prober timer and set the timeout value.
573 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
582 Enable the keepalive timer and set the timeout value.
584 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
588 TcpSetKeepaliveTimer (
593 // Functions in TcpIo.c
597 Packet receive callback function provided to IP_IO. Used to call
598 the proper function to handle the packet received by IP.
600 @param[in] Status Result of the receive request.
601 @param[in] IcmpErr Valid when Status is EFI_ICMP_ERROR.
602 @param[in] NetSession The IP session for the received packet.
603 @param[in] Pkt Packet received.
604 @param[in] Context The data provided by the user for the received packet when
605 the callback is registered in IP_IO_OPEN_DATA::RcvdContext.
606 This is an optional parameter that may be NULL.
612 IN EFI_STATUS Status
,
614 IN EFI_NET_SESSION_DATA
*NetSession
,
616 IN VOID
*Context OPTIONAL
620 Send the segment to IP via IpIo function.
622 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
623 @param[in] Nbuf Pointer to the TCP segment to be sent.
624 @param[in] Src Source address of the TCP segment.
625 @param[in] Dest Destination address of the TCP segment.
626 @param[in] Version IP_VERSION_4 or IP_VERSION_6
628 @retval 0 The segment was sent out successfully.
629 @retval -1 The segment failed to be sent.
636 IN EFI_IP_ADDRESS
*Src
,
637 IN EFI_IP_ADDRESS
*Dest
,
642 Refresh the remote peer's Neighbor Cache State if already exists.
644 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
645 @param[in] Neighbor Source address of the TCP segment.
646 @param[in] Timeout Time in 100-ns units that this entry will remain
647 in the neighbor cache. A value of zero means that
648 the entry is permanent. A value of non-zero means
649 that the entry is dynamic and will be deleted
652 @retval EFI_SUCCESS Successfully updated the neighbor relationship.
653 @retval EFI_NOT_STARTED The IpIo is not configured.
654 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
655 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
656 @retval EFI_NOT_FOUND This entry is not in the neighbor table.
660 Tcp6RefreshNeighbor (
662 IN EFI_IP_ADDRESS
*Neighbor
,
667 // Functions in TcpDispatcher.c
671 The procotol handler provided to the socket layer, used to
672 dispatch the socket level requests by calling the corresponding
675 @param[in] Sock Pointer to the socket of this TCP instance.
676 @param[in] Request The code of this operation request.
677 @param[in] Data Pointer to the operation specific data passed in
678 together with the operation request. This is an
679 optional parameter that may be NULL.
681 @retval EFI_SUCCESS The socket request completed successfully.
682 @retval other The error status returned by the corresponding TCP
690 IN VOID
*Data OPTIONAL