--- /dev/null
+/** @file\r
+ EFI TCPv4 Protocol Definition\r
+ The EFI TCPv4 Service Binding Protocol is used to locate EFI TCPv4 Protocol drivers to create\r
+ and destroy child of the driver to communicate with other host using TCP protocol. \r
+ The EFI TCPv4 Protocol provides services to send and receive data stream. \r
+\r
+ Copyright (c) 2006, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+ Module Name: Tcp4.h\r
+\r
+**/\r
+\r
+#ifndef __EFI_TCP4_PROTOCOL_H__\r
+#define __EFI_TCP4_PROTOCOL_H__\r
+\r
+#define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
+ { \\r
+ 0x00720665, 0x67EB, 0x4a99, {0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } \\r
+ }\r
+\r
+#define EFI_TCP4_PROTOCOL_GUID \\r
+ { \\r
+ 0x65530BC7, 0xA359, 0x410f, {0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } \\r
+ }\r
+\r
+typedef struct _EFI_TCP4_PROTOCOL EFI_TCP4_PROTOCOL;\r
+\r
+typedef struct {\r
+ EFI_HANDLE InstanceHandle;\r
+ EFI_IPv4_ADDRESS LocalAddress;\r
+ UINT16 LocalPort;\r
+ EFI_IPv4_ADDRESS RemoteAddress;\r
+ UINT16 RemotePort;\r
+} EFI_TCP4_SERVICE_POINT;\r
+\r
+typedef struct {\r
+ EFI_HANDLE DriverHandle;\r
+ UINT32 ServiceCount;\r
+ EFI_TCP4_SERVICE_POINT Services[1];\r
+} EFI_TCP4_VARIABLE_DATA;\r
+\r
+typedef struct {\r
+ BOOLEAN UseDefaultAddress;\r
+ EFI_IPv4_ADDRESS StationAddress;\r
+ EFI_IPv4_ADDRESS SubnetMask;\r
+ UINT16 StationPort;\r
+ EFI_IPv4_ADDRESS RemoteAddress;\r
+ UINT16 RemotePort;\r
+ BOOLEAN ActiveFlag;\r
+} EFI_TCP4_ACCESS_POINT;\r
+\r
+typedef struct {\r
+ UINTN ReceiveBufferSize;\r
+ UINTN SendBufferSize;\r
+ UINTN MaxSynBackLog;\r
+ UINTN ConnectionTimeout;\r
+ UINTN DataRetries;\r
+ UINTN FinTimeout;\r
+ UINTN TimeWaitTimeout;\r
+ UINTN KeepAliveProbes;\r
+ UINTN KeepAliveTime;\r
+ UINTN KeepAliveInterval;\r
+ BOOLEAN EnableNagle;\r
+ BOOLEAN EnableTimeStamp;\r
+ BOOLEAN EnableWindowScaling;\r
+ BOOLEAN EnableSelectiveAck;\r
+ BOOLEAN EnablePathMtuDiscovery;\r
+} EFI_TCP4_OPTION;\r
+\r
+typedef struct {\r
+ //\r
+ // I/O parameters\r
+ //\r
+ UINT8 TypeOfService;\r
+ UINT8 TimeToLive;\r
+\r
+ //\r
+ // Access Point\r
+ //\r
+ EFI_TCP4_ACCESS_POINT AccessPoint;\r
+ \r
+ // \r
+ // TCP Control Options \r
+ // \r
+ EFI_TCP4_OPTION *ControlOption;\r
+} EFI_TCP4_CONFIG_DATA;\r
+\r
+typedef enum {\r
+ Tcp4StateClosed = 0,\r
+ Tcp4StateListen = 1,\r
+ Tcp4StateSynSent = 2,\r
+ Tcp4StateSynReceived = 3,\r
+ Tcp4StateEstablished = 4,\r
+ Tcp4StateFinWait1 = 5,\r
+ Tcp4StateFinWait2 = 6,\r
+ Tcp4StateClosing = 7,\r
+ Tcp4StateTimeWait = 8,\r
+ Tcp4StateCloseWait = 9,\r
+ Tcp4StateLastAck = 10\r
+} EFI_TCP4_CONNECTION_STATE;\r
+\r
+typedef struct {\r
+ EFI_EVENT Event;\r
+ EFI_STATUS Status;\r
+} EFI_TCP4_COMPLETION_TOKEN;\r
+\r
+typedef struct {\r
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+} EFI_TCP4_CONNECTION_TOKEN;\r
+\r
+typedef struct {\r
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+ EFI_HANDLE NewChildHandle;\r
+} EFI_TCP4_LISTEN_TOKEN;\r
+\r
+typedef struct {\r
+ UINTN FragmentLength;\r
+ VOID *FragmentBuffer;\r
+} EFI_TCP4_FRAGMENT_DATA;\r
+\r
+typedef struct {\r
+ BOOLEAN UrgentFlag;\r
+ IN OUT UINTN DataLength;\r
+ UINTN FragmentCount;\r
+ EFI_TCP4_FRAGMENT_DATA FragmentTable[1];\r
+} EFI_TCP4_RECEIVE_DATA; \r
+\r
+typedef struct { \r
+ BOOLEAN Push;\r
+ BOOLEAN Urgent;\r
+ UINTN DataLength;\r
+ UINTN FragmentCount;\r
+ EFI_TCP4_FRAGMENT_DATA FragmentTable[1];\r
+} EFI_TCP4_TRANSMIT_DATA;\r
+\r
+typedef struct {\r
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+ union {\r
+ EFI_TCP4_RECEIVE_DATA *RxData;\r
+ EFI_TCP4_TRANSMIT_DATA *TxData;\r
+ } Packet;\r
+} EFI_TCP4_IO_TOKEN;\r
+\r
+typedef struct {\r
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+ BOOLEAN AbortOnClose;\r
+} EFI_TCP4_CLOSE_TOKEN;\r
+\r
+//\r
+// Interface definition for TCP4 protocol\r
+//\r
+\r
+/**\r
+ Get the current operational status.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Tcp4State Pointer to the buffer to receive the current TCP state.\r
+ @param Tcp4ConfigData Pointer to the buffer to receive the current TCP configuration.\r
+ @param Ip4ModeData Pointer to the buffer to receive the current IPv4 configuration\r
+ data used by the TCPv4 instance.\r
+ @param MnpConfigData Pointer to the buffer to receive the current MNP configuration\r
+ data used indirectly by the TCPv4 instance.\r
+ @param SnpModeData Pointer to the buffer to receive the current SNP configuration\r
+ data used indirectly by the TCPv4 instance.\r
+\r
+ @retval EFI_SUCCESS The mode data was read.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't\r
+ been started.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_GET_MODE_DATA) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,\r
+ OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,\r
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
+ )\r
+;\r
+ \r
+/**\r
+ Initialize or brutally reset the operational parameters for this EFI TCPv4 instance.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Tcp4ConfigData Pointer to the configure data to configure the instance.\r
+\r
+ @retval EFI_SUCCESS The operational settings are set, changed, or reset\r
+ successfully.\r
+ @retval EFI_INVALID_PARAMETER Some parameter is invalid.\r
+ @retval EFI_NO_MAPPING When using a default address, configuration (through\r
+ DHCP, BOOTP, RARP, etc.) is not finished yet.\r
+ @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without\r
+ calling Configure() with NULL to reset it.\r
+ @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
+ @retval EFI_UNSUPPORTED One or more of the control options are not supported in\r
+ the implementation.\r
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
+ executing Configure().\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CONFIGURE) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL\r
+ )\r
+;\r
+ \r
+\r
+/**\r
+ Add or delete a route entry to the route table\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param DeleteRoute Set it to TRUE to delete this route from the routing table. Set it to\r
+ FALSE to add this route to the routing table.\r
+ DestinationAddress and SubnetMask are used as the\r
+ keywords to search route entry.\r
+ @param SubnetAddress The destination network.\r
+ @param SubnetMask The subnet mask of the destination network.\r
+ @param GatewayAddress The gateway address for this route. It must be on the same\r
+ subnet with the station address unless a direct route is specified.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_NOT_STARTED The EFI TCPv4 Protocol instance has not been configured.\r
+ @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
+ RARP, etc.) is not finished yet.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - SubnetAddress is NULL.\r
+ - SubnetMask is NULL.\r
+ - GatewayAddress is NULL.\r
+ - *SubnetAddress is not NULL a valid subnet address.\r
+ - *SubnetMask is not a valid subnet mask.\r
+ - *GatewayAddress is not a valid unicast IP address or it\r
+ is not in the same subnet.\r
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the entry to the\r
+ routing table.\r
+ @retval EFI_NOT_FOUND This route is not in the routing table.\r
+ @retval EFI_ACCESS_DENIED The route is already defined in the routing table.\r
+ @retval EFI_UNSUPPORTED The TCP driver does not support this operation.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_ROUTES) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN BOOLEAN DeleteRoute,\r
+ IN EFI_IPv4_ADDRESS *SubnetAddress,\r
+ IN EFI_IPv4_ADDRESS *SubnetMask,\r
+ IN EFI_IPv4_ADDRESS *GatewayAddress\r
+ )\r
+; \r
+\r
+/**\r
+ Initiate a nonblocking TCP connection request for an active TCP instance.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param ConnectionToken Pointer to the connection token to return when the TCP three\r
+ way handshake finishes.\r
+ \r
+ @retval EFI_SUCCESS The connection request is successfully initiated and the state\r
+ - of this TCPv4 instance has been changed to\r
+ - Tcp4StateSynSent.\r
+ @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
+ @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:\r
+ - This instance is not configured as an active one.\r
+ - This instance is not in Tcp4StateClosed state.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
+ - This is NULL.\r
+ - ConnectionToken is NULL.\r
+ - ConnectionToken->CompletionToken.Event is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the activeopen.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CONNECT) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken\r
+ )\r
+; \r
+ \r
+\r
+/**\r
+ Listen on the passive instance to accept an incoming connection request. This is a nonblocking operation.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param ListenToken Pointer to the listen token to return when operation finishes.\r
+\r
+ @retval EFI_SUCCESS The listen token has been queued successfully.\r
+ @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
+ @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r
+ - This instance is not a passive instance.\r
+ - This instance is not in Tcp4StateListen state.\r
+ - The same listen token has already existed in the listen\r
+ token queue of this TCP instance.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
+ - This is NULL.\r
+ - ListenToken is NULL.\r
+ - ListentToken->CompletionToken.Event is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r
+ @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_ACCEPT) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_LISTEN_TOKEN *ListenToken\r
+ )\r
+; \r
+\r
+/**\r
+ Queues outgoing data into the transmit queue.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Token Pointer to the completion token to queue to the transmit queue.\r
+\r
+ @retval EFI_SUCCESS The data has been queued for transmission.\r
+ @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
+ @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
+ RARP, etc.) is not finished yet.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
+ - This is NULL.\r
+ - Token is NULL.\r
+ - Token->CompletionToken.Event is NULL.\r
+ - Token->Packet.TxData is NULL L.\r
+ - Token->Packet.FragmentCount is zero.\r
+ - Token->Packet.DataLength is not equal to the sum of fragment lengths.\r
+ @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
+ - A transmit completion token with the same Token->CompletionToken.Event\r
+ was already in the transmission queue.\r
+ - The current instance is in Tcp4StateClosed state.\r
+ - The current instance is a passive one and it is in\r
+ Tcp4StateListen state.\r
+ - User has called Close() to disconnect this connection.\r
+ @retval EFI_NOT_READY The completion token could not be queued because the\r
+ transmit queue is full.\r
+ @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource\r
+ shortage.\r
+ @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_TRANSMIT) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_IO_TOKEN *Token\r
+ )\r
+; \r
+\r
+\r
+/**\r
+ Places an asynchronous receive request into the receiving queue.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Token Pointer to a token that is associated with the receive data\r
+ descriptor.\r
+\r
+ @retval EFI_SUCCESS The receive completion token was cached.\r
+ @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
+ @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP,\r
+ etc.) is not finished yet.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - Token is NULL.\r
+ - Token->CompletionToken.Event is NULL.\r
+ - Token->Packet.RxData is NULL.\r
+ - Token->Packet.RxData->DataLength is 0.\r
+ - The Token->Packet.RxData->DataLength is not\r
+ the sum of all FragmentBuffer length in FragmentTable.\r
+ @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of\r
+ system resources (usually memory).\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r
+ - A receive completion token with the same Token-\r
+ >CompletionToken.Event was already in the receive\r
+ queue.\r
+ - The current instance is in Tcp4StateClosed state.\r
+ - The current instance is a passive one and it is in\r
+ Tcp4StateListen state.\r
+ - User has called Close() to disconnect this connection.\r
+ @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is\r
+ no any buffered data in the receive buffer of this instance.\r
+ @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_RECEIVE) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_IO_TOKEN *Token\r
+ )\r
+; \r
+ \r
+/**\r
+ Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a\r
+ nonblocking operation. \r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param CloseToken Pointer to the close token to return when operation finishes.\r
+\r
+ @retval EFI_SUCCESS The Close() is called successfully.\r
+ @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.\r
+ @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r
+ - Configure() has been called with\r
+ TcpConfigData set to NULL and this function has\r
+ not returned.\r
+ - Previous Close() call on this instance has not\r
+ finished.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
+ - This is NULL.\r
+ - CloseToken is NULL.\r
+ - CloseToken->CompletionToken.Event is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r
+ @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CLOSE) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_CLOSE_TOKEN *CloseToken\r
+ )\r
+; \r
+\r
+/**\r
+ Abort an asynchronous connection, listen, transmission or receive request.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+ @param Token Pointer to a token that has been issued by\r
+ EFI_TCP4_PROTOCOL.Connect(),\r
+ EFI_TCP4_PROTOCOL.Accept(),\r
+ EFI_TCP4_PROTOCOL.Transmit() or\r
+ EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r
+ tokens issued by above four functions will be aborted. Type\r
+ EFI_TCP4_COMPLETION_TOKEN is defined in\r
+ EFI_TCP4_PROTOCOL.Connect().\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
+ @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.\r
+ Consider increasing the polling rate.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CANCEL) (\r
+ IN EFI_TCP4_PROTOCOL *This,\r
+ IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r
+ )\r
+; \r
+\r
+\r
+/**\r
+ Poll to receive incoming data and transmit outgoing segments.\r
+\r
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
+ @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.\r
+ Consider increasing the polling rate.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_POLL) (\r
+ IN EFI_TCP4_PROTOCOL *This\r
+ )\r
+; \r
+\r
+struct _EFI_TCP4_PROTOCOL {\r
+ EFI_TCP4_GET_MODE_DATA GetModeData;\r
+ EFI_TCP4_CONFIGURE Configure;\r
+ EFI_TCP4_ROUTES Routes;\r
+ EFI_TCP4_CONNECT Connect;\r
+ EFI_TCP4_ACCEPT Accept;\r
+ EFI_TCP4_TRANSMIT Transmit;\r
+ EFI_TCP4_RECEIVE Receive;\r
+ EFI_TCP4_CLOSE Close;\r
+ EFI_TCP4_CANCEL Cancel;\r
+ EFI_TCP4_POLL Poll;\r
+};\r
+\r
+#define EFI_CONNECTION_FIN EFIERR (104)\r
+#define EFI_CONNECTION_RESET EFIERR (105)\r
+#define EFI_CONNECTION_REFUSED EFIERR (106)\r
+\r
+extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiTcp4ProtocolGuid;\r
+\r
+#endif\r