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