]>
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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include "TcpOption.h"
21 #define TCP_COMP_VAL(Min, Max, Default, Val) \
22 ((((Val) <= (Max)) && ((Val) >= (Min))) ? (Val) : (Default))
25 Timeout handler prototype.
27 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
32 (*TCP_TIMER_HANDLER
) (
37 // Functions in TcpMisc.c
41 Initialize the Tcb locally related members.
43 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
52 Initialize the peer related members.
54 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
55 @param[in] Seg Pointer to the segment that contains the peer's intial information.
56 @param[in] Opt Pointer to the options announced by the peer.
67 Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.
69 @param[in] Addr Pointer to the IP address needs to match.
70 @param[in] Port The port number needs to match.
71 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack.
72 IP_VERSION_6 indicates TCP is running on IP6 stack.
75 @retval TRUE The Tcb which matches the <Addr Port> pairs exists.
76 @retval FALSE Otherwise
81 IN EFI_IP_ADDRESS
*Addr
,
87 Locate the TCP_CB related to the socket pair.
89 @param[in] LocalPort The local port number.
90 @param[in] LocalIp The local IP address.
91 @param[in] RemotePort The remote port number.
92 @param[in] RemoteIp The remote IP address.
93 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
94 IP_VERSION_6 indicates TCP is running on IP6 stack.
95 @param[in] Syn If TRUE, the listen sockets are searched.
97 @return Pointer to the related TCP_CB. If NULL, no match is found.
102 IN TCP_PORTNO LocalPort
,
103 IN EFI_IP_ADDRESS
*LocalIp
,
104 IN TCP_PORTNO RemotePort
,
105 IN EFI_IP_ADDRESS
*RemoteIp
,
111 Insert a Tcb into the proper queue.
113 @param[in] Tcb Pointer to the TCP_CB to be inserted.
115 @retval 0 The Tcb was inserted successfully.
116 @retval -1 An error condition occurred.
125 Clone a TCP_CB from Tcb.
127 @param[in] Tcb Pointer to the TCP_CB to be cloned.
129 @return Pointer to the new cloned TCP_CB. If NULL, an error condition occurred.
138 Compute an ISS to be used by a new connection.
140 @return The result ISS.
151 @param[in] Sock Pointer to the socket to get mss.
153 @return The mss size.
164 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
165 @param[in] State The state to be set.
175 Compute the TCP segment's checksum.
177 @param[in] Nbuf Pointer to the buffer that contains the TCP segment.
178 @param[in] HeadSum The checksum value of the fixed part of pseudo header.
180 @return The checksum value.
190 Translate the information from the head of the received TCP
191 segment Nbuf contains, and fill it into a TCP_SEG structure.
193 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
194 @param[in, out] Nbuf Pointer to the buffer contains the TCP segment.
196 @return Pointer to the TCP_SEG that contains the translated TCP head information.
206 Initialize an active connection,
208 @param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a
218 Application has consumed some data, check whether
219 to send a window update ack or a delayed ack.
221 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
230 Initiate the connection close procedure, called when
231 applications want to close the connection.
233 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
242 Check whether the application's newly delivered data can be sent out.
244 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
246 @retval 0 The data has been sent out successfully.
247 @retval -1 The Tcb is not in a state that data is permitted to
257 Abort the connection by sending a reset segment: called
258 when the application wants to abort the connection.
260 @param[in] Tcb Pointer to the TCP_CB of the TCP instance.
269 Reset the connection related with Tcb.
271 @param[in] Tcb Pointer to the TCP_CB of the connection to be reset.
280 Install the device path protocol on the TCP instance.
282 @param[in] Sock Pointer to the socket representing the TCP instance.
284 @retval EFI_SUCCESS The device path protocol installed.
285 @retval other Failed to install the device path protocol.
289 TcpInstallDevicePath (
295 // Functions in TcpOutput.c
299 Compute the sequence space left in the old receive window.
301 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
303 @return The sequence space left in the old receive window.
312 Compute the current receive window.
314 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
316 @return The size of the current receive window, in bytes.
325 Get the maximum SndNxt.
327 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
329 @return The sequence number of the maximum SndNxt.
338 Compute how much data to send.
340 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
341 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
342 and send out data by force.
344 @return The length of the data that can be sent. If 0, no data can be sent.
354 Retransmit the segment from sequence Seq.
356 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
357 @param[in] Seq The sequence number of the segment to be retransmitted.
359 @retval 0 The retransmission succeeded.
360 @retval -1 An error condition occurred.
370 Check whether to send data/SYN/FIN and piggyback an ACK.
372 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
373 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
374 and send out data by force.
376 @return The number of bytes sent.
386 Check whether to send an ACK or delayed ACK.
388 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
397 Send an ACK immediately.
399 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
408 Send a zero probe segment. It can be used by keepalive and zero window probe.
410 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
412 @retval 0 The zero probe segment was sent out successfully.
413 @retval other An error condition occurred.
422 Send a RESET segment in response to the segment received.
424 @param[in] Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
425 @param[in] Head TCP header of the segment that triggers the reset.
426 @param[in] Len Length of the segment that triggers the reset.
427 @param[in] Local Local IP address.
428 @param[in] Remote Remote peer's IP address.
429 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
430 IP_VERSION_6 indicates TCP is running on IP6 stack.
432 @retval 0 A reset is sent or no need to send it.
433 @retval -1 No reset is sent.
441 IN EFI_IP_ADDRESS
*Local
,
442 IN EFI_IP_ADDRESS
*Remote
,
447 Verify that the segment is in good shape.
449 @param[in] Nbuf Buffer that contains the segment to be checked.
451 @retval 0 The segment is broken.
452 @retval 1 The segment is in good shape.
461 // Functions from TcpInput.c
465 Process the received ICMP error messages for TCP.
467 @param[in] Nbuf Buffer that contains part of the TCP segment without IP header
468 truncated from the ICMP error packet.
469 @param[in] IcmpErr The ICMP error code interpreted from an ICMP error packet.
470 @param[in] Src Source address of the ICMP error message.
471 @param[in] Dst Destination address of the ICMP error message.
472 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
480 IN EFI_IP_ADDRESS
*Src
,
481 IN EFI_IP_ADDRESS
*Dst
,
486 Process the received TCP segments.
488 @param[in] Nbuf Buffer that contains received TCP segment without an IP header.
489 @param[in] Src Source address of the segment, or the peer's IP address.
490 @param[in] Dst Destination address of the segment, or the local end's IP
492 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
495 @retval 0 The segment processed successfully. It is either accepted or
496 discarded. But no connection is reset by the segment.
497 @retval -1 A connection is reset by the segment.
503 IN EFI_IP_ADDRESS
*Src
,
504 IN EFI_IP_ADDRESS
*Dst
,
509 // Functions in TcpTimer.c
513 Close the TCP connection.
515 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
524 Heart beat timer handler, queues the DPC at TPL_CALLBACK.
526 @param[in] Event Timer event signaled, ignored.
527 @param[in] Context Context of the timer event, ignored.
540 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
541 @param[in] Timer The index of the timer to be enabled.
542 @param[in] TimeOut The timeout value of this timer.
555 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
556 @param[in] Timer The index of the timer to be cleared.
566 Clear all TCP timers.
568 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
577 Enable the window prober timer and set the timeout value.
579 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
588 Enable the keepalive timer and set the timeout value.
590 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
594 TcpSetKeepaliveTimer (
599 // Functions in TcpIo.c
603 Packet receive callback function provided to IP_IO. Used to call
604 the proper function to handle the packet received by IP.
606 @param[in] Status Result of the receive request.
607 @param[in] IcmpErr Valid when Status is EFI_ICMP_ERROR.
608 @param[in] NetSession The IP session for the received packet.
609 @param[in] Pkt Packet received.
610 @param[in] Context The data provided by the user for the received packet when
611 the callback is registered in IP_IO_OPEN_DATA::RcvdContext.
612 This is an optional parameter that may be NULL.
618 IN EFI_STATUS Status
,
620 IN EFI_NET_SESSION_DATA
*NetSession
,
622 IN VOID
*Context OPTIONAL
626 Send the segment to IP via IpIo function.
628 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
629 @param[in] Nbuf Pointer to the TCP segment to be sent.
630 @param[in] Src Source address of the TCP segment.
631 @param[in] Dest Destination address of the TCP segment.
632 @param[in] Version IP_VERSION_4 or IP_VERSION_6
634 @retval 0 The segment was sent out successfully.
635 @retval -1 The segment failed to be sent.
642 IN EFI_IP_ADDRESS
*Src
,
643 IN EFI_IP_ADDRESS
*Dest
,
648 Refresh the remote peer's Neighbor Cache State if already exists.
650 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
651 @param[in] Neighbor Source address of the TCP segment.
652 @param[in] Timeout Time in 100-ns units that this entry will remain
653 in the neighbor cache. A value of zero means that
654 the entry is permanent. A value of non-zero means
655 that the entry is dynamic and will be deleted
658 @retval EFI_SUCCESS Successfully updated the neighbor relationship.
659 @retval EFI_NOT_STARTED The IpIo is not configured.
660 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
661 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
662 @retval EFI_NOT_FOUND This entry is not in the neighbor table.
666 Tcp6RefreshNeighbor (
668 IN EFI_IP_ADDRESS
*Neighbor
,
673 // Functions in TcpDispatcher.c
677 The procotol handler provided to the socket layer, used to
678 dispatch the socket level requests by calling the corresponding
681 @param[in] Sock Pointer to the socket of this TCP instance.
682 @param[in] Request The code of this operation request.
683 @param[in] Data Pointer to the operation specific data passed in
684 together with the operation request. This is an
685 optional parameter that may be NULL.
687 @retval EFI_SUCCESS The socket request completed successfully.
688 @retval other The error status returned by the corresponding TCP
696 IN VOID
*Data OPTIONAL