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
13 #include <Protocol/Tcp4.h>
14 #include <Protocol/Tcp6.h>
16 #include <Library/NetLib.h>
18 #define TCP_VERSION_4 IP_VERSION_4
19 #define TCP_VERSION_6 IP_VERSION_6
24 #define TCP_GET_MAPPING_TIMEOUT 100000000U
27 EFI_IPv4_ADDRESS LocalIp
;
28 EFI_IPv4_ADDRESS SubnetMask
;
29 EFI_IPv4_ADDRESS Gateway
;
32 EFI_IPv4_ADDRESS RemoteIp
;
35 } TCP4_IO_CONFIG_DATA
;
39 EFI_IPv6_ADDRESS RemoteIp
;
42 } TCP6_IO_CONFIG_DATA
;
45 TCP4_IO_CONFIG_DATA Tcp4IoConfigData
;
46 TCP6_IO_CONFIG_DATA Tcp6IoConfigData
;
50 EFI_TCP4_PROTOCOL
*Tcp4
;
51 EFI_TCP6_PROTOCOL
*Tcp6
;
55 EFI_TCP4_CONNECTION_TOKEN Tcp4Token
;
56 EFI_TCP6_CONNECTION_TOKEN Tcp6Token
;
57 } TCP_IO_CONNECTION_TOKEN
;
60 EFI_TCP4_IO_TOKEN Tcp4Token
;
61 EFI_TCP6_IO_TOKEN Tcp6Token
;
65 EFI_TCP4_CLOSE_TOKEN Tcp4Token
;
66 EFI_TCP6_CLOSE_TOKEN Tcp6Token
;
70 EFI_TCP4_LISTEN_TOKEN Tcp4Token
;
71 EFI_TCP6_LISTEN_TOKEN Tcp6Token
;
72 } TCP_IO_LISTEN_TOKEN
;
77 EFI_HANDLE Controller
;
81 TCP_IO_PROTOCOL NewTcp
;
82 TCP_IO_CONNECTION_TOKEN ConnToken
;
83 TCP_IO_IO_TOKEN TxToken
;
84 TCP_IO_IO_TOKEN RxToken
;
85 TCP_IO_CLOSE_TOKEN CloseToken
;
86 TCP_IO_LISTEN_TOKEN ListenToken
;
96 Create a TCP socket with the specified configuration data.
98 @param[in] Image The handle of the driver image.
99 @param[in] Controller The handle of the controller.
100 @param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.
101 @param[in] ConfigData The Tcp configuration data.
102 @param[out] TcpIo The TcpIo.
104 @retval EFI_SUCCESS The TCP socket is created and configured.
105 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
106 @retval EFI_UNSUPPORTED One or more of the control options are not
107 supported in the implementation.
108 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
109 @retval Others Failed to create the TCP socket or configure it.
116 IN EFI_HANDLE Controller
,
118 IN TCP_IO_CONFIG_DATA
*ConfigData
,
125 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
135 Connect to the other endpoint of the TCP socket.
137 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
138 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.
140 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
142 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
143 TCP socket in the specified time period.
144 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
145 @retval EFI_UNSUPPORTED One or more of the control options are not
146 supported in the implementation.
147 @retval Others Other errors as indicated.
153 IN OUT TCP_IO
*TcpIo
,
154 IN EFI_EVENT Timeout OPTIONAL
158 Accept the incomding request from the other endpoint of the TCP socket.
160 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
161 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.
164 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket
166 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
167 @retval EFI_UNSUPPORTED One or more of the control options are not
168 supported in the implementation.
170 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the
171 TCP socket in the specified time period.
172 @retval Others Other errors as indicated.
178 IN OUT TCP_IO
*TcpIo
,
179 IN EFI_EVENT Timeout OPTIONAL
185 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
195 Transmit the Packet to the other endpoint of the socket.
197 @param[in] TcpIo The TcpIo wrapping the TCP socket.
198 @param[in] Packet The packet to transmit.
200 @retval EFI_SUCCESS The packet is transmitted.
201 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
202 @retval EFI_UNSUPPORTED One or more of the control options are not
203 supported in the implementation.
204 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
205 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
206 @retval Others Other errors as indicated.
217 Receive data from the socket.
219 @param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.
220 @param[in] Packet The buffer to hold the data copy from the socket rx buffer.
221 @param[in] AsyncMode Is this receive asynchronous or not.
222 @param[in] Timeout The time to wait for receiving the amount of data the Packet
223 can hold. Set to NULL for infinite wait.
225 @retval EFI_SUCCESS The required amount of data is received from the socket.
226 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
227 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
228 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
229 @retval EFI_TIMEOUT Failed to receive the required amount of data in the
230 specified time period.
231 @retval Others Other errors as indicated.
237 IN OUT TCP_IO
*TcpIo
,
239 IN BOOLEAN AsyncMode
,
240 IN EFI_EVENT Timeout OPTIONAL