]>
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 - 2010, 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 Set the Tcp variable data.
282 @param[in] TcpService Tcp service data.
284 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
285 @retval other Set variable failed.
290 IN TCP_SERVICE_DATA
*TcpService
294 Clear the variable and free the resource.
296 @param[in] TcpService Tcp service data.
300 TcpClearVariableData (
301 IN TCP_SERVICE_DATA
*TcpService
305 Install the device path protocol on the TCP instance.
307 @param[in] Sock Pointer to the socket representing the TCP instance.
309 @retval EFI_SUCCESS The device path protocol installed.
310 @retval other Failed to install the device path protocol.
314 TcpInstallDevicePath (
320 // Functions in TcpOutput.c
324 Compute the sequence space left in the old receive window.
326 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
328 @return The sequence space left in the old receive window.
337 Compute the current receive window.
339 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
341 @return The size of the current receive window, in bytes.
350 Get the maximum SndNxt.
352 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
354 @return The sequence number of the maximum SndNxt.
363 Compute how much data to send.
365 @param[in] 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 length of the data that can be sent. If 0, no data can be sent.
379 Retransmit the segment from sequence Seq.
381 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
382 @param[in] Seq The sequence number of the segment to be retransmitted.
384 @retval 0 The retransmission succeeded.
385 @retval -1 An error condition occurred.
395 Check whether to send data/SYN/FIN and piggyback an ACK.
397 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
398 @param[in] Force If TRUE, ignore the sender's SWS avoidance algorithm
399 and send out data by force.
401 @return The number of bytes sent.
411 Check whether to send an ACK or delayed ACK.
413 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
422 Send an ACK immediately.
424 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
433 Send a zero probe segment. It can be used by keepalive and zero window probe.
435 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
437 @retval 0 The zero probe segment was sent out successfully.
438 @retval other An error condition occurred.
447 Send a RESET segment in response to the segment received.
449 @param[in] Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
450 @param[in] Head TCP header of the segment that triggers the reset.
451 @param[in] Len Length of the segment that triggers the reset.
452 @param[in] Local Local IP address.
453 @param[in] Remote Remote peer's IP address.
454 @param[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack,
455 IP_VERSION_6 indicates TCP is running on IP6 stack.
457 @retval 0 A reset is sent or no need to send it.
458 @retval -1 No reset is sent.
466 IN EFI_IP_ADDRESS
*Local
,
467 IN EFI_IP_ADDRESS
*Remote
,
472 Verify that the segment is in good shape.
474 @param[in] Nbuf Buffer that contains the segment to be checked.
476 @retval 0 The segment is broken.
477 @retval 1 The segment is in good shape.
486 // Functions from TcpInput.c
490 Process the received ICMP error messages for TCP.
492 @param[in] Nbuf Buffer that contains part of the TCP segment without IP header
493 truncated from the ICMP error packet.
494 @param[in] IcmpErr The ICMP error code interpreted from an ICMP error packet.
495 @param[in] Src Source address of the ICMP error message.
496 @param[in] Dst Destination address of the ICMP error message.
497 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
505 IN EFI_IP_ADDRESS
*Src
,
506 IN EFI_IP_ADDRESS
*Dst
,
511 Process the received TCP segments.
513 @param[in] Nbuf Buffer that contains received TCP segment without an IP header.
514 @param[in] Src Source address of the segment, or the peer's IP address.
515 @param[in] Dst Destination address of the segment, or the local end's IP
517 @param[in] Version IP_VERSION_4 indicates IP4 stack, IP_VERSION_6 indicates
520 @retval 0 The segment processed successfully. It is either accepted or
521 discarded. But no connection is reset by the segment.
522 @retval -1 A connection is reset by the segment.
528 IN EFI_IP_ADDRESS
*Src
,
529 IN EFI_IP_ADDRESS
*Dst
,
534 // Functions in TcpTimer.c
538 Close the TCP connection.
540 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
549 Heart beat timer handler, queues the DPC at TPL_CALLBACK.
551 @param[in] Event Timer event signaled, ignored.
552 @param[in] Context Context of the timer event, ignored.
565 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
566 @param[in] Timer The index of the timer to be enabled.
567 @param[in] TimeOut The timeout value of this timer.
580 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
581 @param[in] Timer The index of the timer to be cleared.
591 Clear all TCP timers.
593 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
602 Enable the window prober timer and set the timeout value.
604 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
613 Enable the keepalive timer and set the timeout value.
615 @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance.
619 TcpSetKeepaliveTimer (
624 // Functions in TcpIo.c
628 Packet receive callback function provided to IP_IO. Used to call
629 the proper function to handle the packet received by IP.
631 @param[in] Status Result of the receive request.
632 @param[in] IcmpErr Valid when Status is EFI_ICMP_ERROR.
633 @param[in] NetSession The IP session for the received packet.
634 @param[in] Pkt Packet received.
635 @param[in] Context The data provided by the user for the received packet when
636 the callback is registered in IP_IO_OPEN_DATA::RcvdContext.
637 This is an optional parameter that may be NULL.
643 IN EFI_STATUS Status
,
645 IN EFI_NET_SESSION_DATA
*NetSession
,
647 IN VOID
*Context OPTIONAL
651 Send the segment to IP via IpIo function.
653 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
654 @param[in] Nbuf Pointer to the TCP segment to be sent.
655 @param[in] Src Source address of the TCP segment.
656 @param[in] Dest Destination address of the TCP segment.
657 @param[in] Version IP_VERSION_4 or IP_VERSION_6
659 @retval 0 The segment was sent out successfully.
660 @retval -1 The segment failed to be sent.
667 IN EFI_IP_ADDRESS
*Src
,
668 IN EFI_IP_ADDRESS
*Dest
,
673 Refresh the remote peer's Neighbor Cache State if already exists.
675 @param[in] Tcb Pointer to the TCP_CB of this TCP instance.
676 @param[in] Neighbor Source address of the TCP segment.
677 @param[in] Timeout Time in 100-ns units that this entry will remain
678 in the neighbor cache. A value of zero means that
679 the entry is permanent. A value of non-zero means
680 that the entry is dynamic and will be deleted
683 @retval EFI_SUCCESS Successfully updated the neighbor relationship.
684 @retval EFI_NOT_STARTED The IpIo is not configured.
685 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
686 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
687 @retval EFI_NOT_FOUND This entry is not in the neighbor table.
691 Tcp6RefreshNeighbor (
693 IN EFI_IP_ADDRESS
*Neighbor
,
698 // Functions in TcpDispatcher.c
702 The procotol handler provided to the socket layer, used to
703 dispatch the socket level requests by calling the corresponding
706 @param[in] Sock Pointer to the socket of this TCP instance.
707 @param[in] Request The code of this operation request.
708 @param[in] Data Pointer to the operation specific data passed in
709 together with the operation request. This is an
710 optional parameter that may be NULL.
712 @retval EFI_SUCCESS The socket request completed successfully.
713 @retval other The error status returned by the corresponding TCP
721 IN VOID
*Data OPTIONAL