NetworkPkg/TcpDxe/TcpMisc.c File Reference


Functions

VOID TcpInitTcbLocal (IN OUT TCP_CB *Tcb)
VOID TcpInitTcbPeer (IN OUT TCP_CB *Tcb, IN TCP_SEG *Seg, IN TCP_OPTION *Opt)
BOOLEAN TcpIsIpEqual (IN EFI_IP_ADDRESS *Ip1, IN EFI_IP_ADDRESS *Ip2, IN UINT8 Version)
BOOLEAN TcpIsIpZero (IN EFI_IP_ADDRESS *Ip, IN UINT8 Version)
TCP_CBTcpLocateListenTcb (IN TCP_PEER *Local, IN TCP_PEER *Remote, IN UINT8 Version)
BOOLEAN TcpFindTcbByPeer (IN EFI_IP_ADDRESS *Addr, IN TCP_PORTNO Port, IN UINT8 Version)
TCP_CBTcpLocateTcb (IN TCP_PORTNO LocalPort, IN EFI_IP_ADDRESS *LocalIp, IN TCP_PORTNO RemotePort, IN EFI_IP_ADDRESS *RemoteIp, IN UINT8 Version, IN BOOLEAN Syn)
INTN TcpInsertTcb (IN TCP_CB *Tcb)
TCP_CBTcpCloneTcb (IN TCP_CB *Tcb)
TCP_SEQNO TcpGetIss (VOID)
UINT16 TcpGetRcvMss (IN SOCKET *Sock)
VOID TcpSetState (IN TCP_CB *Tcb, IN UINT8 State)
UINT16 TcpChecksum (IN NET_BUF *Nbuf, IN UINT16 HeadSum)
TCP_SEGTcpFormatNetbuf (IN TCP_CB *Tcb, IN OUT NET_BUF *Nbuf)
VOID TcpOnAppConnect (IN OUT TCP_CB *Tcb)
VOID TcpOnAppClose (IN OUT TCP_CB *Tcb)
INTN TcpOnAppSend (IN OUT TCP_CB *Tcb)
VOID TcpOnAppConsume (IN TCP_CB *Tcb)
VOID TcpOnAppAbort (IN TCP_CB *Tcb)
VOID TcpResetConnection (IN TCP_CB *Tcb)
EFI_STATUS TcpInstallDevicePath (IN SOCKET *Sock)

Variables

LIST_ENTRY mTcpRunQue
LIST_ENTRY mTcpListenQue
TCP_SEQNO mTcpGlobalIss = TCP_BASE_ISS
CHAR16 * mTcpStateName []

Detailed Description

Misc support routines for TCP driver.

(C) Copyright 2014 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.


Function Documentation

UINT16 TcpChecksum ( IN NET_BUF *  Nbuf,
IN UINT16  HeadSum 
)

Compute the TCP segment's checksum.

Parameters:
[in] Nbuf Pointer to the buffer that contains the TCP segment.
[in] HeadSum The checksum value of the fixed part of pseudo header.
Returns:
The checksum value.

Referenced by TcpInput(), TcpResetConnection(), TcpSendReset(), and TcpTransmitSegment().

TCP_CB* TcpCloneTcb ( IN TCP_CB Tcb  ) 

Clone a TCP_CB from Tcb.

Parameters:
[in] Tcb Pointer to the TCP_CB to be cloned.
Returns:
Pointer to the new cloned TCP_CB; if NULL, error condition occurred.

References _TCP_CONTROL_BLOCK::List, _TCP_SOCKET::ProtoReserved, _TCP_CONTROL_BLOCK::RcvQue, _TCP_CONTROL_BLOCK::Sk, _TCP_CONTROL_BLOCK::SndQue, and SockClone().

Referenced by TcpInput().

BOOLEAN TcpFindTcbByPeer ( IN EFI_IP_ADDRESS *  Addr,
IN TCP_PORTNO  Port,
IN UINT8  Version 
)

Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.

