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