]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Include/Library/TcpIoLib.h
NetworkPkg: Move Network library and drivers from MdeModulePkg to NetworkPkg
[mirror_edk2.git] / MdeModulePkg / Include / Library / TcpIoLib.h
... / ...
CommitLineData
1/** @file\r
2 This library is used to share code between UEFI network stack modules.\r
3 It provides the helper routines to access TCP service.\r
4\r
5Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef _TCP_IO_H_\r
11#define _TCP_IO_H_\r
12\r
13\r
14#include <Protocol/Tcp4.h>\r
15#include <Protocol/Tcp6.h>\r
16\r
17#include <Library/NetLib.h>\r
18\r
19#define TCP_VERSION_4 IP_VERSION_4\r
20#define TCP_VERSION_6 IP_VERSION_6\r
21\r
22///\r
23/// 10 seconds\r
24///\r
25#define TCP_GET_MAPPING_TIMEOUT 100000000U\r
26\r
27\r
28typedef struct {\r
29 EFI_IPv4_ADDRESS LocalIp;\r
30 EFI_IPv4_ADDRESS SubnetMask;\r
31 EFI_IPv4_ADDRESS Gateway;\r
32\r
33 UINT16 StationPort;\r
34 EFI_IPv4_ADDRESS RemoteIp;\r
35 UINT16 RemotePort;\r
36 BOOLEAN ActiveFlag;\r
37} TCP4_IO_CONFIG_DATA;\r
38\r
39typedef struct {\r
40 UINT16 StationPort;\r
41 EFI_IPv6_ADDRESS RemoteIp;\r
42 UINT16 RemotePort;\r
43 BOOLEAN ActiveFlag;\r
44} TCP6_IO_CONFIG_DATA;\r
45\r
46typedef union {\r
47 TCP4_IO_CONFIG_DATA Tcp4IoConfigData;\r
48 TCP6_IO_CONFIG_DATA Tcp6IoConfigData;\r
49} TCP_IO_CONFIG_DATA;\r
50\r
51typedef union {\r
52 EFI_TCP4_PROTOCOL *Tcp4;\r
53 EFI_TCP6_PROTOCOL *Tcp6;\r
54} TCP_IO_PROTOCOL;\r
55\r
56typedef union {\r
57 EFI_TCP4_CONNECTION_TOKEN Tcp4Token;\r
58 EFI_TCP6_CONNECTION_TOKEN Tcp6Token;\r
59} TCP_IO_CONNECTION_TOKEN;\r
60\r
61typedef union {\r
62 EFI_TCP4_IO_TOKEN Tcp4Token;\r
63 EFI_TCP6_IO_TOKEN Tcp6Token;\r
64} TCP_IO_IO_TOKEN;\r
65\r
66typedef union {\r
67 EFI_TCP4_CLOSE_TOKEN Tcp4Token;\r
68 EFI_TCP6_CLOSE_TOKEN Tcp6Token;\r
69} TCP_IO_CLOSE_TOKEN;\r
70\r
71typedef union {\r
72 EFI_TCP4_LISTEN_TOKEN Tcp4Token;\r
73 EFI_TCP6_LISTEN_TOKEN Tcp6Token;\r
74} TCP_IO_LISTEN_TOKEN;\r
75\r
76\r
77typedef struct {\r
78 UINT8 TcpVersion;\r
79 EFI_HANDLE Image;\r
80 EFI_HANDLE Controller;\r
81 EFI_HANDLE Handle;\r
82\r
83 TCP_IO_PROTOCOL Tcp;\r
84 TCP_IO_PROTOCOL NewTcp;\r
85 TCP_IO_CONNECTION_TOKEN ConnToken;\r
86 TCP_IO_IO_TOKEN TxToken;\r
87 TCP_IO_IO_TOKEN RxToken;\r
88 TCP_IO_CLOSE_TOKEN CloseToken;\r
89 TCP_IO_LISTEN_TOKEN ListenToken;\r
90\r
91 BOOLEAN IsConnDone;\r
92 BOOLEAN IsTxDone;\r
93 BOOLEAN IsRxDone;\r
94 BOOLEAN IsCloseDone;\r
95 BOOLEAN IsListenDone;\r
96} TCP_IO;\r
97\r
98/**\r
99 Create a TCP socket with the specified configuration data.\r
100\r
101 @param[in] Image The handle of the driver image.\r
102 @param[in] Controller The handle of the controller.\r
103 @param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.\r
104 @param[in] ConfigData The Tcp configuration data.\r
105 @param[out] TcpIo The TcpIo.\r
106\r
107 @retval EFI_SUCCESS The TCP socket is created and configured.\r
108 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
109 @retval EFI_UNSUPPORTED One or more of the control options are not\r
110 supported in the implementation.\r
111 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
112 @retval Others Failed to create the TCP socket or configure it.\r
113\r
114**/\r
115EFI_STATUS\r
116EFIAPI\r
117TcpIoCreateSocket (\r
118 IN EFI_HANDLE Image,\r
119 IN EFI_HANDLE Controller,\r
120 IN UINT8 TcpVersion,\r
121 IN TCP_IO_CONFIG_DATA *ConfigData,\r
122 OUT TCP_IO *TcpIo\r
123 );\r
124\r
125/**\r
126 Destroy the socket.\r
127\r
128 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.\r
129\r
130**/\r
131VOID\r
132EFIAPI\r
133TcpIoDestroySocket (\r
134 IN TCP_IO *TcpIo\r
135 );\r
136\r
137/**\r
138 Connect to the other endpoint of the TCP socket.\r
139\r
140 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
141 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.\r
142\r
143 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket\r
144 successfully.\r
145 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the\r
146 TCP socket in the specified time period.\r
147 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
148 @retval EFI_UNSUPPORTED One or more of the control options are not\r
149 supported in the implementation.\r
150 @retval Others Other errors as indicated.\r
151\r
152**/\r
153EFI_STATUS\r
154EFIAPI\r
155TcpIoConnect (\r
156 IN OUT TCP_IO *TcpIo,\r
157 IN EFI_EVENT Timeout OPTIONAL\r
158 );\r
159\r
160/**\r
161 Accept the incomding request from the other endpoint of the TCP socket.\r
162\r
163 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
164 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.\r
165\r
166\r
167 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket\r
168 successfully.\r
169 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
170 @retval EFI_UNSUPPORTED One or more of the control options are not\r
171 supported in the implementation.\r
172\r
173 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the\r
174 TCP socket in the specified time period.\r
175 @retval Others Other errors as indicated.\r
176\r
177**/\r
178EFI_STATUS\r
179EFIAPI\r
180TcpIoAccept (\r
181 IN OUT TCP_IO *TcpIo,\r
182 IN EFI_EVENT Timeout OPTIONAL\r
183 );\r
184\r
185/**\r
186 Reset the socket.\r
187\r
188 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
189\r
190**/\r
191VOID\r
192EFIAPI\r
193TcpIoReset (\r
194 IN OUT TCP_IO *TcpIo\r
195 );\r
196\r
197/**\r
198 Transmit the Packet to the other endpoint of the socket.\r
199\r
200 @param[in] TcpIo The TcpIo wrapping the TCP socket.\r
201 @param[in] Packet The packet to transmit.\r
202\r
203 @retval EFI_SUCCESS The packet is trasmitted.\r
204 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
205 @retval EFI_UNSUPPORTED One or more of the control options are not\r
206 supported in the implementation.\r
207 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
208 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
209 @retval Others Other errors as indicated.\r
210\r
211**/\r
212EFI_STATUS\r
213EFIAPI\r
214TcpIoTransmit (\r
215 IN TCP_IO *TcpIo,\r
216 IN NET_BUF *Packet\r
217 );\r
218\r
219/**\r
220 Receive data from the socket.\r
221\r
222 @param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.\r
223 @param[in] Packet The buffer to hold the data copy from the socket rx buffer.\r
224 @param[in] AsyncMode Is this receive asyncronous or not.\r
225 @param[in] Timeout The time to wait for receiving the amount of data the Packet\r
226 can hold. Set to NULL for infinite wait.\r
227\r
228 @retval EFI_SUCCESS The required amount of data is received from the socket.\r
229 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
230 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
231 @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.\r
232 @retval EFI_TIMEOUT Failed to receive the required amount of data in the\r
233 specified time period.\r
234 @retval Others Other errors as indicated.\r
235\r
236**/\r
237EFI_STATUS\r
238EFIAPI\r
239TcpIoReceive (\r
240 IN OUT TCP_IO *TcpIo,\r
241 IN NET_BUF *Packet,\r
242 IN BOOLEAN AsyncMode,\r
243 IN EFI_EVENT Timeout OPTIONAL\r
244 );\r
245\r
246#endif\r
247\r