]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Tcp4.h
Import Pal.h and Sal.h.
[mirror_edk2.git] / MdePkg / Include / Protocol / Tcp4.h
CommitLineData
d1f95000 1/** @file\r
2 EFI TCPv4 Protocol Definition\r
3 The EFI TCPv4 Service Binding Protocol is used to locate EFI TCPv4 Protocol drivers to create\r
4 and destroy child of the driver to communicate with other host using TCP protocol. \r
5 The EFI TCPv4 Protocol provides services to send and receive data stream. \r
6\r
7 Copyright (c) 2006, Intel Corporation \r
8 All rights reserved. This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
16 Module Name: Tcp4.h\r
17\r
18**/\r
19\r
20#ifndef __EFI_TCP4_PROTOCOL_H__\r
21#define __EFI_TCP4_PROTOCOL_H__\r
22\r
23#include <Protocol/Ip4.h>\r
24\r
25#define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
26 { \\r
27 0x00720665, 0x67EB, 0x4a99, {0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } \\r
28 }\r
29\r
30#define EFI_TCP4_PROTOCOL_GUID \\r
31 { \\r
32 0x65530BC7, 0xA359, 0x410f, {0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } \\r
33 }\r
34\r
35typedef struct _EFI_TCP4_PROTOCOL EFI_TCP4_PROTOCOL;\r
36\r
37typedef struct {\r
38 EFI_HANDLE InstanceHandle;\r
39 EFI_IPv4_ADDRESS LocalAddress;\r
40 UINT16 LocalPort;\r
41 EFI_IPv4_ADDRESS RemoteAddress;\r
42 UINT16 RemotePort;\r
43} EFI_TCP4_SERVICE_POINT;\r
44\r
45typedef struct {\r
46 EFI_HANDLE DriverHandle;\r
47 UINT32 ServiceCount;\r
48 EFI_TCP4_SERVICE_POINT Services[1];\r
49} EFI_TCP4_VARIABLE_DATA;\r
50\r
51typedef struct {\r
52 BOOLEAN UseDefaultAddress;\r
53 EFI_IPv4_ADDRESS StationAddress;\r
54 EFI_IPv4_ADDRESS SubnetMask;\r
55 UINT16 StationPort;\r
56 EFI_IPv4_ADDRESS RemoteAddress;\r
57 UINT16 RemotePort;\r
58 BOOLEAN ActiveFlag;\r
59} EFI_TCP4_ACCESS_POINT;\r
60\r
61typedef struct {\r
62 UINTN ReceiveBufferSize;\r
63 UINTN SendBufferSize;\r
64 UINTN MaxSynBackLog;\r
65 UINTN ConnectionTimeout;\r
66 UINTN DataRetries;\r
67 UINTN FinTimeout;\r
68 UINTN TimeWaitTimeout;\r
69 UINTN KeepAliveProbes;\r
70 UINTN KeepAliveTime;\r
71 UINTN KeepAliveInterval;\r
72 BOOLEAN EnableNagle;\r
73 BOOLEAN EnableTimeStamp;\r
74 BOOLEAN EnableWindowScaling;\r
75 BOOLEAN EnableSelectiveAck;\r
76 BOOLEAN EnablePathMtuDiscovery;\r
77} EFI_TCP4_OPTION;\r
78\r
79typedef struct {\r
80 //\r
81 // I/O parameters\r
82 //\r
83 UINT8 TypeOfService;\r
84 UINT8 TimeToLive;\r
85\r
86 //\r
87 // Access Point\r
88 //\r
89 EFI_TCP4_ACCESS_POINT AccessPoint;\r
90 \r
91 // \r
92 // TCP Control Options \r
93 // \r
94 EFI_TCP4_OPTION *ControlOption;\r
95} EFI_TCP4_CONFIG_DATA;\r
96\r
97typedef enum {\r
98 Tcp4StateClosed = 0,\r
99 Tcp4StateListen = 1,\r
100 Tcp4StateSynSent = 2,\r
101 Tcp4StateSynReceived = 3,\r
102 Tcp4StateEstablished = 4,\r
103 Tcp4StateFinWait1 = 5,\r
104 Tcp4StateFinWait2 = 6,\r
105 Tcp4StateClosing = 7,\r
106 Tcp4StateTimeWait = 8,\r
107 Tcp4StateCloseWait = 9,\r
108 Tcp4StateLastAck = 10\r
109} EFI_TCP4_CONNECTION_STATE;\r
110\r
111typedef struct {\r
112 EFI_EVENT Event;\r
113 EFI_STATUS Status;\r
114} EFI_TCP4_COMPLETION_TOKEN;\r
115\r
116typedef struct {\r
117 EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
118} EFI_TCP4_CONNECTION_TOKEN;\r
119\r
120typedef struct {\r
121 EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
122 EFI_HANDLE NewChildHandle;\r
123} EFI_TCP4_LISTEN_TOKEN;\r
124\r
125typedef struct {\r
126 UINTN FragmentLength;\r
127 VOID *FragmentBuffer;\r
128} EFI_TCP4_FRAGMENT_DATA;\r
129\r
130typedef struct {\r
131 BOOLEAN UrgentFlag;\r
132 IN OUT UINTN DataLength;\r
133 UINTN FragmentCount;\r
134 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];\r
135} EFI_TCP4_RECEIVE_DATA; \r
136\r
137typedef struct { \r
138 BOOLEAN Push;\r
139 BOOLEAN Urgent;\r
140 UINTN DataLength;\r
141 UINTN FragmentCount;\r
142 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];\r
143} EFI_TCP4_TRANSMIT_DATA;\r
144\r
145typedef struct {\r
146 EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
147 union {\r
148 EFI_TCP4_RECEIVE_DATA *RxData;\r
149 EFI_TCP4_TRANSMIT_DATA *TxData;\r
150 } Packet;\r
151} EFI_TCP4_IO_TOKEN;\r
152\r
153typedef struct {\r
154 EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
155 BOOLEAN AbortOnClose;\r
156} EFI_TCP4_CLOSE_TOKEN;\r
157\r
158//\r
159// Interface definition for TCP4 protocol\r
160//\r
161\r
162/**\r
163 Get the current operational status.\r
164\r
165 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
166 @param Tcp4State Pointer to the buffer to receive the current TCP state.\r
167 @param Tcp4ConfigData Pointer to the buffer to receive the current TCP configuration.\r
168 @param Ip4ModeData Pointer to the buffer to receive the current IPv4 configuration\r
169 data used by the TCPv4 instance.\r
170 @param MnpConfigData Pointer to the buffer to receive the current MNP configuration\r
171 data used indirectly by the TCPv4 instance.\r
172 @param SnpModeData Pointer to the buffer to receive the current SNP configuration\r
173 data used indirectly by the TCPv4 instance.\r
174\r
175 @retval EFI_SUCCESS The mode data was read.\r
176 @retval EFI_INVALID_PARAMETER This is NULL.\r
177 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't\r
178 been started.\r
179\r
180**/\r
181typedef\r
182EFI_STATUS\r
183(EFIAPI *EFI_TCP4_GET_MODE_DATA) (\r
184 IN CONST EFI_TCP4_PROTOCOL *This,\r
185 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,\r
186 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,\r
187 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
188 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
189 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
190 )\r
191;\r
192 \r
193/**\r
194 Initialize or brutally reset the operational parameters for this EFI TCPv4 instance.\r
195\r
196 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
197 @param Tcp4ConfigData Pointer to the configure data to configure the instance.\r
198\r
199 @retval EFI_SUCCESS The operational settings are set, changed, or reset\r
200 successfully.\r
201 @retval EFI_INVALID_PARAMETER Some parameter is invalid.\r
202 @retval EFI_NO_MAPPING When using a default address, configuration (through\r
203 DHCP, BOOTP, RARP, etc.) is not finished yet.\r
204 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without\r
205 calling Configure() with NULL to reset it.\r
206 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
207 @retval EFI_UNSUPPORTED One or more of the control options are not supported in\r
208 the implementation.\r
209 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
210 executing Configure().\r
211\r
212**/\r
213typedef\r
214EFI_STATUS\r
215(EFIAPI *EFI_TCP4_CONFIGURE) (\r
216 IN EFI_TCP4_PROTOCOL *This,\r
217 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL\r
218 )\r
219;\r
220 \r
221\r
222/**\r
223 Add or delete a route entry to the route table\r
224\r
225 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
226 @param DeleteRoute Set it to TRUE to delete this route from the routing table. Set it to\r
227 FALSE to add this route to the routing table.\r
228 DestinationAddress and SubnetMask are used as the\r
229 keywords to search route entry.\r
230 @param SubnetAddress The destination network.\r
231 @param SubnetMask The subnet mask of the destination network.\r
232 @param GatewayAddress The gateway address for this route. It must be on the same\r
233 subnet with the station address unless a direct route is specified.\r
234\r
235 @retval EFI_SUCCESS The operation completed successfully.\r
236 @retval EFI_NOT_STARTED The EFI TCPv4 Protocol instance has not been configured.\r
237 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
238 RARP, etc.) is not finished yet.\r
239 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
240 - This is NULL.\r
241 - SubnetAddress is NULL.\r
242 - SubnetMask is NULL.\r
243 - GatewayAddress is NULL.\r
244 - *SubnetAddress is not NULL a valid subnet address.\r
245 - *SubnetMask is not a valid subnet mask.\r
246 - *GatewayAddress is not a valid unicast IP address or it\r
247 is not in the same subnet.\r
248 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the entry to the\r
249 routing table.\r
250 @retval EFI_NOT_FOUND This route is not in the routing table.\r
251 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.\r
252 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.\r
253\r
254**/\r
255typedef\r
256EFI_STATUS\r
257(EFIAPI *EFI_TCP4_ROUTES) (\r
258 IN EFI_TCP4_PROTOCOL *This,\r
259 IN BOOLEAN DeleteRoute,\r
260 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
261 IN EFI_IPv4_ADDRESS *SubnetMask,\r
262 IN EFI_IPv4_ADDRESS *GatewayAddress\r
263 )\r
264; \r
265\r
266/**\r
267 Initiate a nonblocking TCP connection request for an active TCP instance.\r
268\r
269 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
270 @param ConnectionToken Pointer to the connection token to return when the TCP three\r
271 way handshake finishes.\r
272 \r
273 @retval EFI_SUCCESS The connection request is successfully initiated and the state\r
274 - of this TCPv4 instance has been changed to\r
275 - Tcp4StateSynSent.\r
276 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
277 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:\r
278 - This instance is not configured as an active one.\r
279 - This instance is not in Tcp4StateClosed state.\r
280 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
281 - This is NULL.\r
282 - ConnectionToken is NULL.\r
283 - ConnectionToken->CompletionToken.Event is NULL.\r
284 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the activeopen.\r
285 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
286\r
287**/\r
288typedef\r
289EFI_STATUS\r
290(EFIAPI *EFI_TCP4_CONNECT) (\r
291 IN EFI_TCP4_PROTOCOL *This,\r
292 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken\r
293 )\r
294; \r
295 \r
296\r
297/**\r
298 Listen on the passive instance to accept an incoming connection request. This is a nonblocking operation.\r
299\r
300 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
301 @param ListenToken Pointer to the listen token to return when operation finishes.\r
302\r
303 @retval EFI_SUCCESS The listen token has been queued successfully.\r
304 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
305 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r
306 - This instance is not a passive instance.\r
307 - This instance is not in Tcp4StateListen state.\r
308 - The same listen token has already existed in the listen\r
309 token queue of this TCP instance.\r
310 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
311 - This is NULL.\r
312 - ListenToken is NULL.\r
313 - ListentToken->CompletionToken.Event is NULL.\r
314 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r
315 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.\r
316\r
317**/\r
318typedef\r
319EFI_STATUS\r
320(EFIAPI *EFI_TCP4_ACCEPT) (\r
321 IN EFI_TCP4_PROTOCOL *This,\r
322 IN EFI_TCP4_LISTEN_TOKEN *ListenToken\r
323 )\r
324; \r
325\r
326/**\r
327 Queues outgoing data into the transmit queue.\r
328\r
329 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
330 @param Token Pointer to the completion token to queue to the transmit queue.\r
331\r
332 @retval EFI_SUCCESS The data has been queued for transmission.\r
333 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
334 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
335 RARP, etc.) is not finished yet.\r
336 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
337 - This is NULL.\r
338 - Token is NULL.\r
339 - Token->CompletionToken.Event is NULL.\r
340 - Token->Packet.TxData is NULL L.\r
341 - Token->Packet.FragmentCount is zero.\r
342 - Token->Packet.DataLength is not equal to the sum of fragment lengths.\r
343 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
344 - A transmit completion token with the same Token->CompletionToken.Event\r
345 was already in the transmission queue.\r
346 - The current instance is in Tcp4StateClosed state.\r
347 - The current instance is a passive one and it is in\r
348 Tcp4StateListen state.\r
349 - User has called Close() to disconnect this connection.\r
350 @retval EFI_NOT_READY The completion token could not be queued because the\r
351 transmit queue is full.\r
352 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource\r
353 shortage.\r
354 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.\r
355\r
356**/\r
357typedef\r
358EFI_STATUS\r
359(EFIAPI *EFI_TCP4_TRANSMIT) (\r
360 IN EFI_TCP4_PROTOCOL *This,\r
361 IN EFI_TCP4_IO_TOKEN *Token\r
362 )\r
363; \r
364\r
365\r
366/**\r
367 Places an asynchronous receive request into the receiving queue.\r
368\r
369 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
370 @param Token Pointer to a token that is associated with the receive data\r
371 descriptor.\r
372\r
373 @retval EFI_SUCCESS The receive completion token was cached.\r
374 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
375 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP,\r
376 etc.) is not finished yet.\r
377 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
378 - This is NULL.\r
379 - Token is NULL.\r
380 - Token->CompletionToken.Event is NULL.\r
381 - Token->Packet.RxData is NULL.\r
382 - Token->Packet.RxData->DataLength is 0.\r
383 - The Token->Packet.RxData->DataLength is not\r
384 the sum of all FragmentBuffer length in FragmentTable.\r
385 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of\r
386 system resources (usually memory).\r
387 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
388 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
389 - A receive completion token with the same Token-\r
390 >CompletionToken.Event was already in the receive\r
391 queue.\r
392 - The current instance is in Tcp4StateClosed state.\r
393 - The current instance is a passive one and it is in\r
394 Tcp4StateListen state.\r
395 - User has called Close() to disconnect this connection.\r
396 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is\r
397 no any buffered data in the receive buffer of this instance.\r
398 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
399\r
400**/\r
401typedef\r
402EFI_STATUS\r
403(EFIAPI *EFI_TCP4_RECEIVE) (\r
404 IN EFI_TCP4_PROTOCOL *This,\r
405 IN EFI_TCP4_IO_TOKEN *Token\r
406 )\r
407; \r
408 \r
409/**\r
410 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a\r
411 nonblocking operation. \r
412\r
413 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
414 @param CloseToken Pointer to the close token to return when operation finishes.\r
415\r
416 @retval EFI_SUCCESS The Close() is called successfully.\r
417 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
418 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r
419 - Configure() has been called with\r
420 TcpConfigData set to NULL and this function has\r
421 not returned.\r
422 - Previous Close() call on this instance has not\r
423 finished.\r
424 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
425 - This is NULL.\r
426 - CloseToken is NULL.\r
427 - CloseToken->CompletionToken.Event is NULL.\r
428 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r
429 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.\r
430\r
431**/\r
432typedef\r
433EFI_STATUS\r
434(EFIAPI *EFI_TCP4_CLOSE) (\r
435 IN EFI_TCP4_PROTOCOL *This,\r
436 IN EFI_TCP4_CLOSE_TOKEN *CloseToken\r
437 )\r
438; \r
439\r
440/**\r
441 Abort an asynchronous connection, listen, transmission or receive request.\r
442\r
443 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
444 @param Token Pointer to a token that has been issued by\r
445 EFI_TCP4_PROTOCOL.Connect(),\r
446 EFI_TCP4_PROTOCOL.Accept(),\r
447 EFI_TCP4_PROTOCOL.Transmit() or\r
448 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r
449 tokens issued by above four functions will be aborted. Type\r
450 EFI_TCP4_COMPLETION_TOKEN is defined in\r
451 EFI_TCP4_PROTOCOL.Connect().\r
452\r
453 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
454 @retval EFI_INVALID_PARAMETER This is NULL.\r
455 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
456 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
457 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.\r
458 Consider increasing the polling rate.\r
459\r
460**/\r
461typedef\r
462EFI_STATUS\r
463(EFIAPI *EFI_TCP4_CANCEL) (\r
464 IN EFI_TCP4_PROTOCOL *This,\r
465 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r
466 )\r
467; \r
468\r
469\r
470/**\r
471 Poll to receive incoming data and transmit outgoing segments.\r
472\r
473 @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
474\r
475 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
476 @retval EFI_INVALID_PARAMETER This is NULL.\r
477 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
478 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
479 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.\r
480 Consider increasing the polling rate.\r
481\r
482**/\r
483typedef\r
484EFI_STATUS\r
485(EFIAPI *EFI_TCP4_POLL) (\r
486 IN EFI_TCP4_PROTOCOL *This\r
487 )\r
488; \r
489\r
490struct _EFI_TCP4_PROTOCOL {\r
491 EFI_TCP4_GET_MODE_DATA GetModeData;\r
492 EFI_TCP4_CONFIGURE Configure;\r
493 EFI_TCP4_ROUTES Routes;\r
494 EFI_TCP4_CONNECT Connect;\r
495 EFI_TCP4_ACCEPT Accept;\r
496 EFI_TCP4_TRANSMIT Transmit;\r
497 EFI_TCP4_RECEIVE Receive;\r
498 EFI_TCP4_CLOSE Close;\r
499 EFI_TCP4_CANCEL Cancel;\r
500 EFI_TCP4_POLL Poll;\r
501};\r
502\r
503#define EFI_CONNECTION_FIN EFIERR (104)\r
504#define EFI_CONNECTION_RESET EFIERR (105)\r
505#define EFI_CONNECTION_REFUSED EFIERR (106)\r
506\r
507extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;\r
508extern EFI_GUID gEfiTcp4ProtocolGuid;\r
509\r
510#endif\r