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