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