]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/TcpIoLib.h
Add three INIT flag in Debug Agent Library.
[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
14**/
15
16#ifndef _TCP_IO_H_
17#define _TCP_IO_H_\r
18\r
19\r
20#include <Protocol/Tcp4.h>\r
21#include <Protocol/Tcp6.h>\r
22\r
23#include <Library/NetLib.h>
24\r
25#define TCP_VERSION_4 IP_VERSION_4\r
26#define TCP_VERSION_6 IP_VERSION_6\r
27\r
28///
29/// 10 seconds
30///
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
43} TCP4_IO_CONFIG_DATA;
44\r
45typedef struct {
46 UINT16 StationPort;\r
47 EFI_IPv6_ADDRESS RemoteIp;\r
48 UINT16 RemotePort;
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
115 @retval EFI_UNSUPPORTED One or more of the control options are not
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
123TcpIoCreateSocket (
124 IN EFI_HANDLE Image,
125 IN EFI_HANDLE Controller,\r
126 IN UINT8 TcpVersion,
127 IN TCP_IO_CONFIG_DATA *ConfigData,
128 OUT TCP_IO *TcpIo
129 );
130
131/**
132 Destroy the socket.
133
134 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.
135
136**/
137VOID
138EFIAPI\r
139TcpIoDestroySocket (
140 IN TCP_IO *TcpIo
141 );
142
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
159EFI_STATUS
160EFIAPI\r
161TcpIoConnect (
162 IN OUT TCP_IO *TcpIo,
163 IN EFI_EVENT Timeout
164 );
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
190
191/**
192 Reset the socket.
193
194 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.
195
196**/
197VOID
198EFIAPI\r
199TcpIoReset (
200 IN OUT TCP_IO *TcpIo
201 );
202
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
218EFI_STATUS
219EFIAPI\r
220TcpIoTransmit (
221 IN TCP_IO *TcpIo,
222 IN NET_BUF *Packet
223 );
224
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
243EFI_STATUS
244EFIAPI\r
245TcpIoReceive (
246 IN OUT TCP_IO *TcpIo,
247 IN NET_BUF *Packet,
248 IN BOOLEAN AsyncMode,
249 IN EFI_EVENT Timeout
250 );
251\r
252#endif\r
253\r