2 This library is used to share code between UEFI network stack modules.
3 It provides the helper routines to access TCP service.
5 Copyright (c) 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<BR>
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.
20 #include <Protocol/Tcp4.h>
21 #include <Protocol/Tcp6.h>
23 #include <Library/NetLib.h>
25 #define TCP_VERSION_4 IP_VERSION_4
26 #define TCP_VERSION_6 IP_VERSION_6
31 #define TCP_GET_MAPPING_TIMEOUT 100000000U
35 EFI_IPv4_ADDRESS LocalIp
;
36 EFI_IPv4_ADDRESS SubnetMask
;
37 EFI_IPv4_ADDRESS Gateway
;
40 EFI_IPv4_ADDRESS RemoteIp
;
43 } TCP4_IO_CONFIG_DATA
;
47 EFI_IPv6_ADDRESS RemoteIp
;
50 } TCP6_IO_CONFIG_DATA
;
53 TCP4_IO_CONFIG_DATA Tcp4IoConfigData
;
54 TCP6_IO_CONFIG_DATA Tcp6IoConfigData
;
58 EFI_TCP4_PROTOCOL
*Tcp4
;
59 EFI_TCP6_PROTOCOL
*Tcp6
;
63 EFI_TCP4_CONNECTION_TOKEN Tcp4Token
;
64 EFI_TCP6_CONNECTION_TOKEN Tcp6Token
;
65 } TCP_IO_CONNECTION_TOKEN
;
68 EFI_TCP4_IO_TOKEN Tcp4Token
;
69 EFI_TCP6_IO_TOKEN Tcp6Token
;
73 EFI_TCP4_CLOSE_TOKEN Tcp4Token
;
74 EFI_TCP6_CLOSE_TOKEN Tcp6Token
;
78 EFI_TCP4_LISTEN_TOKEN Tcp4Token
;
79 EFI_TCP6_LISTEN_TOKEN Tcp6Token
;
80 } TCP_IO_LISTEN_TOKEN
;
86 EFI_HANDLE Controller
;
90 TCP_IO_PROTOCOL NewTcp
;
91 TCP_IO_CONNECTION_TOKEN ConnToken
;
92 TCP_IO_IO_TOKEN TxToken
;
93 TCP_IO_IO_TOKEN RxToken
;
94 TCP_IO_CLOSE_TOKEN CloseToken
;
95 TCP_IO_LISTEN_TOKEN ListenToken
;
101 BOOLEAN IsListenDone
;
105 Create a TCP socket with the specified configuration data.
107 @param[in] Image The handle of the driver image.
108 @param[in] Controller The handle of the controller.
109 @param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.
110 @param[in] ConfigData The Tcp configuration data.
111 @param[out] TcpIo The TcpIo.
113 @retval EFI_SUCCESS The TCP socket is created and configured.
114 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
115 @retval EFI_UNSUPPORTED One or more of the control options are not
116 supported in the implementation.
117 @retval Others Failed to create the TCP socket or configure it.
124 IN EFI_HANDLE Controller
,
126 IN TCP_IO_CONFIG_DATA
*ConfigData
,
133 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
143 Connect to the other endpoint of the TCP socket.
145 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
146 @param[in] Timeout The time to wait for connection done.
148 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
150 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
151 TCP socket in the specified time period.
152 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
153 @retval EFI_UNSUPPORTED One or more of the control options are not
154 supported in the implementation.
155 @retval Others Other errors as indicated.
161 IN OUT TCP_IO
*TcpIo
,
166 Accept the incomding request from the other endpoint of the TCP socket.
168 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
169 @param[in] Timeout The time to wait for connection done.
172 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
174 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
175 @retval EFI_UNSUPPORTED One or more of the control options are not
176 supported in the implementation.
178 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
179 TCP socket in the specified time period.
180 @retval Others Other errors as indicated.
186 IN OUT TCP_IO
*TcpIo
,
193 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
203 Transmit the Packet to the other endpoint of the socket.
205 @param[in] TcpIo The TcpIo wrapping the TCP socket.
206 @param[in] Packet The packet to transmit.
208 @retval EFI_SUCCESS The packet is trasmitted.
209 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
210 @retval EFI_UNSUPPORTED One or more of the control options are not
211 supported in the implementation.
212 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
213 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
214 @retval Others Other errors as indicated.
225 Receive data from the socket.
227 @param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.
228 @param[in] Packet The buffer to hold the data copy from the socket rx buffer.
229 @param[in] AsyncMode Is this receive asyncronous or not.
230 @param[in] Timeout The time to wait for receiving the amount of data the Packet
233 @retval EFI_SUCCESS The required amount of data is received from the socket.
234 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
235 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
236 @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.
237 @retval EFI_TIMEOUT Failed to receive the required amount of data in the
238 specified time period.
239 @retval Others Other errors as indicated.
245 IN OUT TCP_IO
*TcpIo
,
247 IN BOOLEAN AsyncMode
,