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 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Protocol/Tcp4.h>
15 #include <Protocol/Tcp6.h>
17 #include <Library/NetLib.h>
19 #define TCP_VERSION_4 IP_VERSION_4
20 #define TCP_VERSION_6 IP_VERSION_6
25 #define TCP_GET_MAPPING_TIMEOUT 100000000U
29 EFI_IPv4_ADDRESS LocalIp
;
30 EFI_IPv4_ADDRESS SubnetMask
;
31 EFI_IPv4_ADDRESS Gateway
;
34 EFI_IPv4_ADDRESS RemoteIp
;
37 } TCP4_IO_CONFIG_DATA
;
41 EFI_IPv6_ADDRESS RemoteIp
;
44 } TCP6_IO_CONFIG_DATA
;
47 TCP4_IO_CONFIG_DATA Tcp4IoConfigData
;
48 TCP6_IO_CONFIG_DATA Tcp6IoConfigData
;
52 EFI_TCP4_PROTOCOL
*Tcp4
;
53 EFI_TCP6_PROTOCOL
*Tcp6
;
57 EFI_TCP4_CONNECTION_TOKEN Tcp4Token
;
58 EFI_TCP6_CONNECTION_TOKEN Tcp6Token
;
59 } TCP_IO_CONNECTION_TOKEN
;
62 EFI_TCP4_IO_TOKEN Tcp4Token
;
63 EFI_TCP6_IO_TOKEN Tcp6Token
;
67 EFI_TCP4_CLOSE_TOKEN Tcp4Token
;
68 EFI_TCP6_CLOSE_TOKEN Tcp6Token
;
72 EFI_TCP4_LISTEN_TOKEN Tcp4Token
;
73 EFI_TCP6_LISTEN_TOKEN Tcp6Token
;
74 } TCP_IO_LISTEN_TOKEN
;
80 EFI_HANDLE Controller
;
84 TCP_IO_PROTOCOL NewTcp
;
85 TCP_IO_CONNECTION_TOKEN ConnToken
;
86 TCP_IO_IO_TOKEN TxToken
;
87 TCP_IO_IO_TOKEN RxToken
;
88 TCP_IO_CLOSE_TOKEN CloseToken
;
89 TCP_IO_LISTEN_TOKEN ListenToken
;
99 Create a TCP socket with the specified configuration data.
101 @param[in] Image The handle of the driver image.
102 @param[in] Controller The handle of the controller.
103 @param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.
104 @param[in] ConfigData The Tcp configuration data.
105 @param[out] TcpIo The TcpIo.
107 @retval EFI_SUCCESS The TCP socket is created and configured.
108 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
109 @retval EFI_UNSUPPORTED One or more of the control options are not
110 supported in the implementation.
111 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
112 @retval Others Failed to create the TCP socket or configure it.
119 IN EFI_HANDLE Controller
,
121 IN TCP_IO_CONFIG_DATA
*ConfigData
,
128 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
138 Connect to the other endpoint of the TCP socket.
140 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
141 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.
143 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
145 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
146 TCP socket in the specified time period.
147 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
148 @retval EFI_UNSUPPORTED One or more of the control options are not
149 supported in the implementation.
150 @retval Others Other errors as indicated.
156 IN OUT TCP_IO
*TcpIo
,
157 IN EFI_EVENT Timeout OPTIONAL
161 Accept the incomding request from the other endpoint of the TCP socket.
163 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
164 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.
167 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
169 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
170 @retval EFI_UNSUPPORTED One or more of the control options are not
171 supported in the implementation.
173 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
174 TCP socket in the specified time period.
175 @retval Others Other errors as indicated.
181 IN OUT TCP_IO
*TcpIo
,
182 IN EFI_EVENT Timeout OPTIONAL
188 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
198 Transmit the Packet to the other endpoint of the socket.
200 @param[in] TcpIo The TcpIo wrapping the TCP socket.
201 @param[in] Packet The packet to transmit.
203 @retval EFI_SUCCESS The packet is trasmitted.
204 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
205 @retval EFI_UNSUPPORTED One or more of the control options are not
206 supported in the implementation.
207 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
208 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
209 @retval Others Other errors as indicated.
220 Receive data from the socket.
222 @param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.
223 @param[in] Packet The buffer to hold the data copy from the socket rx buffer.
224 @param[in] AsyncMode Is this receive asyncronous or not.
225 @param[in] Timeout The time to wait for receiving the amount of data the Packet
226 can hold. Set to NULL for infinite wait.
228 @retval EFI_SUCCESS The required amount of data is received from the socket.
229 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
230 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
231 @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.
232 @retval EFI_TIMEOUT Failed to receive the required amount of data in the
233 specified time period.
234 @retval Others Other errors as indicated.
240 IN OUT TCP_IO
*TcpIo
,
242 IN BOOLEAN AsyncMode
,
243 IN EFI_EVENT Timeout OPTIONAL