]>
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 initial 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 (
288 // Functions in TcpOutput.c
292 Compute the sequence space left in the old receive window.
294 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
296 @return The sequence space left in the old receive window.
305 Compute the current receive window.
307 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
309 @return The size of the current receive window, in bytes.
318 Get the maximum SndNxt.
320 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
322 @return The sequence number of the maximum SndNxt.
331 Compute how much data to send.
333 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
334 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
335 and send out data by force.
337 @return The length of the data that can be sent. If 0, no data can be sent.
347 Retransmit the segment from sequence Seq.
349 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
350 @param[in] Seq The sequence number of the segment to be retransmitted.
352 @retval 0 The retransmission succeeded.
353 @retval -1 An error condition occurred.
363 Check whether to send data/SYN/FIN and piggyback an ACK.
365 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
366 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
367 and send out data by force.
369 @return The number of bytes sent.
379 Check whether to send an ACK or delayed ACK.
381 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
390 Send an ACK immediately.
392 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
401 Send a zero probe segment. It can be used by keepalive and zero window probe.
403 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
405 @retval 0 The zero probe segment was sent out successfully.
406 @retval other An error condition occurred.
415 Send a RESET segment in response to the segment received.
417 @param[in] Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
418 @param[in] Head TCP header of the segment that triggers the reset.
419 @param[in] Len Length of the segment that triggers the reset.
420 @param[in] Local Local IP address.
421 @param[in] Remote Remote peer's IP address.
422 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
423 IP_VERSION_6 indicates TCP is running on IP6 stack.
425 @retval 0 A reset is sent or no need to send it.
426 @retval -1 No reset is sent.
434 IN EFI_IP_ADDRESS
*Local
,
435 IN EFI_IP_ADDRESS
*Remote
,
440 Verify that the segment is in good shape.
442 @param[in] Nbuf Buffer that contains the segment to be checked.
444 @retval 0 The segment is broken.
445 @retval 1 The segment is in good shape.
454 // Functions from TcpInput.c
458 Process the received ICMP error messages for TCP.
460 @param[in] Nbuf Buffer that contains part of the TCP segment without IP header
461 truncated from the ICMP error packet.
462 @param[in] IcmpErr The ICMP error code interpreted from an ICMP error packet.
463 @param[in] Src Source address of the ICMP error message.
464 @param[in] Dst Destination address of the ICMP error message.
465 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
473 IN EFI_IP_ADDRESS
*Src
,
474 IN EFI_IP_ADDRESS
*Dst
,
479 Process the received TCP segments.
481 @param[in] Nbuf Buffer that contains received TCP segment without an IP header.
482 @param[in] Src Source address of the segment, or the peer's IP address.
483 @param[in] Dst Destination address of the segment, or the local end's IP
485 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
488 @retval 0 The segment processed successfully. It is either accepted or
489 discarded. But no connection is reset by the segment.
490 @retval -1 A connection is reset by the segment.
496 IN EFI_IP_ADDRESS
*Src
,
497 IN EFI_IP_ADDRESS
*Dst
,
502 // Functions in TcpTimer.c
506 Close the TCP connection.
508 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
517 Heart beat timer handler, queues the DPC at TPL_CALLBACK.
519 @param[in] Event Timer event signaled, ignored.
520 @param[in] Context Context of the timer event, ignored.
533 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
534 @param[in] Timer The index of the timer to be enabled.
535 @param[in] TimeOut The timeout value of this timer.
548 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
549 @param[in] Timer The index of the timer to be cleared.
559 Clear all TCP timers.
561 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
570 Enable the window prober timer and set the timeout value.
572 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
581 Enable the keepalive timer and set the timeout value.
583 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
587 TcpSetKeepaliveTimer (
592 // Functions in TcpIo.c
596 Packet receive callback function provided to IP_IO. Used to call
597 the proper function to handle the packet received by IP.
599 @param[in] Status Result of the receive request.
600 @param[in] IcmpErr Valid when Status is EFI_ICMP_ERROR.
601 @param[in] NetSession The IP session for the received packet.
602 @param[in] Pkt Packet received.
603 @param[in] Context The data provided by the user for the received packet when
604 the callback is registered in IP_IO_OPEN_DATA::RcvdContext.
605 This is an optional parameter that may be NULL.
611 IN EFI_STATUS Status
,
613 IN EFI_NET_SESSION_DATA
*NetSession
,
615 IN VOID
*Context OPTIONAL
619 Send the segment to IP via IpIo function.
621 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
622 @param[in] Nbuf Pointer to the TCP segment to be sent.
623 @param[in] Src Source address of the TCP segment.
624 @param[in] Dest Destination address of the TCP segment.
625 @param[in] Version IP_VERSION_4 or IP_VERSION_6
627 @retval 0 The segment was sent out successfully.
628 @retval -1 The segment failed to be sent.
635 IN EFI_IP_ADDRESS
*Src
,
636 IN EFI_IP_ADDRESS
*Dest
,
641 Refresh the remote peer's Neighbor Cache State if already exists.
643 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
644 @param[in] Neighbor Source address of the TCP segment.
645 @param[in] Timeout Time in 100-ns units that this entry will remain
646 in the neighbor cache. A value of zero means that
647 the entry is permanent. A value of non-zero means
648 that the entry is dynamic and will be deleted
651 @retval EFI_SUCCESS Successfully updated the neighbor relationship.
652 @retval EFI_NOT_STARTED The IpIo is not configured.
653 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
654 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
655 @retval EFI_NOT_FOUND This entry is not in the neighbor table.
659 Tcp6RefreshNeighbor (
661 IN EFI_IP_ADDRESS
*Neighbor
,
666 // Functions in TcpDispatcher.c
670 The protocol handler provided to the socket layer, used to
671 dispatch the socket level requests by calling the corresponding
674 @param[in] Sock Pointer to the socket of this TCP instance.
675 @param[in] Request The code of this operation request.
676 @param[in] Data Pointer to the operation specific data passed in
677 together with the operation request. This is an
678 optional parameter that may be NULL.
680 @retval EFI_SUCCESS The socket request completed successfully.
681 @retval other The error status returned by the corresponding TCP
689 IN VOID
*Data OPTIONAL