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.
7 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available under
9 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
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.
16 @par Revision Reference:
17 This Protocol is introduced in UEFI Specification 2.0.
21 #ifndef __EFI_TCP4_PROTOCOL_H__
22 #define __EFI_TCP4_PROTOCOL_H__
24 FILE_LICENCE ( BSD3 );
26 #include <ipxe/efi/Protocol/Ip4.h>
28 #define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \
30 0x00720665, 0x67EB, 0x4a99, {0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } \
33 #define EFI_TCP4_PROTOCOL_GUID \
35 0x65530BC7, 0xA359, 0x410f, {0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } \
38 typedef struct _EFI_TCP4_PROTOCOL EFI_TCP4_PROTOCOL;
41 /// EFI_TCP4_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.
42 /// The definition in here is only present to provide backwards compatability.
45 EFI_HANDLE InstanceHandle;
46 EFI_IPv4_ADDRESS LocalAddress;
48 EFI_IPv4_ADDRESS RemoteAddress;
50 } EFI_TCP4_SERVICE_POINT;
53 /// EFI_TCP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
54 /// The definition in here is only present to provide backwards compatability.
57 EFI_HANDLE DriverHandle;
59 EFI_TCP4_SERVICE_POINT Services[1];
60 } EFI_TCP4_VARIABLE_DATA;
63 BOOLEAN UseDefaultAddress;
64 EFI_IPv4_ADDRESS StationAddress;
65 EFI_IPv4_ADDRESS SubnetMask;
67 EFI_IPv4_ADDRESS RemoteAddress;
70 } EFI_TCP4_ACCESS_POINT;
73 UINT32 ReceiveBufferSize;
74 UINT32 SendBufferSize;
76 UINT32 ConnectionTimeout;
79 UINT32 TimeWaitTimeout;
80 UINT32 KeepAliveProbes;
82 UINT32 KeepAliveInterval;
84 BOOLEAN EnableTimeStamp;
85 BOOLEAN EnableWindowScaling;
86 BOOLEAN EnableSelectiveAck;
87 BOOLEAN EnablePathMtuDiscovery;
100 EFI_TCP4_ACCESS_POINT AccessPoint;
103 // TCP Control Options
105 EFI_TCP4_OPTION *ControlOption;
106 } EFI_TCP4_CONFIG_DATA;
109 /// TCP4 connnection state
114 Tcp4StateSynSent = 2,
115 Tcp4StateSynReceived = 3,
116 Tcp4StateEstablished = 4,
117 Tcp4StateFinWait1 = 5,
118 Tcp4StateFinWait2 = 6,
119 Tcp4StateClosing = 7,
120 Tcp4StateTimeWait = 8,
121 Tcp4StateCloseWait = 9,
122 Tcp4StateLastAck = 10
123 } EFI_TCP4_CONNECTION_STATE;
128 } EFI_TCP4_COMPLETION_TOKEN;
132 /// The Status in the CompletionToken will be set to one of
133 /// the following values if the active open succeeds or an unexpected
135 /// EFI_SUCCESS: The active open succeeds and the instance's
136 /// state is Tcp4StateEstablished.
137 /// EFI_CONNECTION_RESET: The connect fails because the connection is reset
138 /// either by instance itself or the communication peer.
139 /// EFI_CONNECTION_REFUSED: The connect fails because this connection is initiated with
140 /// an active open and the connection is refused.
141 /// EFI_ABORTED: The active open is aborted.
142 /// EFI_TIMEOUT: The connection establishment timer expires and
143 /// no more specific information is available.
144 /// EFI_NETWORK_UNREACHABLE: The active open fails because
145 /// an ICMP network unreachable error is received.
146 /// EFI_HOST_UNREACHABLE: The active open fails because an
147 /// ICMP host unreachable error is received.
148 /// EFI_PROTOCOL_UNREACHABLE: The active open fails
149 /// because an ICMP protocol unreachable error is received.
150 /// EFI_PORT_UNREACHABLE: The connection establishment
151 /// timer times out and an ICMP port unreachable error is received.
152 /// EFI_ICMP_ERROR: The connection establishment timer timeout and some other ICMP
153 /// error is received.
154 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
155 /// EFI_NO_MEDIA: There was a media error.
157 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
158 } EFI_TCP4_CONNECTION_TOKEN;
161 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
162 EFI_HANDLE NewChildHandle;
163 } EFI_TCP4_LISTEN_TOKEN;
166 UINT32 FragmentLength;
167 VOID *FragmentBuffer;
168 } EFI_TCP4_FRAGMENT_DATA;
173 UINT32 FragmentCount;
174 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
175 } EFI_TCP4_RECEIVE_DATA;
181 UINT32 FragmentCount;
182 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
183 } EFI_TCP4_TRANSMIT_DATA;
187 /// When transmission finishes or meets any unexpected error it will
188 /// be set to one of the following values:
189 /// EFI_SUCCESS: The receiving or transmission operation
190 /// completes successfully.
191 /// EFI_CONNECTION_FIN: The receiving operation fails because the communication peer
192 /// has closed the connection and there is no more data in the
193 /// receive buffer of the instance.
194 /// EFI_CONNECTION_RESET: The receiving or transmission operation fails
195 /// because this connection is reset either by instance
196 /// itself or the communication peer.
197 /// EFI_ABORTED: The receiving or transmission is aborted.
198 /// EFI_TIMEOUT: The transmission timer expires and no more
199 /// specific information is available.
200 /// EFI_NETWORK_UNREACHABLE: The transmission fails
201 /// because an ICMP network unreachable error is received.
202 /// EFI_HOST_UNREACHABLE: The transmission fails because an
203 /// ICMP host unreachable error is received.
204 /// EFI_PROTOCOL_UNREACHABLE: The transmission fails
205 /// because an ICMP protocol unreachable error is received.
206 /// EFI_PORT_UNREACHABLE: The transmission fails and an
207 /// ICMP port unreachable error is received.
208 /// EFI_ICMP_ERROR: The transmission fails and some other
209 /// ICMP error is received.
210 /// EFI_DEVICE_ERROR: An unexpected system or network error occurs.
211 /// EFI_NO_MEDIA: There was a media error.
213 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
216 /// When this token is used for receiving, RxData is a pointer to EFI_TCP4_RECEIVE_DATA.
218 EFI_TCP4_RECEIVE_DATA *RxData;
220 /// When this token is used for transmitting, TxData is a pointer to EFI_TCP4_TRANSMIT_DATA.
222 EFI_TCP4_TRANSMIT_DATA *TxData;
227 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
228 BOOLEAN AbortOnClose;
229 } EFI_TCP4_CLOSE_TOKEN;
232 // Interface definition for TCP4 protocol
236 Get the current operational status.
238 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
239 @param Tcp4State The pointer to the buffer to receive the current TCP state.
240 @param Tcp4ConfigData The pointer to the buffer to receive the current TCP configuration.
241 @param Ip4ModeData The pointer to the buffer to receive the current IPv4 configuration
242 data used by the TCPv4 instance.
243 @param MnpConfigData The pointer to the buffer to receive the current MNP configuration
244 data used indirectly by the TCPv4 instance.
245 @param SnpModeData The pointer to the buffer to receive the current SNP configuration
246 data used indirectly by the TCPv4 instance.
248 @retval EFI_SUCCESS The mode data was read.
249 @retval EFI_INVALID_PARAMETER This is NULL.
250 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
256 (EFIAPI *EFI_TCP4_GET_MODE_DATA)(
257 IN EFI_TCP4_PROTOCOL *This,
258 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
259 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
260 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
261 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
262 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
266 Initialize or brutally reset the operational parameters for this EFI TCPv4 instance.
268 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
269 @param Tcp4ConfigData The pointer to the configure data to configure the instance.
271 @retval EFI_SUCCESS The operational settings are set, changed, or reset
273 @retval EFI_INVALID_PARAMETER Some parameter is invalid.
274 @retval EFI_NO_MAPPING When using a default address, configuration (through
275 DHCP, BOOTP, RARP, etc.) is not finished yet.
276 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without
277 calling Configure() with NULL to reset it.
278 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
279 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
281 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
282 executing Configure().
287 (EFIAPI *EFI_TCP4_CONFIGURE)(
288 IN EFI_TCP4_PROTOCOL *This,
289 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
294 Add or delete a route entry to the route table
296 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
297 @param DeleteRoute Set it to TRUE to delete this route from the routing table. Set it to
298 FALSE to add this route to the routing table.
299 DestinationAddress and SubnetMask are used as the
300 keywords to search route entry.
301 @param SubnetAddress The destination network.
302 @param SubnetMask The subnet mask of the destination network.
303 @param GatewayAddress The gateway address for this route. It must be on the same
304 subnet with the station address unless a direct route is specified.
306 @retval EFI_SUCCESS The operation completed successfully.
307 @retval EFI_NOT_STARTED The EFI TCPv4 Protocol instance has not been configured.
308 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
309 RARP, etc.) is not finished yet.
310 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
312 - SubnetAddress is NULL.
313 - SubnetMask is NULL.
314 - GatewayAddress is NULL.
315 - *SubnetAddress is not NULL a valid subnet address.
316 - *SubnetMask is not a valid subnet mask.
317 - *GatewayAddress is not a valid unicast IP address or it
318 is not in the same subnet.
319 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the entry to the
321 @retval EFI_NOT_FOUND This route is not in the routing table.
322 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
323 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
328 (EFIAPI *EFI_TCP4_ROUTES)(
329 IN EFI_TCP4_PROTOCOL *This,
330 IN BOOLEAN DeleteRoute,
331 IN EFI_IPv4_ADDRESS *SubnetAddress,
332 IN EFI_IPv4_ADDRESS *SubnetMask,
333 IN EFI_IPv4_ADDRESS *GatewayAddress
337 Initiate a nonblocking TCP connection request for an active TCP instance.
339 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
340 @param ConnectionToken The pointer to the connection token to return when the TCP three
341 way handshake finishes.
343 @retval EFI_SUCCESS The connection request is successfully initiated and the state
344 of this TCPv4 instance has been changed to Tcp4StateSynSent.
345 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
346 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
347 - This instance is not configured as an active one.
348 - This instance is not in Tcp4StateClosed state.
349 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
351 - ConnectionToken is NULL.
352 - ConnectionToken->CompletionToken.Event is NULL.
353 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the activ eopen.
354 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
359 (EFIAPI *EFI_TCP4_CONNECT)(
360 IN EFI_TCP4_PROTOCOL *This,
361 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
366 Listen on the passive instance to accept an incoming connection request. This is a nonblocking operation.
368 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
369 @param ListenToken The pointer to the listen token to return when operation finishes.
371 @retval EFI_SUCCESS The listen token has been queued successfully.
372 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
373 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
374 - This instance is not a passive instance.
375 - This instance is not in Tcp4StateListen state.
376 - The same listen token has already existed in the listen
377 token queue of this TCP instance.
378 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
380 - ListenToken is NULL.
381 - ListentToken->CompletionToken.Event is NULL.
382 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
383 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
388 (EFIAPI *EFI_TCP4_ACCEPT)(
389 IN EFI_TCP4_PROTOCOL *This,
390 IN EFI_TCP4_LISTEN_TOKEN *ListenToken
394 Queues outgoing data into the transmit queue.
396 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
397 @param Token The pointer to the completion token to queue to the transmit queue.
399 @retval EFI_SUCCESS The data has been queued for transmission.
400 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
401 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
402 RARP, etc.) is not finished yet.
403 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
406 - Token->CompletionToken.Event is NULL.
407 - Token->Packet.TxData is NULL L.
408 - Token->Packet.FragmentCount is zero.
409 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
410 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
411 - A transmit completion token with the same Token->CompletionToken.Event
412 was already in the transmission queue.
413 - The current instance is in Tcp4StateClosed state.
414 - The current instance is a passive one and it is in
415 Tcp4StateListen state.
416 - User has called Close() to disconnect this connection.
417 @retval EFI_NOT_READY The completion token could not be queued because the
418 transmit queue is full.
419 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
421 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
426 (EFIAPI *EFI_TCP4_TRANSMIT)(
427 IN EFI_TCP4_PROTOCOL *This,
428 IN EFI_TCP4_IO_TOKEN *Token
433 Places an asynchronous receive request into the receiving queue.
435 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
436 @param Token The pointer to a token that is associated with the receive data
439 @retval EFI_SUCCESS The receive completion token was cached.
440 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
441 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP,
442 etc.) is not finished yet.
443 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
446 - Token->CompletionToken.Event is NULL.
447 - Token->Packet.RxData is NULL.
448 - Token->Packet.RxData->DataLength is 0.
449 - The Token->Packet.RxData->DataLength is not
450 the sum of all FragmentBuffer length in FragmentTable.
451 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
452 system resources (usually memory).
453 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
454 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
455 - A receive completion token with the same Token-
456 >CompletionToken.Event was already in the receive
458 - The current instance is in Tcp4StateClosed state.
459 - The current instance is a passive one and it is in
460 Tcp4StateListen state.
461 - User has called Close() to disconnect this connection.
462 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is
463 no any buffered data in the receive buffer of this instance.
464 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
469 (EFIAPI *EFI_TCP4_RECEIVE)(
470 IN EFI_TCP4_PROTOCOL *This,
471 IN EFI_TCP4_IO_TOKEN *Token
475 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
476 nonblocking operation.
478 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
479 @param CloseToken The pointer to the close token to return when operation finishes.
481 @retval EFI_SUCCESS The Close() is called successfully.
482 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
483 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
484 - Configure() has been called with
485 TcpConfigData set to NULL and this function has
487 - Previous Close() call on this instance has not
489 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
491 - CloseToken is NULL.
492 - CloseToken->CompletionToken.Event is NULL.
493 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
494 @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
499 (EFIAPI *EFI_TCP4_CLOSE)(
500 IN EFI_TCP4_PROTOCOL *This,
501 IN EFI_TCP4_CLOSE_TOKEN *CloseToken
505 Abort an asynchronous connection, listen, transmission or receive request.
507 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
508 @param Token The pointer to a token that has been issued by
509 EFI_TCP4_PROTOCOL.Connect(),
510 EFI_TCP4_PROTOCOL.Accept(),
511 EFI_TCP4_PROTOCOL.Transmit() or
512 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
513 tokens issued by above four functions will be aborted. Type
514 EFI_TCP4_COMPLETION_TOKEN is defined in
515 EFI_TCP4_PROTOCOL.Connect().
517 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
519 @retval EFI_INVALID_PARAMETER This is NULL.
520 @retval EFI_NOT_STARTED This instance hasn't been configured.
521 @retval EFI_NO_MAPPING When using the default address, configuration
522 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
523 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
524 transmission or receive queue. It has either
525 completed or wasn't issued by Transmit() and Receive().
526 @retval EFI_UNSUPPORTED The implementation does not support this function.
531 (EFIAPI *EFI_TCP4_CANCEL)(
532 IN EFI_TCP4_PROTOCOL *This,
533 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
538 Poll to receive incoming data and transmit outgoing segments.
540 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
542 @retval EFI_SUCCESS Incoming or outgoing data was processed.
543 @retval EFI_INVALID_PARAMETER This is NULL.
544 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
545 @retval EFI_NOT_READY No incoming or outgoing data is processed.
546 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
547 Consider increasing the polling rate.
552 (EFIAPI *EFI_TCP4_POLL)(
553 IN EFI_TCP4_PROTOCOL *This
557 /// The EFI_TCP4_PROTOCOL defines the EFI TCPv4 Protocol child to be used by
558 /// any network drivers or applications to send or receive data stream.
559 /// It can either listen on a specified port as a service or actively connected
560 /// to remote peer as a client. Each instance has its own independent settings,
561 /// such as the routing table.
563 struct _EFI_TCP4_PROTOCOL {
564 EFI_TCP4_GET_MODE_DATA GetModeData;
565 EFI_TCP4_CONFIGURE Configure;
566 EFI_TCP4_ROUTES Routes;
567 EFI_TCP4_CONNECT Connect;
568 EFI_TCP4_ACCEPT Accept;
569 EFI_TCP4_TRANSMIT Transmit;
570 EFI_TCP4_RECEIVE Receive;
571 EFI_TCP4_CLOSE Close;
572 EFI_TCP4_CANCEL Cancel;
576 extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;
577 extern EFI_GUID gEfiTcp4ProtocolGuid;