Parameters:
[in] Addr Pointer to the IP address needs to match.
[in] Port The port number needs to match.
[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack, IP_VERSION_6 indicates TCP is running on IP6 stack.
Return values:
TRUE The Tcb which matches the <Addr port>=""> pair exists.
FALSE Otherwise

References _TCP_PEER::Ip, _TCP_SOCKET::IpVersion, _TCP_CONTROL_BLOCK::LocalEnd, mTcpListenQue, mTcpRunQue, _TCP_PEER::Port, _TCP_CONTROL_BLOCK::Sk, and TcpIsIpEqual().

Referenced by TcpBind().

TCP_SEG* TcpFormatNetbuf ( IN TCP_CB Tcb,
IN OUT NET_BUF *  Nbuf 
)

Translate the information from the head of the received TCP segment Nbuf contents and fill it into a TCP_SEG structure.

Parameters:
[in] Tcb Pointer to the TCP_CB of this TCP instance.
[in,out] Nbuf Pointer to the buffer contains the TCP segment.
Returns:
Pointer to the TCP_SEG that contains the translated TCP head information.

References _TCP_SEG::Ack, _TCP_SEG::End, _TCP_SEG::Flag, _TCP_SEG::Seq, TCP_FLG_FIN, TCP_FLG_ON, TCP_FLG_SYN, TCPSEG_NETBUF, _TCP_SEG::Urg, and _TCP_SEG::Wnd.

Referenced by TcpInput().

TCP_SEQNO TcpGetIss ( VOID   ) 

Compute an ISS to be used by a new connection.

Returns:
The resulting ISS.

References mTcpGlobalIss, and TCP_ISS_INCREMENT_1.

Referenced by TcpInitTcbLocal().

UINT16 TcpGetRcvMss ( IN SOCKET Sock  ) 

Get the local mss.

Parameters:
[in] Sock Pointer to the socket to get mss.
Returns:
The mss size.

References _TCP_SERVICE_DATA::IpIo, and _TCP_PROTO_DATA::TcpService.

Referenced by TcpConfigurePcb(), and TcpInitTcbPeer().

VOID TcpInitTcbLocal ( IN OUT TCP_CB Tcb  ) 

Initialize the Tcb local related members.

Parameters:
[in,out] Tcb Pointer to the TCP_CB of this TCP instance.

References GET_RCV_BUFFSIZE, and TcpGetIss().

Referenced by TcpInput(), and TcpOnAppConnect().

VOID TcpInitTcbPeer ( IN OUT TCP_CB Tcb,
IN TCP_SEG Seg,
IN TCP_OPTION Opt 
)

Initialize the peer related members.

Parameters:
[in,out] Tcb Pointer to the TCP_CB of this TCP instance.
[in] Seg Pointer to the segment that contains the peer's intial info.
[in] Opt Pointer to the options announced by the peer.

References TCP_CTRL_NO_TS, TCP_CTRL_NO_WS, TCP_CTRL_RCVD_TS, TCP_CTRL_RCVD_WS, TCP_CTRL_SND_TS, TCP_FLG_ACK, TCP_FLG_ON, TCP_FLG_SYN, TCP_OPTION_RCVD_MSS, TCP_OPTION_RCVD_TS, TCP_OPTION_RCVD_WS, TCP_OPTION_TS_ALIGNED_LEN, TCP_SET_FLG, TcpComputeScale(), and TcpGetRcvMss().

Referenced by TcpInput().

INTN TcpInsertTcb ( IN TCP_CB Tcb  ) 

Insert a Tcb into the proper queue.

Parameters:
[in] Tcb Pointer to the TCP_CB to be inserted.
Return values:
0 The Tcb was inserted successfully.
-1 Error condition occurred.

References _TCP_CONTROL_BLOCK::LocalEnd, mTcpListenQue, mTcpRunQue, _TCP_CONTROL_BLOCK::RemoteEnd, TCP_CLOSED, TCP_LISTEN, TCP_PEER_EQUAL, TCP_SYN_RCVD, and TCP_SYN_SENT.

Referenced by TcpConfigurePcb(), and TcpInput().

EFI_STATUS TcpInstallDevicePath ( IN SOCKET Sock  ) 

Install the device path protocol on the TCP instance.

Parameters:
[in] Sock Pointer to the socket representing the TCP instance.
Return values:
EFI_SUCCESS The device path protocol was installed.
other Failed to install the device path protocol.

References _TCP_SERVICE_DATA::ControllerHandle, _TCP_PEER::Ip, _TCP_CONTROL_BLOCK::LocalEnd, _TCP_PEER::Port, _TCP_CONTROL_BLOCK::RemoteEnd, _TCP_CONTROL_BLOCK::SubnetMask, _TCP_PROTO_DATA::TcpPcb, _TCP_PROTO_DATA::TcpService, and _TCP_CONTROL_BLOCK::UseDefaultAddr.

Referenced by TcpConfigurePcb(), and TcpSetState().

BOOLEAN TcpIsIpEqual ( IN EFI_IP_ADDRESS *  Ip1,
IN EFI_IP_ADDRESS *  Ip2,
IN UINT8  Version 
)

Check whether one IP address equals the other.

Parameters:
[in] Ip1 Pointer to IP address to be checked.
[in] Ip2 Pointer to IP address to be checked.
[in] Version IP_VERSION_4 indicates the IP address is an IPv4 address, IP_VERSION_6 indicates the IP address is an IPv6 address.
Return values:
TRUE Ip1 equals Ip2.
FALSE Ip1 does not equal Ip2.

Referenced by TcpFindTcbByPeer().

BOOLEAN TcpIsIpZero ( IN EFI_IP_ADDRESS *  Ip,
IN UINT8  Version 
)

Check whether one IP address is filled with ZERO.

Parameters:
[in] Ip Pointer to the IP address to be checked.
[in] Version IP_VERSION_4 indicates the IP address is an IPv4 address, IP_VERSION_6 indicates the IP address is an IPv6 address.
Return values:
TRUE Ip is all zero address.
FALSE Ip is not all zero address.

Referenced by TcpLocateListenTcb().

TCP_CB* TcpLocateListenTcb ( IN TCP_PEER Local,
IN TCP_PEER Remote,
IN UINT8  Version 
)

Locate a listen TCB that matchs the Local and Remote.

Parameters:
[in] Local Pointer to the local (IP, Port).
[in] Remote Pointer to the remote (IP, Port).
[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack, IP_VERSION_6 indicates TCP is running on IP6 stack.
Returns:
Pointer to the TCP_CB with the least number of wildcards, if NULL no match is found.

References _TCP_PEER::Ip, _TCP_SOCKET::IpVersion, _TCP_CONTROL_BLOCK::LocalEnd, mTcpListenQue, _TCP_PEER::Port, _TCP_CONTROL_BLOCK::RemoteEnd, _TCP_CONTROL_BLOCK::Sk, TCP_PEER_MATCH, and TcpIsIpZero().

Referenced by TcpLocateTcb().

TCP_CB* TcpLocateTcb ( IN TCP_PORTNO  LocalPort,
IN EFI_IP_ADDRESS *  LocalIp,
IN TCP_PORTNO  RemotePort,
IN EFI_IP_ADDRESS *  RemoteIp,
IN UINT8  Version,
IN BOOLEAN  Syn 
)

Locate the TCP_CB related to the socket pair.

Parameters:
[in] LocalPort The local port number.
[in] LocalIp The local IP address.
[in] RemotePort The remote port number.
[in] RemoteIp The remote IP address.
[in] Version IP_VERSION_4 indicates TCP is running on IP4 stack, IP_VERSION_6 indicates TCP is running on IP6 stack.
[in] Syn If TRUE, the listen sockets are searched.
Returns:
Pointer to the related TCP_CB. If NULL, no match is found.

References _TCP_PEER::Ip, _TCP_SOCKET::IpVersion, _TCP_CONTROL_BLOCK::List, _TCP_CONTROL_BLOCK::LocalEnd, mTcpRunQue, _TCP_PEER::Port, _TCP_CONTROL_BLOCK::RemoteEnd, _TCP_CONTROL_BLOCK::Sk, TCP_PEER_EQUAL, and TcpLocateListenTcb().

Referenced by TcpIcmpInput(), and TcpInput().

VOID TcpOnAppAbort ( IN TCP_CB Tcb  ) 

Abort the connection by sending a reset segment. Called when the application wants to abort the connection.

Parameters:
[in] Tcb Pointer to the TCP_CB of the TCP instance.

References TCP_CLOSE_WAIT, TCP_CLOSED, TCP_ESTABLISHED, TCP_FIN_WAIT_1, TCP_FIN_WAIT_2, TCP_SYN_RCVD, TcpResetConnection(), and TcpSetState().

Referenced by TcpDispatcher().

VOID TcpOnAppClose ( IN OUT TCP_CB Tcb  ) 

Initiate the connection close procedure, called when applications want to close the connection.

Parameters:
[in,out] Tcb Pointer to the TCP_CB of this TCP instance.

References GET_RCV_DATASIZE, TCP_CLOSE_WAIT, TCP_CLOSED, TCP_ESTABLISHED, TCP_FIN_WAIT_1, TCP_LAST_ACK, TCP_LISTEN, TCP_SYN_RCVD, TCP_SYN_SENT, TcpClose(), TcpResetConnection(), TcpSetState(), and TcpToSendData().

Referenced by TcpDispatcher().

VOID TcpOnAppConnect ( IN OUT TCP_CB Tcb  ) 

Initialize an active connection.

Parameters:
[in,out] Tcb Pointer to the TCP_CB that wants to initiate a connection.

References TCP_SYN_SENT, TCP_TIMER_CONNECT, TcpInitTcbLocal(), TcpSetState(), TcpSetTimer(), and TcpToSendData().

Referenced by TcpDispatcher().

VOID TcpOnAppConsume ( IN TCP_CB Tcb  ) 

Application has consumed some data. Check whether to send a window update ack or a delayed ack.

Parameters:
[in] Tcb Pointer to the TCP_CB of this TCP instance.

References TCP_ESTABLISHED, TcpRcvWinNow(), TcpRcvWinOld(), and TcpSendAck().

Referenced by TcpDispatcher().

INTN TcpOnAppSend ( IN OUT TCP_CB Tcb  ) 

Check whether the application's newly delivered data can be sent out.

Parameters:
[in,out] Tcb Pointer to the TCP_CB of this TCP instance.
Return values:
0 The data has been sent out successfully.
-1 The Tcb is not in a state that data is permitted to be sent out.

References TCP_CLOSE_WAIT, TCP_CLOSED, TCP_CLOSING, TCP_ESTABLISHED, TCP_FIN_WAIT_1, TCP_FIN_WAIT_2, TCP_LAST_ACK, TCP_LISTEN, TCP_SYN_RCVD, TCP_SYN_SENT, TCP_TIME_WAIT, and TcpToSendData().

Referenced by TcpDispatcher().

VOID TcpResetConnection ( IN TCP_CB Tcb  ) 

Reset the connection related with Tcb.

Parameters:
[in] Tcb Pointer to the TCP_CB of the connection to be reset.

References TCP_FLG_RST, TCP_MAX_HEAD, TcpChecksum(), and TcpSendIpPacket().

Referenced by TcpConnectTimeout(), TcpOnAppAbort(), and TcpOnAppClose().

VOID TcpSetState ( IN TCP_CB Tcb,
IN UINT8  State 
)

Set the Tcb's state.

Parameters:
[in] Tcb Pointer to the TCP_CB of this TCP instance.
[in] State The state to be set.

References mTcpStateName, SockConnClosed(), SockConnEstablished(), TCP_CLOSED, TCP_ESTABLISHED, and TcpInstallDevicePath().

Referenced by TcpClose(), TcpConfigurePcb(), TcpDeliverData(), TcpInput(), TcpOnAppAbort(), TcpOnAppClose(), and TcpOnAppConnect().


Variable Documentation

TCP_SEQNO mTcpGlobalIss = TCP_BASE_ISS

LIST_ENTRY mTcpListenQue

LIST_ENTRY mTcpRunQue

CHAR16* mTcpStateName[]

Initial value:

 {
  L"TCP_CLOSED",
  L"TCP_LISTEN",
  L"TCP_SYN_SENT",
  L"TCP_SYN_RCVD",
  L"TCP_ESTABLISHED",
  L"TCP_FIN_WAIT_1",
  L"TCP_FIN_WAIT_2",
  L"TCP_CLOSING",
  L"TCP_TIME_WAIT",
  L"TCP_CLOSE_WAIT",
  L"TCP_LAST_ACK"
}

Referenced by TcpSetState(), and TcpToSendData().


Generated on Mon Sep 28 08:49:06 2015 for NetworkPkg[ALL] by  doxygen 1.5.7.1