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 - 2011, 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 EFI_OUT_OF_RESOURCES Failed to allocate memory.
118 @retval Others Failed to create the TCP socket or configure it.
125 IN EFI_HANDLE Controller
,
127 IN TCP_IO_CONFIG_DATA
*ConfigData
,
134 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
144 Connect to the other endpoint of the TCP socket.
146 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
147 @param[in] Timeout The time to wait for connection done.
149 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
151 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
152 TCP socket in the specified time period.
153 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
154 @retval EFI_UNSUPPORTED One or more of the control options are not
155 supported in the implementation.
156 @retval Others Other errors as indicated.
162 IN OUT TCP_IO
*TcpIo
,
167 Accept the incomding request from the other endpoint of the TCP socket.
169 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
170 @param[in] Timeout The time to wait for connection done.
173 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
175 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
176 @retval EFI_UNSUPPORTED One or more of the control options are not
177 supported in the implementation.
179 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
180 TCP socket in the specified time period.
181 @retval Others Other errors as indicated.
187 IN OUT TCP_IO
*TcpIo
,
194 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
204 Transmit the Packet to the other endpoint of the socket.
206 @param[in] TcpIo The TcpIo wrapping the TCP socket.
207 @param[in] Packet The packet to transmit.
209 @retval EFI_SUCCESS The packet is trasmitted.
210 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
211 @retval EFI_UNSUPPORTED One or more of the control options are not
212 supported in the implementation.
213 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
214 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
215 @retval Others Other errors as indicated.
226 Receive data from the socket.
228 @param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.
229 @param[in] Packet The buffer to hold the data copy from the socket rx buffer.
230 @param[in] AsyncMode Is this receive asyncronous or not.
231 @param[in] Timeout The time to wait for receiving the amount of data the Packet
234 @retval EFI_SUCCESS The required amount of data is received from the socket.
235 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
236 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
237 @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.
238 @retval EFI_TIMEOUT Failed to receive the required amount of data in the
239 specified time period.
240 @retval Others Other errors as indicated.
246 IN OUT TCP_IO
*TcpIo
,
248 IN BOOLEAN AsyncMode
,