From bdb140d76b384c8492b609ba766d148ccb3572c1 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Mon, 17 Aug 2009 09:22:26 +0000 Subject: [PATCH] 1. import Ip6.h, Ip6Config.h and Tcp6.h. 2. refine comments in Ip4.h and Tcp4.h. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9081 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Protocol/Ip4.h | 18 +- MdePkg/Include/Protocol/Ip6.h | 912 ++++++++++++++++++++++++++++ MdePkg/Include/Protocol/Ip6Config.h | 369 +++++++++++ MdePkg/Include/Protocol/Tcp4.h | 24 +- MdePkg/Include/Protocol/Tcp6.h | 853 ++++++++++++++++++++++++++ 5 files changed, 2156 insertions(+), 20 deletions(-) create mode 100644 MdePkg/Include/Protocol/Ip6.h create mode 100644 MdePkg/Include/Protocol/Ip6Config.h create mode 100644 MdePkg/Include/Protocol/Tcp6.h diff --git a/MdePkg/Include/Protocol/Ip4.h b/MdePkg/Include/Protocol/Ip4.h index beb114a6e5..dbc9ad6b1e 100644 --- a/MdePkg/Include/Protocol/Ip4.h +++ b/MdePkg/Include/Protocol/Ip4.h @@ -5,11 +5,11 @@ sections: - EFI IPv4 Service Binding Protocol - EFI IPv4 Variable - - EFI IPv4 Protocol The EFI IPv4 Protocol provides basic - network IPv4 packet I/O services, which includes support for - a subset of the Internet Control Message Protocol (ICMP) and - may include support for the Internet Group Management - Protocol (IGMP). + - EFI IPv4 Protocol + The EFI IPv4 Protocol provides basic network IPv4 packet I/O services, + which includes support foR a subset of the Internet Control Message + Protocol (ICMP) and may include support for the Internet Group Management + Protocol (IGMP). Copyright (c) 2006 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials @@ -353,7 +353,7 @@ EFI_STATUS - This is NULL. - JoinFlag is TRUE and GroupAddress is NULL. - GroupAddress is not NULL and *GroupAddress is - not a multicast IPv4 address. + not a multicast IPv4 address. @retval EFI_NOT_STARTED This instance has not been started. @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.) is not finished yet. @@ -420,7 +420,7 @@ EFI_STATUS @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table. @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE). @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when - DeleteRoute is FALSE). + DeleteRoute is FALSE). **/ typedef @@ -495,7 +495,7 @@ EFI_STATUS resources (usually memory). @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4 Protocol instance has been reset to startup defaults. - EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already + @retval EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already in the receive queue. @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full. @retval EFI_ICMP_ERROR An ICMP error packet was received. @@ -526,7 +526,7 @@ EFI_STATUS defined in EFI_IP4_PROTOCOL.Transmit(). @retval EFI_SUCCESS The asynchronous I/O request was aborted and - Token.->Event was signaled. When Token is NULL, all + Token->Event was signaled. When Token is NULL, all pending requests were aborted and their events were signaled. @retval EFI_INVALID_PARAMETER This is NULL. @retval EFI_NOT_STARTED This instance has not been started. diff --git a/MdePkg/Include/Protocol/Ip6.h b/MdePkg/Include/Protocol/Ip6.h new file mode 100644 index 0000000000..0857fca111 --- /dev/null +++ b/MdePkg/Include/Protocol/Ip6.h @@ -0,0 +1,912 @@ +/** @file + + This file defines the EFI IPv6 (Internet Protocol version 6) + Protocol interface. It is split into the following three main + sections: + - EFI IPv6 Service Binding Protocol + - EFI IPv6 Variable + - EFI IPv6 Protocol + The EFI IPv6 Protocol provides basic network IPv6 packet I/O services, + which includes support for Neighbor Discovery Protocol (ND), Multicast + Listener Discovery Protocol (MLD), and a subset of the Internet Control + Message Protocol (ICMPv6). + + Copyright (c) 2008 - 2009, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EFI_IP6_PROTOCOL_H__ +#define __EFI_IP6_PROTOCOL_H__ + +#include + + +#define EFI_IP6_SERVICE_BINDING_PROTOCOL_GUID \ + { \ + 0xec835dd3, 0xfe0f, 0x617b, {0xa6, 0x21, 0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88 } \ + } + +#define EFI_IP6_PROTOCOL_GUID \ + { \ + 0x2c8759d5, 0x5c2d, 0x66ef, {0x92, 0x5f, 0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2 } \ + } + +typedef struct _EFI_IP6_PROTOCOL EFI_IP6_PROTOCOL; + +/// +/// ICMPv6 type definitions for error messages +/// +///@{ +#define ICMP_V6_DEST_UNREACHABLE 0x1 +#define ICMP_V6_PACKET_TOO_BIG 0x2 +#define ICMP_V6_TIME_EXCEEDED 0x3 +#define ICMP_V6_PARAMETER_PROBLEM 0x4 +///@} + +/// +/// ICMPv6 type definition for informational messages +/// +///@{ +#define ICMP_V6_ECHO_REQUEST 0x80 +#define ICMP_V6_ECHO_REPLY 0x81 +#define ICMP_V6_LISTENER_QUERY 0x82 +#define ICMP_V6_LISTENER_REPORT 0x83 +#define ICMP_V6_LISTENER_DONE 0x84 +#define ICMP_V6_ROUTER_SOLICIT 0x85 +#define ICMP_V6_ROUTER_ADVERTISE 0x86 +#define ICMP_V6_NEIGHBOR_SOLICIT 0x87 +#define ICMP_V6_NEIGHBOR_ADVERTISE 0x88 +#define ICMP_V6_REDIRECT 0x89 +#define ICMP_V6_LISTENER_REPORT_2 0x8F +///@} + +/// +/// ICMPv6 code definitions for ICMP_V6_DEST_UNREACHABLE +/// +///@{ +#define ICMP_V6_NO_ROUTE_TO_DEST 0x0 +#define ICMP_V6_COMM_PROHIBITED 0x1 +#define ICMP_V6_BEYOND_SCOPE 0x2 +#define ICMP_V6_ADDR_UNREACHABLE 0x3 +#define ICMP_V6_PORT_UNREACHABLE 0x4 +#define ICMP_V6_SOURCE_ADDR_FAILED 0x5 +#define ICMP_V6_ROUTE_REJECTED 0x6 +///@} + +/// +/// ICMPv6 code definitions for ICMP_V6_TIME_EXCEEDED +/// +///@{ +#define ICMP_V6_TIMEOUT_HOP_LIMIT 0x0 +#define ICMP_V6_TIMEOUT_REASSEMBLE 0x1 +///@} + +/// +/// ICMPv6 code definitions for ICMP_V6_PARAMETER_PROBLEM +/// +///@{ +#define ICMP_V6_ERRONEOUS_HEADER 0x0 +#define ICMP_V6_UNRECOGNIZE_NEXT_HDR 0x1 +#define ICMP_V6_UNRECOGNIZE_OPTION 0x2 +///@} + +/// +/// EFI_IP6_CONFIG_DATA +/// is used to report and change IPv6 session parameters. +/// +typedef struct { + /// + /// For the IPv6 packet to send and receive, this is the default value + /// of the 'Next Header' field in the last IPv6 extension header or in + /// the IPv6 header if there are no extension headers. Ignored when + /// AcceptPromiscuous is TRUE. + /// + UINT8 DefaultProtocol; + /// + /// Set to TRUE to receive all IPv6 packets that get through the + /// receive filters. + /// Set to FALSE to receive only the DefaultProtocol IPv6 + /// packets that get through the receive filters. Ignored when + /// AcceptPromiscuous is TRUE. + /// + BOOLEAN AcceptAnyProtocol; + /// + /// Set to TRUE to receive ICMP error report packets. Ignored when + /// AcceptPromiscuous or AcceptAnyProtocol is TRUE. + /// + BOOLEAN AcceptIcmpErrors; + /// + /// Set to TRUE to receive all IPv6 packets that are sent to any + /// hardware address or any protocol address. Set to FALSE to stop + /// receiving all promiscuous IPv6 packets. + /// + BOOLEAN AcceptPromiscuous; + /// + /// The destination address of the packets that will be transmitted. + /// Ignored if it is unspecified. + /// + EFI_IPv6_ADDRESS DestinationAddress; + /// + /// The station IPv6 address that will be assigned to this EFI IPv6 + /// Protocol instance. This field can be set and changed only when + /// the EFI IPv6 driver is transitioning from the stopped to the started + /// states. If the StationAddress is specified, the EFI IPv6 Protocol + /// driver will deliver only incoming IPv6 packets whose destination + /// matches this IPv6 address exactly. The StationAddress is required + /// to be one of currently configured IPv6 addresses. An address + /// containing all zeroes is also accepted as a special case. Under this + /// situation, the IPv6 driver is responsible for binding a source + /// address to this EFI IPv6 protocol instance according to the source + /// address selection algorithm. Only incoming packets destined to + /// the selected address will be delivered to the user. And the + /// selected station address can be retrieved through later + /// GetModeData() call. If no address is available for selecting, + /// EFI_NO_MAPPING will be returned, and the station address will + /// only be successfully bound to this EFI IPv6 protocol instance + /// after IP6ModeData.IsConfigured changed to TRUE. + /// + EFI_IPv6_ADDRESS StationAddress; + /// + /// TrafficClass field in transmitted IPv6 packets. Default value + /// is zero. + /// + UINT8 TrafficClass; + /// + /// HopLimit field in transmitted IPv6 packets. + /// + UINT8 HopLimit; + /// + /// FlowLabel field in transmitted IPv6 packets. Default value is + /// zero. + /// + UINT32 FlowLabel; + /// + /// The timer timeout value (number of microseconds) for the + /// receive timeout event to be associated with each assembled + /// packet. Zero means do not drop assembled packets. + /// + UINT32 ReceiveTimeout; + /// + /// The timer timeout value (number of microseconds) for the + /// transmit timeout event to be associated with each outgoing + /// packet. Zero means do not drop outgoing packets. + /// + UINT32 TransmitTimeout; +} EFI_IP6_CONFIG_DATA; + +/// +/// EFI_IP6_ADDRESS_INFO +/// +typedef struct { + EFI_IPv6_ADDRESS Address; ///< The IPv6 address. + UINT8 PrefixLength; ///< The length of the prefix associated with the Address. +} EFI_IP6_ADDRESS_INFO; + +/// +/// EFI_IP6_ROUTE_TABLE +/// is the entry structure that is used in routing tables +/// +typedef struct { + /// + /// The IPv6 address of the gateway to be used as the next hop for + /// packets to this prefix. If the IPv6 address is all zeros, then the + /// prefix is on-link. + /// + EFI_IPv6_ADDRESS Gateway; + /// + /// The destination prefix to be routed. + /// + EFI_IPv6_ADDRESS Destination; + /// + /// The length of the prefix associated with the Destination. + /// + UINT8 PrefixLength; +} EFI_IP6_ROUTE_TABLE; + +/// +/// EFI_IP6_NEIGHBOR_STATE +/// +typedef enum { + /// + /// Address resolution is being performed on this entry. Specially, + /// Neighbor Solicitation has been sent to the solicited-node + /// multicast address of the target, but corresponding Neighbor + /// Advertisement has not been received. + /// + EfiNeighborInComplete, + /// + /// Positive confirmation was received that the forward path to the + /// neighbor was functioning properly. + /// + EfiNeighborReachable, + /// + ///Reachable Time has elapsed since the last positive confirmation + ///was received. In this state, the forward path to the neighbor was + ///functioning properly. + /// + EfiNeighborStale, + /// + /// This state is an optimization that gives upper-layer protocols + /// additional time to provide reachability confirmation. + /// + EfiNeighborDelay, + /// + /// A reachability confirmation is actively sought by retransmitting + /// Neighbor Solicitations every RetransTimer milliseconds until a + /// reachability confirmation is received. + /// + EfiNeighborProbe +} EFI_IP6_NEIGHBOR_STATE; + +/// +/// EFI_IP6_NEIGHBOR_CACHE +/// is the entry structure that is used in neighbor cache. It records a set +/// of entries about individual neighbors to which traffic has been sent recently. +/// +typedef struct { + EFI_IPv6_ADDRESS Neighbor; ///< The on-link unicast/anycast IP address of the neighbor. + EFI_MAC_ADDRESS LinkAddress; ///< Link-layer address of the neighbor. + EFI_IP6_NEIGHBOR_STATE State; ///< State of this neighbor cache entry. +} EFI_IP6_NEIGHBOR_CACHE; + +/// +/// EFI_IP6_ICMP_TYPE +/// is used to describe those ICMP messages that are supported by this EFI +/// IPv6 Protocol driver. +/// +typedef struct { + UINT8 Type; ///< The type of ICMP message. + UINT8 Code; ///< The code of the ICMP message. +} EFI_IP6_ICMP_TYPE; + +/// +/// EFI_IP6_MODE_DATA +/// +typedef struct { + /// + /// Set to TRUE after this EFI IPv6 Protocol instance is started. + /// All other fields in this structure are undefined until this field is TRUE. + /// Set to FALSE when the EFI IPv6 Protocol instance is stopped. + /// + BOOLEAN IsStarted; + /// + /// The maximum packet size, in bytes, of the packet which the upper layer driver could feed. + /// + UINT32 MaxPacketSize; + /// + /// Current configuration settings. Undefined until IsStarted is TRUE. + /// + EFI_IP6_CONFIG_DATA ConfigData; + /// + /// Set to TRUE when the EFI IPv6 Protocol instance is configured. + /// The instance is configured when it has a station address and + /// corresponding prefix length. + /// Set to FALSE when the EFI IPv6 Protocol instance is not configured. + /// + BOOLEAN IsConfigured; + /// + /// Number of configured IPv6 addresses on this interface. + /// + UINT32 AddressCount; + /// + /// List of currently configured IPv6 addresses and corresponding + /// prefix lengths assigned to this interface. It is caller's + /// responsibility to free this buffer. + /// + EFI_IP6_ADDRESS_INFO *AddressList; + /// + /// Number of joined multicast groups. Undefined until + /// IsConfigured is TRUE. + /// + UINT32 GroupCount; + /// + /// List of joined multicast group addresses. It is caller's + /// responsibility to free this buffer. Undefined until + /// IsConfigured is TRUE. + /// + EFI_IPv6_ADDRESS *GroupTable; + /// + /// Number of entries in the routing table. Undefined until + /// IsConfigured is TRUE. + /// + UINT32 RouteCount; + /// + /// Routing table entries. It is caller's responsibility to free this buffer. + /// + EFI_IP6_ROUTE_TABLE *RouteTable; + /// + /// Number of entries in the neighbor cache. Undefined until + /// IsConfigured is TRUE. + /// + UINT32 NeighborCount; + /// + /// Neighbor cache entries. It is caller's responsibility to free this + /// buffer. Undefined until IsConfigured is TRUE. + /// + EFI_IP6_NEIGHBOR_CACHE *NeighborCache; + /// + /// Number of entries in the prefix table. Undefined until + /// IsConfigured is TRUE. + /// + UINT32 PrefixCount; + /// + /// On-link Prefix table entries. It is caller's responsibility to free this + /// buffer. Undefined until IsConfigured is TRUE. + /// + EFI_IP6_ADDRESS_INFO *PrefixTable; + /// + /// Number of entries in the supported ICMP types list. + /// + UINT32 IcmpTypeCount; + /// + /// Array of ICMP types and codes that are supported by this EFI + /// IPv6 Protocol driver. It is caller's responsibility to free this + /// buffer. + /// + EFI_IP6_ICMP_TYPE *IcmpTypeList; +} EFI_IP6_MODE_DATA; + +/// +/// EFI_IP6_HEADER +/// The fields in the IPv6 header structure are defined in the Internet +/// Protocol version6 specification. +/// +#pragma pack(1) +typedef struct _EFI_IP6_HEADER { + UINT8 TrafficClassH:4; + UINT8 Version:4; + UINT8 FlowLabelH:4; + UINT8 TrafficClassL:4; + UINT16 FlowLabelL; + UINT16 PayloadLength; + UINT8 NextHeader; + UINT8 HopLimit; + EFI_IPv6_ADDRESS SourceAddress; + EFI_IPv6_ADDRESS DestinationAddress; +} EFI_IP6_HEADER; +#pragma pack + +/// +/// EFI_IP6_FRAGMENT_DATA +/// describes the location and length of the IPv6 packet +/// fragment to transmit or that has been received. +/// +typedef struct _EFI_IP6_FRAGMENT_DATA { + UINT32 FragmentLength; ///< Length of fragment data. This field may not be set to zero. + VOID *FragmentBuffer; ///< Pointer to fragment data. This field may not be set to NULL. +} EFI_IP6_FRAGMENT_DATA; + +/// +/// EFI_IP6_RECEIVE_DATA +/// +typedef struct _EFI_IP6_RECEIVE_DATA { + /// + /// Time when the EFI IPv6 Protocol driver accepted the packet. + /// Ignored if it is zero. + /// + EFI_TIME TimeStamp; + /// + /// After this event is signaled, the receive data structure is released + /// and must not be referenced. + /// + EFI_EVENT RecycleSignal; + /// + ///Length of the IPv6 packet headers, including both the IPv6 + ///header and any extension headers. + /// + UINT32 HeaderLength; + /// + /// Pointer to the IPv6 packet header. If the IPv6 packet was + /// fragmented, this argument is a pointer to the header in the first + /// fragment. + /// + EFI_IP6_HEADER *Header; + /// + /// Sum of the lengths of IPv6 packet buffers in FragmentTable. May + /// be zero. + /// + UINT32 DataLength; + /// + /// Number of IPv6 payload fragments. May be zero. + /// + UINT32 FragmentCount; + /// + /// Array of payload fragment lengths and buffer pointers. + /// + EFI_IP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP6_RECEIVE_DATA; + +/// +/// EFI_IP6_OVERRIDE_DATA +/// The information and flags in the override data structure will override +/// default parameters or settings for one Transmit() function call. +/// +typedef struct _EFI_IP6_OVERRIDE_DATA { + UINT8 Protocol; ///< Protocol type override. + UINT8 HopLimit; ///< Hop-Limit override. + UINT32 FlowLabel; ///< Flow-Label override. +} EFI_IP6_OVERRIDE_DATA; + +/// +/// EFI_IP6_TRANSMIT_DATA +/// +typedef struct _EFI_IP6_TRANSMIT_DATA { + /// + /// The destination IPv6 address. If it is unspecified, + /// ConfigData.DestinationAddress will be used instead. + /// + EFI_IPv6_ADDRESS DestinationAddress; + /// + /// If not NULL, the IPv6 transmission control override data. + /// + EFI_IP6_OVERRIDE_DATA *OverrideData; + /// + /// Total length in byte of the IPv6 extension headers specified in + /// ExtHdrs. + /// + UINT32 ExtHdrsLength; + /// + /// Pointer to the IPv6 extension headers. The IP layer will append + /// the required extension headers if they are not specified by + /// ExtHdrs. Ignored if ExtHdrsLength is zero. + /// + VOID *ExtHdrs; + /// + /// The protocol of first extension header in ExtHdrs. Ignored if + /// ExtHdrsLength is zero. + /// + UINT8 NextHeader; + /// + /// Total length in bytes of the FragmentTable data to transmit. + /// + UINT32 DataLength; + /// + /// Number of entries in the fragment data table. + /// + UINT32 FragmentCount; + /// + /// Start of the fragment data table. + /// + EFI_IP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP6_TRANSMIT_DATA; + +/// +/// EFI_IP6_COMPLETION_TOKEN +/// structures are used for both transmit and receive operations. +/// +typedef struct { + /// + /// This Event will be signaled after the Status field is updated by + /// the EFI IPv6 Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. + /// + EFI_EVENT Event; + /// + /// Will be set to one of the following values: + /// - EFI_SUCCESS: The receive or transmit completed + /// successfully. + /// - EFI_ABORTED: The receive or transmit was aborted + /// - EFI_TIMEOUT: The transmit timeout expired. + /// - EFI_ICMP_ERROR: An ICMP error packet was received. + /// - EFI_DEVICE_ERROR: An unexpected system or network + /// error occurred. + /// - EFI_SECURITY_VIOLATION: The transmit or receive was + /// failed because of an IPsec policy check. + /// + EFI_STATUS Status; + union { + /// + /// When the Token is used for receiving, RxData is a pointer to the EFI_IP6_RECEIVE_DATA. + /// + EFI_IP6_RECEIVE_DATA *RxData; + /// + /// When the Token is used for transmitting, TxData is a pointer to the EFI_IP6_TRANSMIT_DATA. + /// + EFI_IP6_TRANSMIT_DATA *TxData; + } Packet; +} EFI_IP6_COMPLETION_TOKEN; + +/** + Gets the current operational settings for this instance of the EFI IPv6 Protocol driver. + + The GetModeData() function returns the current operational mode data for this driver instance. + The data fields in EFI_IP6_MODE_DATA are read only. This function is used optionally to + retrieve the operational mode data of underlying networks or drivers.. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[out] Ip6ModeData Pointer to the EFI IPv6 Protocol mode data structure. + @param[out] MnpConfigData Pointer to the managed network configuration data structure. + @param[out] SnpModeData Pointer to the simple network mode data structure. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_GET_MODE_DATA) ( + IN EFI_IP6_PROTOCOL *This, + OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +/** + Assigns an IPv6 address and subnet mask to this EFI IPv6 Protocol driver instance. + + The Configure() function is used to set, change, or reset the operational parameters and filter + settings for this EFI IPv6 Protocol instance. Until these parameters have been set, no network traffic + can be sent or received by this instance. Once the parameters have been reset (by calling this + function with Ip6ConfigData set to NULL), no more traffic can be sent or received until these + parameters have been set again. Each EFI IPv6 Protocol instance can be started and stopped + independently of each other by enabling or disabling their receive filter settings with the + Configure() function. + + If Ip6ConfigData.StationAddress is a valid non-zero IPv6 unicast address, it is required + to be one of the currently configured IPv6 addresses list in the EFI IPv6 drivers, or else + EFI_INVALID_PARAMETER will be returned. If Ip6ConfigData.StationAddress is + unspecified, the IPv6 driver will bind a source address according to the source address selection + algorithm. Clients could frequently call GetModeData() to check get currently configured IPv6 + address list in the EFI IPv6 driver. If both Ip6ConfigData.StationAddress and + Ip6ConfigData.Destination are unspecified, when transmitting the packet afterwards, the + source address filled in each outgoing IPv6 packet is decided based on the destination of this packet. . + + If operational parameters are reset or changed, any pending transmit and receive requests will be + cancelled. Their completion token status will be set to EFI_ABORTED and their events will be + signaled. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[in] Ip6ConfigData Pointer to the EFI IPv6 Protocol configuration data structure. + + @retval EFI_SUCCESS The driver instance was successfully opened. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + - This is NULL. + - Ip6ConfigData.StationAddress is neither zero nor + a unicast IPv6 address. + - Ip6ConfigData.StationAddress is neither zero nor + one of the configured IP addresses in the EFI IPv6 driver. + - Ip6ConfigData.DefaultProtocol is illegal. + @retval EFI_OUT_OF_RESOURCES The EFI IPv6 Protocol driver instance data could not be allocated. + @retval EFI_NO_MAPPING The IPv6 driver was responsible for choosing a source address for + this instance, but no source address was available for use. + @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the IPv6 + address or prefix length can be changed. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv6 + Protocol driver instance is not opened. + @retval EFI_UNSUPPORTED Default protocol specified through + Ip6ConfigData.DefaulProtocol isn't supported. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIGURE) ( + IN EFI_IP6_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL + ); + +/** + Joins and leaves multicast groups. + + The Groups() function is used to join and leave multicast group sessions. Joining a group will + enable reception of matching multicast packets. Leaving a group will disable reception of matching + multicast packets. Source-Specific Multicast isn't required to be supported. + + If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[in] JoinFlag Set to TRUE to join the multicast group session and FALSE to leave. + @param[in] GroupAddress Pointer to the IPv6 multicast address. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_INVALID_PARAMETER One or more of the following is TRUE: + - This is NULL. + - JoinFlag is TRUE and GroupAddress is NULL. + - GroupAddress is not NULL and *GroupAddress is + not a multicast IPv6 address. + - GroupAddress is not NULL and *GroupAddress is in the + range of SSM destination address. + @retval EFI_NOT_STARTED This instance has not been started. + @retval EFI_OUT_OF_RESOURCES System resources could not be allocated. + @retval EFI_UNSUPPORTED This EFI IPv6 Protocol implementation does not support multicast groups. + @retval EFI_ALREADY_STARTED The group address is already in the group table (when + JoinFlag is TRUE). + @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE). + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_GROUPS) ( + IN EFI_IP6_PROTOCOL *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL + ); + +/** + Adds and deletes routing table entries. + + The Routes() function adds a route to or deletes a route from the routing table. + + Routes are determined by comparing the leftmost PrefixLength bits of Destination with + the destination IPv6 address arithmetically. The gateway address must be on the same subnet as the + configured station address. + + The default route is added with Destination and PrefixLegth both set to all zeros. The + default route matches all destination IPv6 addresses that do not match any other routes. + + All EFI IPv6 Protocol instances share a routing table. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[in] DeleteRoute Set to TRUE to delete this route from the routing table. Set to + FALSE to add this route to the routing table. Destination, + PrefixLength and Gateway are used as the key to each + route entry. + @param[in] Destination The address prefix of the subnet that needs to be routed. + @param[in] PrefixLength The prefix length of Destination. Ignored if Destination + is NULL. + @param[in] GatewayAddress The unicast gateway IPv6 address for this route. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_NOT_STARTED The driver instance has not been started. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + - This is NULL. + - When DeleteRoute is TRUE, both Destination and + GatewayAddress are NULL. + - When DeleteRoute is FALSE, either Destination or + GatewayAddress is NULL. + - *GatewayAddress is not a valid unicast IPv6 address. + - *GatewayAddress is one of the local configured IPv6 + addresses. + @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table. + @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE). + @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when + DeleteRoute is FALSE). + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_ROUTES) ( + IN EFI_IP6_PROTOCOL *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv6_ADDRESS *Destination, OPTIONAL + IN UINT8 PrefixLength, + IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL + ); + +/** + Add or delete Neighbor cache entries. + + The Neighbors() function is used to add, update, or delete an entry from neighbor cache. + IPv6 neighbor cache entries are typically inserted and updated by the network protocol driver as + network traffic is processed. Most neighbor cache entries will time out and be deleted if the network + traffic stops. Neighbor cache entries that were inserted by Neighbors() may be static (will not + timeout) or dynamic (will time out). + + The implementation should follow the neighbor cache timeout mechanism which is defined in + RFC4861. The default neighbor cache timeout value should be tuned for the expected network + environment + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[in] DeleteFlag Set to TRUE to delete the specified cache entry, set to FALSE to + add (or update, if it already exists and Override is TRUE) the + specified cache entry. TargetIp6Address is used as the key + to find the requested cache entry. + @param[in] TargetIp6Address Pointer to Target IPv6 address. + @param[in] TargetLinkAddress Pointer to link-layer address of the target. Ignored if NULL. + @param[in] Timeout Time in 100-ns units that this entry will remain in the neighbor + cache, it will be deleted after Timeout. A value of zero means that + the entry is permanent. A non-zero value means that the entry is + dynamic. + @param[in] Override If TRUE, the cached link-layer address of the matching entry will + be overridden and updated; if FALSE, EFI_ACCESS_DENIED + will be returned if a corresponding cache entry already existed. + + @retval EFI_SUCCESS The data has been queued for transmission. + @retval EFI_NOT_STARTED This instance has not been started. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + - This is NULL. + - TargetIpAddress is NULL. + - *TargetLinkAddress is invalid when not NULL. + - *TargetIpAddress is not a valid unicast IPv6 address. + - *TargetIpAddress is one of the local configured IPv6 + addresses. + @retval EFI_OUT_OF_RESOURCES Could not add the entry to the neighbor cache. + @retval EFI_NOT_FOUND This entry is not in the neighbor cache (when DeleteFlag is + TRUE or when DeleteFlag is FALSE while + TargetLinkAddress is NULL.). + @retval EFI_ACCESS_DENIED The to-be-added entry is already defined in the neighbor cache, + and that entry is tagged as un-overridden (when DeleteFlag + is FALSE). + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_NEIGHBORS) ( + IN EFI_IP6_PROTOCOL *This, + IN BOOLEAN DeleteFlag, + IN EFI_IPv6_ADDRESS *TargetIp6Address, + IN EFI_MAC_ADDRESS *TargetLinkAddress, + IN UINT32 Timeout, + IN BOOLEAN Override + ); + +/** + Places outgoing data packets into the transmit queue. + + The Transmit() function places a sending request in the transmit queue of this + EFI IPv6 Protocol instance. Whenever the packet in the token is sent out or some + errors occur, the event in the token will be signaled and the status is updated. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[in] Token Pointer to the transmit token. + + @retval EFI_SUCCESS The data has been queued for transmission. + @retval EFI_NOT_STARTED This instance has not been started. + @retval EFI_NO_MAPPING The IPv6 driver was responsible for choosing a source address for + this transmission, but no source address was available for use. + @retval EFI_INVALID_PARAMETER One or more of the following is TRUE: + - This is NULL. + - Token is NULL. + - Token.Event is NULL. + - Token.Packet.TxData is NULL. + - Token.Packet.ExtHdrsLength is not zero and Token.Packet.ExtHdrs is NULL. + - Token.Packet.FragmentCount is zero. + - One or more of the Token.Packet.TxData.FragmentTable[].FragmentLength fields is zero. + - One or more of the Token.Packet.TxData.FragmentTable[].FragmentBuffer fields is NULL. + - Token.Packet.TxData.DataLength is zero or not equal to the sum of fragment lengths. + - Token.Packet.TxData.DestinationAddress is non-zero when DestinationAddress is configured as + non-zero when doing Configure() for this EFI IPv6 protocol instance. + - Token.Packet.TxData.DestinationAddress is unspecified when DestinationAddress is unspecified + when doing Configure() for this EFI IPv6 protocol instance. + @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event + was already in the transmit queue. + @retval EFI_NOT_READY The completion token could not be queued because the transmit + queue is full. + @retval EFI_NOT_FOUND Not route is found to destination address. + @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data. + @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too + short to transmit. + @retval EFI_BAD_BUFFER_SIZE If Token.Packet.TxData.DataLength is beyond the + maximum that which can be described through the Fragment Offset + field in Fragment header when performing fragmentation. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_TRANSMIT) ( + IN EFI_IP6_PROTOCOL *This, + IN EFI_IP6_COMPLETION_TOKEN *Token + ); + +/** + Places a receiving request into the receiving queue. + + The Receive() function places a completion token into the receive packet queue. + This function is always asynchronous. + + The Token.Event field in the completion token must be filled in by the caller + and cannot be NULL. When the receive operation completes, the EFI IPv6 Protocol + driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event + is signaled. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param]in] Token Pointer to a token that is associated with the receive data descriptor. + + @retval EFI_SUCCESS The receive completion token was cached. + @retval EFI_NOT_STARTED This EFI IPv6 Protocol instance has not been started. + @retval EFI_NO_MAPPING When IP6 driver responsible for binding source address to this instance, + while no source address is available for use. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + - This is NULL. + - Token is NULL. + - Token.Event is NULL. + @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system + resources (usually memory). + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + The EFI IPv6 Protocol instance has been reset to startup defaults. + @retval EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already + in the receive queue. + @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_RECEIVE) ( + IN EFI_IP6_PROTOCOL *This, + IN EFI_IP6_COMPLETION_TOKEN *Token + ); + +/** + Abort an asynchronous transmit or receive request. + + The Cancel() function is used to abort a pending transmit or receive request. + If the token is in the transmit or receive request queues, after calling this + function, Token->Status will be set to EFI_ABORTED and then Token->Event will + be signaled. If the token is not in one of the queues, which usually means the + asynchronous operation has completed, this function will not signal the token + and EFI_NOT_FOUND is returned. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + @param[in] Token Pointer to a token that has been issued by + EFI_IP6_PROTOCOL.Transmit() or + EFI_IP6_PROTOCOL.Receive(). If NULL, all pending + tokens are aborted. Type EFI_IP6_COMPLETION_TOKEN is + defined in EFI_IP6_PROTOCOL.Transmit(). + + @retval EFI_SUCCESS The asynchronous I/O request was aborted and + Token->Event was signaled. When Token is NULL, all + pending requests were aborted and their events were signaled. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED This instance has not been started. + @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was + not found in the transmit or receive queue. It has either completed + or was not issued by Transmit() and Receive(). + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CANCEL)( + IN EFI_IP6_PROTOCOL *This, + IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL + ); + +/** + Polls for incoming data packets and processes outgoing data packets. + + The Poll() function polls for incoming data packets and processes outgoing data + packets. Network drivers and applications can call the EFI_IP6_PROTOCOL.Poll() + function to increase the rate that data packets are moved between the communications + device and the transmit and receive queues. + + In some systems the periodic timer event may not poll the underlying communications + device fast enough to transmit and/or receive all data packets without missing + incoming packets or dropping outgoing packets. Drivers and applications that are + experiencing packet loss should try calling the EFI_IP6_PROTOCOL.Poll() function + more often. + + @param[in] This Pointer to the EFI_IP6_PROTOCOL instance. + + @retval EFI_SUCCESS Incoming or outgoing data was processed. + @retval EFI_NOT_STARTED This EFI IPv6 Protocol instance has not been started. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_NOT_READY No incoming or outgoing data is processed. + @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. + Consider increasing the polling rate. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_POLL) ( + IN EFI_IP6_PROTOCOL *This + ); + +/// +/// The EFI IPv6 Protocol implements a simple packet-oriented interface that can be +/// used by drivers, daemons, and applications to transmit and receive network packets. +/// +typedef struct _EFI_IP6_PROTOCOL { + EFI_IP6_GET_MODE_DATA GetModeData; + EFI_IP6_CONFIGURE Configure; + EFI_IP6_GROUPS Groups; + EFI_IP6_ROUTES Routes; + EFI_IP6_NEIGHBORS Neighbors; + EFI_IP6_TRANSMIT Transmit; + EFI_IP6_RECEIVE Receive; + EFI_IP6_CANCEL Cancel; + EFI_IP6_POLL Poll; +} EFI_IP6_PROTOCOL; + +extern EFI_GUID gEfiIp6ServiceBindingProtocolGuid; +extern EFI_GUID gEfiIp6ProtocolGuid; + +#endif diff --git a/MdePkg/Include/Protocol/Ip6Config.h b/MdePkg/Include/Protocol/Ip6Config.h new file mode 100644 index 0000000000..2182e4b374 --- /dev/null +++ b/MdePkg/Include/Protocol/Ip6Config.h @@ -0,0 +1,369 @@ +/** @file + This file provides a definition of the EFI IPv6 Configuration + Protocol. + +Copyright (c) 2008 - 2009, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#ifndef __EFI_IP6CONFIG_PROTOCOL_H__ +#define __EFI_IP6CONFIG_PROTOCOL_H__ + +#include + +#define EFI_IP6_CONFIG_PROTOCOL_GUID \ + { \ + 0x937fe521, 0x95ae, 0x4d1a, {0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \ + } + +typedef struct _EFI_IP6_CONFIG_PROTOCOL EFI_IP6_CONFIG_PROTOCOL; + +/// +/// EFI_IP6_CONFIG_DATA_TYPE +/// +typedef enum { + /// + /// The interface information of the communication + /// device this EFI IPv6 Configuration Protocol instance manages. + /// This type of data is read only.The corresponding Data is of type + /// EFI_IP6_CONFIG_INTERFACE_INFO. + /// + Ip6ConfigDataTypeInterfaceInfo, + /// + /// The alternative interface ID for the + /// communication device this EFI IPv6 Configuration Protocol + /// instance manages if the link local IPv6 address generated from + /// the interfaced ID based on the default source the EFI IPv6 + /// Protocol uses is a duplicate address. The length of the interface + /// ID is 64 bit. The corresponding Data is of type + /// EFI_IP6_CONFIG_INTERFACE_ID. + /// + Ip6ConfigDataTypeAltInterfaceId, + /// + /// The general configuration policy for the EFI IPv6 network + /// stack running on the communication device this EFI IPv6 + /// Configuration Protocol instance manages. The policy will affect + /// other configuration settings. The corresponding Data is of type + /// EFI_IP6_CONFIG_POLICY. + /// + Ip6ConfigDataTypePolicy, + /// + /// The number of consecutive + /// Neighbor Solicitation messages sent while performing Duplicate + /// Address Detection on a tentative address. A value of zero + /// indicates that Duplicate Address Detection will not be performed + /// on tentative addresses. The corresponding Data is of type + /// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS. + /// + Ip6ConfigDataTypeDupAddrDetectTransmits, + /// + /// The station addresses set manually for the EFI + /// IPv6 network stack. It is only configurable when the policy is + /// Ip6ConfigPolicyManual. The corresponding Data is a + /// pointer to an array of EFI_IPv6_ADDRESS instances. + /// + Ip6ConfigDataTypeManualAddress, + /// + /// The gateway addresses set manually for the EFI IPv6 + /// network stack running on the communication device this EFI + /// IPv6 Configuration Protocol manages. It is not configurable when + /// the policy is Ip6ConfigPolicyAutomatic. The gateway + /// addresses must be unicast IPv6 addresses. The corresponding + /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. + /// + Ip6ConfigDataTypeGateway, + /// + /// The DNS server list for the EFI IPv6 network stack + /// running on the communication device this EFI IPv6 + /// Configuration Protocol manages. It is not configurable when the + /// policy is Ip6ConfigPolicyAutomatic.The DNS server + /// addresses must be unicast IPv6 addresses. The corresponding + /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. + /// + Ip6ConfigDataTypeDnsServer, + /// + /// The number of this enumeration memebers. + /// + Ip6ConfigDataTypeMaximum +} EFI_IP6_CONFIG_DATA_TYPE; + +/// +/// EFI_IP6_CONFIG_INTERFACE_INFO +/// describes the operational state of the interface this +/// EFI IPv6 Configuration Protocol instance manages. +/// +typedef struct { + /// + /// The name of the interface. It is a NULL-terminated Unicode string. + /// + CHAR16 Name[32]; + /// + /// The interface type of the network interface. + /// + UINT8 IfType; + /// + /// The size, in bytes, of the network interface's hardware address. + /// + UINT32 HwAddressSize; + /// + /// The hardware address for the network interface. + /// + EFI_MAC_ADDRESS HwAddress; + /// + /// Number of EFI_IP6_ADDRESS_INFO structures pointed to by AddressInfo. + /// + UINT32 AddressInfoCount; + /// + /// Pointer to an array of EFI_IP6_ADDRESS_INFO instances + /// which contain the local IPv6 addresses and the corresponding + /// prefix length information. Set to NULL if AddressInfoCount + /// is zero. + /// + EFI_IP6_ADDRESS_INFO *AddressInfo; + /// + /// Number of route table entries in the following RouteTable. + /// + UINT32 RouteCount; + /// + /// The route table of the IPv6 network stack runs on this interface. + /// Set to NULL if RouteCount is zero. + /// + EFI_IP6_ROUTE_TABLE *RouteTable; +} EFI_IP6_CONFIG_INTERFACE_INFO; + +/// +/// EFI_IP6_CONFIG_INTERFACE_ID +/// describes the 64-bit interface ID. +/// +typedef struct { + UINT8 Id[8]; +} EFI_IP6_CONFIG_INTERFACE_ID; + +/// +/// EFI_IP6_CONFIG_POLICY +/// defines the general configuration policy the EFI IPv6 +/// Configuration Protocol supports. +/// +typedef enum { + /// + /// Under this policy, the IpI6ConfigDataTypeManualAddress, + /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer + /// configuration data are required to be set manually. + /// The EFI IPv6 Protocol will get all required configuration + /// such as address, prefix and gateway settings from the EFI + /// IPv6 Configuration protocol. + /// + Ip6ConfigPolicyManual, + /// + /// Under this policy, the IpI6ConfigDataTypeManualAddress, + /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer + /// configuration data are not allowed to set via SetData(). + /// All of these configurations are retrieved from some auto + /// configuration mechanism. + /// The EFI IPv6 Protocol will use the IPv6 stateless address + /// autoconfiguration mechanism and/or the IPv6 stateful address + /// autoconfiguration mechanism described in the related RFCs to + /// get address and other configuration information + /// + Ip6ConfigPolicyAutomatic +} EFI_IP6_CONFIG_POLICY; + +/// +/// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS +/// describes the number of consecutive Neighbor Solicitation messages sent +/// while performing Duplicate Address Detection on a tentative address. +/// The default value for a newly detected communication device is 1. +/// +typedef struct { + UINT32 DupAddrDetectTransmits; ///< The number of consecutive Neighbor Solicitation messages sent. +} EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS; + +/// +/// EFI_IP6_CONFIG_MANUAL_ADDRESS +/// is used to set the station address information for the EFI IPv6 network +/// stack manually when the policy is Ip6ConfigPolicyManual. +/// +typedef struct { + EFI_IPv6_ADDRESS Address; ///< The IPv6 unicast address. + BOOLEAN IsAnycast; ///< Set to TRUE if Address is anycast. + UINT8 PrefixLength; ///< The length, in bits, of the prefix associated with this Address. +} EFI_IP6_CONFIG_MANUAL_ADDRESS; + + +/** + Set the configuration for the EFI IPv6 network stack running on the communication + device this EFI IPv6 Configuration Protocol instance manages. + + This function is used to set the configuration data of type DataType for the EFI + IPv6 network stack running on the communication device this EFI IPv6 Configuration + Protocol instance manages. + + The DataSize is used to calculate the count of structure instances in the Data for + some DataType that multiple structure instances are allowed. + + This function is always non-blocking. When setting some type of configuration data, + an asynchronous process is invoked to check the correctness of the data, such as + doing Duplicate Address Detection on the manually set local IPv6 addresses. + EFI_NOT_READY is returned immediately to indicate that such an asynchronous process + is invoked and the process is not finished yet. The caller willing to get the result + of the asynchronous process is required to call RegisterDataNotify() to register an + event on the specified configuration data. Once the event is signaled, the caller + can call GetData() to get back the configuration data in order to know the result. + For other types of configuration data that do not require an asynchronous configuration + process, the result of the operation is immediately returned. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to set. + @param[in] DataSize Size of the buffer pointed to by Data in bytes. + @param[in] Data The data buffer to set. The type of the data buffer is + associated with the DataType. + + @retval EFI_SUCCESS The specified configuration data for the EFI IPv6 + network stack is set successfully. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + - This is NULL. + - Data is NULL. + - One or more fields in Data do not match the requirement of the + data type indicated by DataType. + @rerval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified + configuration data can not be set under the current policy + @retval EFI_ACCESS_DENIED Another set operation on the specified configuration + data is already in process. + @retval EFI_NOT_READY An asynchronous process is invoked to set the specified + configuration data and the process is not finished yet. + @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type + indicated by DataType. + @retval EFI_UNSUPPORTED This DataType is not supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_SET_DATA) ( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN UINTN DataSize, + IN VOID *Data + ); + +/** + Get the configuration data for the EFI IPv6 network stack running on the communication + device this EFI IPv6 Configuration Protocol instance manages. + + This function returns the configuration data of type DataType for the EFI IPv6 network + stack running on the communication device this EFI IPv6 Configuration Protocol instance + manages. + + The caller is responsible for allocating the buffer used to return the specified + configuration data and the required size will be returned to the caller if the size of + the buffer is too small. + + EFI_NOT_READY is returned if the specified configuration data is not ready due to an + already in progress asynchronous configuration process. The caller can call RegisterDataNotify() + to register an event on the specified configuration data. Once the asynchronous configuration + process is finished, the event will be signaled and a subsequent GetData() call will return + the specified configuration data. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to get. + @param[in,out] DataSize On input, in bytes, the size of Data. On output, in bytes, the + size of buffer required to store the specified configuration data. + @param[in] Data The data buffer in which the configuration data is returned. The + type of the data buffer is associated with the DataType. + + @retval EFI_SUCCESS The specified configuration data is got successfully. + @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE: + - This is NULL. + - DataSize is NULL. + - Data is NULL if *DataSize is not zero. + @rerval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified configuration data + and the required size is returned in DataSize. + @retval EFI_NOT_READY The specified configuration data is not ready due to an already in + progress asynchronous configuration process. + @retval EFI_NOT_FOUND The specified configuration data is not found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_GET_DATA) ( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN OUT UINTN *DataSize, + IN VOID *Data OPTIONAL + ); + +/** + Register an event that is to be signaled whenever a configuration process on the specified + configuration data is done. + + This function registers an event that is to be signaled whenever a configuration process + on the specified configuration data is done. An event can be registered for different DataType + simultaneously and the caller is responsible for determining which type of configuration data + causes the signaling of the event in such case. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to unregister the event for. + @param[in] Event The event to register. + + @retval EFI_SUCCESS The notification event for the specified configuration data is + registered. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @rerval EFI_UNSUPPORTED The configuration data type specified by DataType is not + supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_ACCESS_DENIED The Event is already registered for the DataType. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_REGISTER_NOTIFY) ( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/** + Remove a previously registered event for the specified configuration data. + + This function removes a previously registered event for the specified configuration data. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to remove the previously registered event for. + @param[in] Event The event to unregister. + + @retval EFI_SUCCESS The event registered for the specified configuration data is removed. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @rerval EFI_NOT_FOUND The Event has not been registered for the specified + DataType. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_UNREGISTER_NOTIFY) ( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/// +/// The EFI_IP6_CONFIG_PROTOCOL provides the mechanism to set and get various +/// types of configurations for the EFI IPv6 network stack. +/// +typedef struct _EFI_IP6_CONFIG_PROTOCOL { + EFI_IP6_CONFIG_SET_DATA SetData; + EFI_IP6_CONFIG_GET_DATA GetData; + EFI_IP6_CONFIG_REGISTER_NOTIFY RegisterDataNotify; + EFI_IP6_CONFIG_UNREGISTER_NOTIFY UnregisterDataNotify; +} EFI_IP6_CONFIG_PROTOCOL; + +extern EFI_GUID gEfiIp6ConfigProtocolGuid; + +#endif + diff --git a/MdePkg/Include/Protocol/Tcp4.h b/MdePkg/Include/Protocol/Tcp4.h index d750fe9c78..355afe1835 100644 --- a/MdePkg/Include/Protocol/Tcp4.h +++ b/MdePkg/Include/Protocol/Tcp4.h @@ -1,10 +1,10 @@ /** @file - EFI TCPv4 Protocol Definition + EFI TCPv4(Transmission Control Protocol version 4) Protocol Definition The EFI TCPv4 Service Binding Protocol is used to locate EFI TCPv4 Protocol drivers to create and destroy child of the driver to communicate with other host using TCP protocol. The EFI TCPv4 Protocol provides services to send and receive data stream. - Copyright (c) 2006 - 2008, Intel Corporation + Copyright (c) 2006 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -269,8 +269,7 @@ EFI_STATUS way handshake finishes. @retval EFI_SUCCESS The connection request is successfully initiated and the state - - of this TCPv4 instance has been changed to - - Tcp4StateSynSent. + of this TCPv4 instance has been changed to Tcp4StateSynSent. @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured. @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE: - This instance is not configured as an active one. @@ -279,7 +278,7 @@ EFI_STATUS - This is NULL. - ConnectionToken is NULL. - ConnectionToken->CompletionToken.Event is NULL. - @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the activeopen. + @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the activ eopen. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. **/ @@ -443,12 +442,15 @@ EFI_STATUS EFI_TCP4_COMPLETION_TOKEN is defined in EFI_TCP4_PROTOCOL.Connect(). - @retval EFI_SUCCESS Incoming or outgoing data was processed. - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. - @retval EFI_NOT_READY No incoming or outgoing data is processed. - @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue. - Consider increasing the polling rate. + @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event + is signaled. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED This instance hasn't been configured. + @retval EFI_NO_MAPPING When using the default address, configuration + (DHCP, BOOTP,RARP, etc.) hasn't finished yet. + @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the + transmission or receive queue. It has either + completed or wasn't issued by Transmit() and Receive(). **/ typedef diff --git a/MdePkg/Include/Protocol/Tcp6.h b/MdePkg/Include/Protocol/Tcp6.h new file mode 100644 index 0000000000..d3f538200c --- /dev/null +++ b/MdePkg/Include/Protocol/Tcp6.h @@ -0,0 +1,853 @@ +/** @file + EFI TCPv6(Transmission Control Protocol version 6) Protocol Definition + The EFI TCPv6 Service Binding Protocol is used to locate EFI TCPv6 Protocol drivers to create + and destroy child of the driver to communicate with other host using TCP protocol. + The EFI TCPv6 Protocol provides services to send and receive data stream. + + Copyright (c) 2008 - 2009, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EFI_TCP6_PROTOCOL_H__ +#define __EFI_TCP6_PROTOCOL_H__ + +#include +#include +#include + +#define EFI_TCP6_SERVICE_BINDING_PROTOCOL_GUID \ + { \ + 0xec20eb79, 0x6c1a, 0x4664, {0x9a, 0x0d, 0xd2, 0xe4, 0xcc, 0x16, 0xd6, 0x64 } \ + } + +#define EFI_TCP6_PROTOCOL_GUID \ + { \ + 0x46e44855, 0xbd60, 0x4ab7, {0xab, 0x0d, 0xa6, 0x79, 0xb9, 0x44, 0x7d, 0x77 } \ + } + + +typedef struct _EFI_TCP6_PROTOCOL EFI_TCP6_PROTOCOL; + + +/// +/// EFI_TCP6_SERVICE_POINT +/// +typedef struct { + /// + /// The EFI TCPv6 Protocol instance handle that is using this + /// address/port pair. + /// + EFI_HANDLE InstanceHandle; + /// + /// The local IPv6 address to which this TCP instance is bound. Set + /// to 0::/128, if this TCP instance is configured to listen on all + /// available source addresses. + /// + EFI_IPv6_ADDRESS LocalAddress; + /// + /// The local port number in host byte order. + /// + UINT16 LocalPort; + /// + /// The remote IPv6 address. It may be 0::/128 if this TCP instance is + /// not connected to any remote host. + /// + EFI_IPv6_ADDRESS RemoteAddress; + /// + /// The remote port number in host byte order. It may be zero if this + /// TCP instance is not connected to any remote host. + /// + UINT16 RemotePort; +} EFI_TCP6_SERVICE_POINT; + +/// +/// EFI_TCP6_VARIABLE_DATA +/// +typedef struct { + EFI_HANDLE DriverHandle; ///< The handle of the driver that creates this entry. + UINT32 ServiceCount; ///< The number of address/port pairs following this data structure. + EFI_TCP6_SERVICE_POINT Services[1]; ///< List of address/port pairs that are currently in use. +} EFI_TCP6_VARIABLE_DATA; + +/// +/// EFI_TCP6_ACCESS_POINT +/// +typedef struct { + /// + /// The local IP address assigned to this TCP instance. The EFI + /// TCPv6 driver will only deliver incoming packets whose + /// destination addresses exactly match the IP address. Set to zero to + /// let the underlying IPv6 driver choose a source address. If not zero + /// it must be one of the configured IP addresses in the underlying + /// IPv6 driver. + /// + EFI_IPv6_ADDRESS StationAddress; + /// + /// The local port number to which this EFI TCPv6 Protocol instance + /// is bound. If the instance doesn't care the local port number, set + /// StationPort to zero to use an ephemeral port. + /// + UINT16 StationPort; + /// + /// The remote IP address to which this EFI TCPv6 Protocol instance + /// is connected. If ActiveFlag is FALSE (i.e. a passive TCPv6 + /// instance), the instance only accepts connections from the + /// RemoteAddress. If ActiveFlag is TRUE the instance will + /// connect to the RemoteAddress, i.e., outgoing segments will be + /// sent to this address and only segments from this address will be + /// delivered to the application. When ActiveFlag is FALSE, it + /// can be set to zero and means that incoming connection requests + /// from any address will be accepted. + /// + EFI_IPv6_ADDRESS RemoteAddress; + /// + /// The remote port to which this EFI TCPv6 Protocol instance + /// connects or from which connection request will be accepted by + /// this EFI TCPv6 Protocol instance. If ActiveFlag is FALSE it + /// can be zero and means that incoming connection request from + /// any port will be accepted. Its value can not be zero when + /// ActiveFlag is TRUE. + /// + UINT16 RemotePort; + /// + /// Set it to TRUE to initiate an active open. Set it to FALSE to + /// initiate a passive open to act as a server. + /// + BOOLEAN ActiveFlag; +} EFI_TCP6_ACCESS_POINT; + +/// +/// EFI_TCP6_OPTION +/// +typedef struct { + /// + /// The size of the TCP receive buffer. + /// + UINT32 ReceiveBufferSize; + /// + /// The size of the TCP send buffer. + /// + UINT32 SendBufferSize; + /// + /// The length of incoming connect request queue for a passive + /// instance. When set to zero, the value is implementation specific. + /// + UINT32 MaxSynBackLog; + /// + /// The maximum seconds a TCP instance will wait for before a TCP + /// connection established. When set to zero, the value is + /// implementation specific. + /// + UINT32 ConnectionTimeout; + /// + ///The number of times TCP will attempt to retransmit a packet on + ///an established connection. When set to zero, the value is + ///implementation specific. + /// + UINT32 DataRetries; + /// + /// How many seconds to wait in the FIN_WAIT_2 states for a final + /// FIN flag before the TCP instance is closed. This timeout is in + /// effective only if the application has called Close() to + /// disconnect the connection completely. It is also called + /// FIN_WAIT_2 timer in other implementations. When set to zero, + /// it should be disabled because the FIN_WAIT_2 timer itself is + /// against the standard. The default value is 60. + /// + UINT32 FinTimeout; + /// + /// How many seconds to wait in TIME_WAIT state before the TCP + /// instance is closed. The timer is disabled completely to provide a + /// method to close the TCP connection quickly if it is set to zero. It + /// is against the related RFC documents. + /// + UINT32 TimeWaitTimeout; + /// + /// The maximum number of TCP keep-alive probes to send before + /// giving up and resetting the connection if no response from the + /// other end. Set to zero to disable keep-alive probe. + /// + UINT32 KeepAliveProbes; + /// + /// The number of seconds a connection needs to be idle before TCP + /// sends out periodical keep-alive probes. When set to zero, the + /// value is implementation specific. It should be ignored if keep- + /// alive probe is disabled. + /// + UINT32 KeepAliveTime; + /// + /// The number of seconds between TCP keep-alive probes after the + /// periodical keep-alive probe if no response. When set to zero, the + /// value is implementation specific. It should be ignored if keep- + /// alive probe is disabled. + /// + UINT32 KeepAliveInterval; + /// + /// Set it to TRUE to enable the Nagle algorithm as defined in + /// RFC896. Set it to FALSE to disable it. + /// + BOOLEAN EnableNagle; + /// + /// Set it to TRUE to enable TCP timestamps option as defined in + /// RFC1323. Set to FALSE to disable it. + /// + BOOLEAN EnableTimeStamp; + /// + /// Set it to TRUE to enable TCP window scale option as defined in + /// RFC1323. Set it to FALSE to disable it. + /// + BOOLEAN EnableWindowScaling; + /// + /// Set it to TRUE to enable selective acknowledge mechanism + /// described in RFC 2018. Set it to FALSE to disable it. + /// Implementation that supports SACK can optionally support + /// DSAK as defined in RFC 2883. + /// + BOOLEAN EnableSelectiveAck; + /// + /// Set it to TRUE to enable path MTU discovery as defined in + /// RFC 1191. Set to FALSE to disable it. + /// + BOOLEAN EnablePathMtuDiscovery; +} EFI_TCP6_OPTION; + +/// +/// EFI_TCP6_CONFIG_DATA +/// +typedef struct { + /// + /// TrafficClass field in transmitted IPv6 packets. + /// + UINT8 TrafficClass; + /// + /// HopLimit field in transmitted IPv6 packets. + /// + UINT8 HopLimit; + /// + /// Used to specify TCP communication end settings for a TCP instance. + /// + EFI_TCP6_ACCESS_POINT AccessPoint; + /// + /// Used to configure the advance TCP option for a connection. If set + /// to NULL, implementation specific options for TCP connection will be used. + /// + EFI_TCP6_OPTION *ControlOption; +} EFI_TCP6_CONFIG_DATA; + +/// +/// EFI_TCP6_CONNECTION_STATE +/// +typedef enum { + Tcp6StateClosed = 0, + Tcp6StateListen = 1, + Tcp6StateSynSent = 2, + Tcp6StateSynReceived = 3, + Tcp6StateEstablished = 4, + Tcp6StateFinWait1 = 5, + Tcp6StateFinWait2 = 6, + Tcp6StateClosing = 7, + Tcp6StateTimeWait = 8, + Tcp6StateCloseWait = 9, + Tcp6StateLastAck = 10 +} EFI_TCP6_CONNECTION_STATE; + +/// +/// EFI_TCP6_COMPLETION_TOKEN +/// is used as a common header for various asynchronous tokens. +/// +typedef struct { + /// + /// The Event to signal after request is finished and Status field is + /// updated by the EFI TCPv6 Protocol driver. + /// + EFI_EVENT Event; + /// + /// The result of the completed operation. + /// + EFI_STATUS Status; +} EFI_TCP6_COMPLETION_TOKEN; + +/// +/// EFI_TCP6_CONNECTION_TOKEN +/// will be set if the active open succeeds or an unexpected +/// error happens. +/// +typedef struct { + /// + /// The Status in the CompletionToken will be set to one of + /// the following values if the active open succeeds or an unexpected + /// error happens: + /// EFI_SUCCESS: The active open succeeds and the instance's + /// state is Tcp6StateEstablished. + /// EFI_CONNECTION_RESET: The connect fails because the connection is reset + /// either by instance itself or the communication peer. + /// EFI_ABORTED: The active open is aborted. + /// EFI_TIMEOUT: The connection establishment timer expires and + /// no more specific information is available. + /// EFI_NETWORK_UNREACHABLE: The active open fails because + /// an ICMP network unreachable error is received. + /// EFI_HOST_UNREACHABLE: The active open fails because an + /// ICMP host unreachable error is received. + /// EFI_PROTOCOL_UNREACHABLE: The active open fails + /// because an ICMP protocol unreachable error is received. + /// EFI_PORT_UNREACHABLE: The connection establishment + /// timer times out and an ICMP port unreachable error is received. + /// EFI_ICMP_ERROR: The connection establishment timer times + /// out and some other ICMP error is received. + /// EFI_DEVICE_ERROR: An unexpected system or network error occurred. + /// EFI_SECURITY_VIOLATION: The active open was failed because of IPSec policy check. + /// + EFI_TCP6_COMPLETION_TOKEN CompletionToken; +} EFI_TCP6_CONNECTION_TOKEN; + +/// +/// EFI_TCP6_LISTEN_TOKEN +/// returns when list operation finishes. +/// +typedef struct { + /// + /// The Status in CompletionToken will be set to the + /// following value if accept finishes: + /// EFI_SUCCESS: A remote peer has successfully established a + /// connection to this instance. A new TCP instance has also been + /// created for the connection. + /// EFI_CONNECTION_RESET: The accept fails because the connection is reset either + /// by instance itself or communication peer. + /// EFI_ABORTED: The accept request has been aborted. + /// EFI_SECURITY_VIOLATION: The accept operation was failed because of IPSec policy check. + /// + EFI_TCP6_COMPLETION_TOKEN CompletionToken; + EFI_HANDLE NewChildHandle; +} EFI_TCP6_LISTEN_TOKEN; + +/// +/// EFI_TCP6_FRAGMENT_DATA +/// allows multiple receive or transmit buffers to be specified. The +/// purpose of this structure is to provide scattered read and write. +/// +typedef struct { + UINT32 FragmentLength; ///< Length of data buffer in the fragment. + VOID *FragmentBuffer; ///< Pointer to the data buffer in the fragment. +} EFI_TCP6_FRAGMENT_DATA; + +/// +/// EFI_TCP6_RECEIVE_DATA +/// When TCPv6 driver wants to deliver received data to the application, +/// it will pick up the first queued receiving token, update its +/// Token->Packet.RxData then signal the Token->CompletionToken.Event. +/// +typedef struct { + /// + /// Whether the data is urgent. When this flag is set, the instance is in + /// urgent mode. + /// + BOOLEAN UrgentFlag; + /// + /// When calling Receive() function, it is the byte counts of all + /// Fragmentbuffer in FragmentTable allocated by user. + /// When the token is signaled by TCPv6 driver it is the length of + /// received data in the fragments. + /// + UINT32 DataLength; + /// + /// Number of fragments. + /// + UINT32 FragmentCount; + /// + /// An array of fragment descriptors. + /// + EFI_TCP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP6_RECEIVE_DATA; + +/// +/// EFI_TCP6_TRANSMIT_DATA +/// The EFI TCPv6 Protocol user must fill this data structure before sending a packet. +/// The packet may contain multiple buffers in non-continuous memory locations. +/// +typedef struct { + /// + /// Push If TRUE, data must be transmitted promptly, and the PUSH bit in + /// the last TCP segment created will be set. If FALSE, data + /// transmission may be delayed to combine with data from + /// subsequent Transmit()s for efficiency. + /// + BOOLEAN Push; + /// + /// The data in the fragment table are urgent and urgent point is in + /// effect if TRUE. Otherwise those data are NOT considered urgent. + /// + BOOLEAN Urgent; + /// + /// Length of the data in the fragments. + /// + UINT32 DataLength; + /// + /// Number of fragments. + /// + UINT32 FragmentCount; + /// + /// An array of fragment descriptors. + /// + EFI_TCP6_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP6_TRANSMIT_DATA; + +/// +/// EFI_TCP6_IO_TOKEN +/// returns When transmission finishes or meets any unexpected error. +/// +typedef struct { + /// + /// When transmission finishes or meets any unexpected error it will + /// be set to one of the following values: + /// EFI_SUCCESS: The receiving or transmission operation + /// completes successfully. + /// EFI_CONNECTION_RESET: The receiving or transmission operation fails + /// because this connection is reset either by instance + /// itself or the communication peer. + /// EFI_ABORTED: The receiving or transmission is aborted. + /// EFI_TIMEOUT: The transmission timer expires and no more + /// specific information is available. + /// EFI_NETWORK_UNREACHABLE: The transmission fails + /// because an ICMP network unreachable error is received. + /// EFI_HOST_UNREACHABLE: The transmission fails because an + /// ICMP host unreachable error is received. + /// EFI_PROTOCOL_UNREACHABLE: The transmission fails + /// because an ICMP protocol unreachable error is received. + /// EFI_PORT_UNREACHABLE: The transmission fails and an + /// ICMP port unreachable error is received. + /// EFI_ICMP_ERROR: The transmission fails and some other + /// ICMP error is received. + /// EFI_DEVICE_ERROR: An unexpected system or network error occurs. + /// EFI_SECURITY_VIOLATION: The receiving or transmission + /// operation was failed because of IPSec policy check + /// + EFI_TCP6_COMPLETION_TOKEN CompletionToken; + union { + /// + /// When this token is used for receiving, RxData is a pointer to + /// EFI_TCP6_RECEIVE_DATA. + /// + EFI_TCP6_RECEIVE_DATA *RxData; + /// + /// When this token is used for transmitting, TxData is a pointer to + /// EFI_TCP6_TRANSMIT_DATA. + /// + EFI_TCP6_TRANSMIT_DATA *TxData; + } Packet; +} EFI_TCP6_IO_TOKEN; + +/// +/// EFI_TCP6_CLOSE_TOKEN +/// returns when close operation finishes. +/// +typedef struct { + /// + /// When close finishes or meets any unexpected error it will be set + /// to one of the following values: + /// EFI_SUCCESS: The close operation completes successfully. + /// EFI_ABORTED: User called configure with NULL without close stopping. + /// EFI_SECURITY_VIOLATION: The close operation was failed because of IPSec policy check. + /// + EFI_TCP6_COMPLETION_TOKEN CompletionToken; + /// + /// Abort the TCP connection on close instead of the standard TCP + /// close process when it is set to TRUE. This option can be used to + /// satisfy a fast disconnect. + /// + BOOLEAN AbortOnClose; +} EFI_TCP6_CLOSE_TOKEN; + +/** + Get the current operational status. + + The GetModeData() function copies the current operational settings of this EFI TCPv6 + Protocol instance into user-supplied buffers. This function can also be used to retrieve + the operational setting of underlying drivers such as IPv6, MNP, or SNP. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[out] Tcp6State The buffer in which the current TCP state is returned. + @param[out] Tcp6ConfigData The buffer in which the current TCP configuration is returned. + @param[out] Ip6ModeData The buffer in which the current IPv6 configuration data used by + the TCP instance is returned. + @param[out] MnpConfigData The buffer in which the current MNP configuration data used + indirectly by the TCP instance is returned. + @param[out] SnpModeData The buffer in which the current SNP mode data used indirectly by + the TCP instance is returned. + + @retval EFI_SUCCESS The mode data was read. + @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't + been started. + @retval EFI_INVALID_PARAMETER This is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_GET_MODE_DATA) ( + IN EFI_TCP6_PROTOCOL *This, + OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL, + OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL, + OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +/** + Initialize or brutally reset the operational parameters for this EFI TCPv6 instance. + + The Configure() function does the following: + - Initialize this TCP instance, i.e., initialize the communication end settings and + specify active open or passive open for an instance. + - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush + transmission and receiving buffer directly without informing the communication peer. + + No other TCPv6 Protocol operation except Poll() can be executed by this instance until + it is configured properly. For an active TCP instance, after a proper configuration it + may call Connect() to initiates the three-way handshake. For a passive TCP instance, + its state will transit to Tcp6StateListen after configuration, and Accept() may be + called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL, + the instance is reset. Resetting process will be done brutally, the state machine will + be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed, + and no traffic is allowed through this instance. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance. + If Tcp6ConfigData is set to NULL, the instance is reset. + + @retval EFI_SUCCESS The operational settings are set, changed, or reset + successfully. + @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source + address for this instance, but no source address was available for + use. + @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE: + - This is NULL. + - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor + one of the configured IP addresses in the underlying IPv6 driver. + - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast + IPv6 address. + - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or + Tcp6ConfigData->AccessPoint.RemotePort is zero when + Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE. + - A same access point has been configured in other TCP + instance properly. + @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without + calling Configure() with NULL to reset it. + @retval EFI_UNSUPPORTED One or more of the control options are not supported in + the implementation. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when + executing Configure(). + @retval EFI_DEVICE_ERROR An unexpected network or system error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CONFIGURE) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL + ); + +/** + Initiate a nonblocking TCP connection request for an active TCP instance. + + The Connect() function will initiate an active open to the remote peer configured + in current TCP instance if it is configured active. If the connection succeeds or + fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled + and ConnectionToken->CompletionToken.Status will be updated accordingly. This + function can only be called for the TCP instance in Tcp6StateClosed state. The + instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS. + If TCP three-way handshake succeeds, its state will become Tcp6StateEstablished, + otherwise, the state will return to Tcp6StateClosed. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] ConnectionToken Pointer to the connection token to return when the TCP three + way handshake finishes. + + @retval EFI_SUCCESS The connection request is successfully initiated and the state of + this TCP instance has been changed to Tcp6StateSynSent. + @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. + @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE: + - This instance is not configured as an active one. + - This instance is not in Tcp6StateClosed state. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + - This is NULL. + - ConnectionToken is NULL. + - ConnectionToken->CompletionToken.Event is NULL. + @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to initiate the active open. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CONNECT) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken + ); + +/** + Listen on the passive instance to accept an incoming connection request. This is a + nonblocking operation. + + The Accept() function initiates an asynchronous accept request to wait for an incoming + connection on the passive TCP instance. If a remote peer successfully establishes a + connection with this instance, a new TCP instance will be created and its handle will + be returned in ListenToken->NewChildHandle. The newly created instance is configured + by inheriting the passive instance's configuration and is ready for use upon return. + The new instance is in the Tcp6StateEstablished state. + + The ListenToken->CompletionToken.Event will be signaled when a new connection is + accepted, user aborts the listen or connection is reset. + + This function only can be called when current TCP instance is in Tcp6StateListen state. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] ListenToken Pointer to the listen token to return when operation finishes. + + + @retval EFI_SUCCESS The listen token has been queued successfully. + @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. + @retval EFI_ACCESS_DENIED One or more of the following are TRUE: + - This instance is not a passive instance. + - This instance is not in Tcp6StateListen state. + - The same listen token has already existed in the listen + token queue of this TCP instance. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + - This is NULL. + - ListenToken is NULL. + - ListentToken->CompletionToken.Event is NULL. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation. + @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_ACCEPT) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_LISTEN_TOKEN *ListenToken + ); + +/** + Queues outgoing data into the transmit queue. + + The Transmit() function queues a sending request to this TCP instance along with the + user data. The status of the token is updated and the event in the token will be + signaled once the data is sent out or some error occurs. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] Token Pointer to the completion token to queue to the transmit queue. + + @retval EFI_SUCCESS The data has been queued for transmission. + @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. + @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a + source address for this instance, but no source address was + available for use. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + - This is NULL. + - Token is NULL. + - Token->CompletionToken.Event is NULL. + - Token->Packet.TxData is NULL. + - Token->Packet.FragmentCount is zero. + - Token->Packet.DataLength is not equal to the sum of fragment lengths. + @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE: + - A transmit completion token with the same Token-> + CompletionToken.Event was already in the + transmission queue. + - The current instance is in Tcp6StateClosed state. + - The current instance is a passive one and it is in + Tcp6StateListen state. + - User has called Close() to disconnect this connection. + @retval EFI_NOT_READY The completion token could not be queued because the + transmit queue is full. + @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource + shortage. + @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_TRANSMIT) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_IO_TOKEN *Token + ); + +/** + Places an asynchronous receive request into the receiving queue. + + The Receive() function places a completion token into the receive packet queue. This + function is always asynchronous. The caller must allocate the Token->CompletionToken.Event + and the FragmentBuffer used to receive data. The caller also must fill the DataLength which + represents the whole length of all FragmentBuffer. When the receive operation completes, the + EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData + fields and the Token->CompletionToken.Event is signaled. If got data the data and its length + will be copied into the FragmentTable, at the same time the full length of received data will + be recorded in the DataLength fields. Providing a proper notification function and context + for the event will enable the user to receive the notification and receiving status. That + notification function is guaranteed to not be re-entered. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] Token Pointer to a token that is associated with the receive data + descriptor. + + @retval EFI_SUCCESS The receive completion token was cached. + @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. + @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source + address for this instance, but no source address was available for use. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + - This is NULL. + - Token is NULL. + - Token->CompletionToken.Event is NULL. + - Token->Packet.RxData is NULL. + - Token->Packet.RxData->DataLength is 0. + - The Token->Packet.RxData->DataLength is not the + sum of all FragmentBuffer length in FragmentTable. + @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of + system resources (usually memory). + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + The EFI TCPv6 Protocol instance has been reset to startup defaults. + @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE: + - A receive completion token with the same Token->CompletionToken.Event + was already in the receive queue. + - The current instance is in Tcp6StateClosed state. + - The current instance is a passive one and it is in + Tcp6StateListen state. + - User has called Close() to disconnect this connection. + @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no + any buffered data in the receive buffer of this instance + @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_RECEIVE) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_IO_TOKEN *Token + ); + +/** + Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a + nonblocking operation. + + Initiate an asynchronous close token to TCP driver. After Close() is called, any buffered + transmission data will be sent by TCP driver and the current instance will have a graceful close + working flow described as RFC 793 if AbortOnClose is set to FALSE, otherwise, a rest packet + will be sent by TCP driver to fast disconnect this connection. When the close operation completes + successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous + operations are signaled and any buffers used for TCP network traffic are flushed. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] CloseToken Pointer to the close token to return when operation finishes. + + @retval EFI_SUCCESS The Close() is called successfully. + @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. + @retval EFI_ACCESS_DENIED One or more of the following are TRUE: + - CloseToken or CloseToken->CompletionToken.Event is already in use. + - Previous Close() call on this instance has not finished. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + - This is NULL. + - CloseToken is NULL. + - CloseToken->CompletionToken.Event is NULL. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation. + @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CLOSE) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_CLOSE_TOKEN *CloseToken + ); + +/** + Abort an asynchronous connection, listen, transmission or receive request. + + The Cancel() function aborts a pending connection, listen, transmit or + receive request. + + If Token is not NULL and the token is in the connection, listen, transmission + or receive queue when it is being cancelled, its Token->Status will be set + to EFI_ABORTED and then Token->Event will be signaled. + + If the token is not in one of the queues, which usually means that the + asynchronous operation has completed, EFI_NOT_FOUND is returned. + + If Token is NULL all asynchronous token issued by Connect(), Accept(), + Transmit() and Receive() will be aborted. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + @param[in] Token Pointer to a token that has been issued by + EFI_TCP6_PROTOCOL.Connect(), + EFI_TCP6_PROTOCOL.Accept(), + EFI_TCP6_PROTOCOL.Transmit() or + EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending + tokens issued by above four functions will be aborted. Type + EFI_TCP6_COMPLETION_TOKEN is defined in + EFI_TCP_PROTOCOL.Connect(). + + @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event + is signaled. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED This instance hasn't been configured. + @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or + receive queue. It has either completed or wasn't issued by + Transmit() and Receive(). + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_CANCEL) ( + IN EFI_TCP6_PROTOCOL *This, + IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL + ); + +/** + Poll to receive incoming data and transmit outgoing segments. + + The Poll() function increases the rate that data is moved between the network + and application and can be called when the TCP instance is created successfully. + Its use is optional. + + @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. + + @retval EFI_SUCCESS Incoming or outgoing data was processed. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_NOT_READY No incoming or outgoing data is processed. + @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue. + Consider increasing the polling rate. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_TCP6_POLL) ( + IN EFI_TCP6_PROTOCOL *This + ); + +/// +/// EFI_TCP6_PROTOCOL +/// defines the EFI TCPv6 Protocol child to be used by any network drivers or +/// applications to send or receive data stream. It can either listen on a +/// specified port as a service or actively connect to remote peer as a client. +/// Each instance has its own independent settings. +/// +typedef struct _EFI_TCP6_PROTOCOL { + EFI_TCP6_GET_MODE_DATA GetModeData; + EFI_TCP6_CONFIGURE Configure; + EFI_TCP6_CONNECT Connect; + EFI_TCP6_ACCEPT Accept; + EFI_TCP6_TRANSMIT Transmit; + EFI_TCP6_RECEIVE Receive; + EFI_TCP6_CLOSE Close; + EFI_TCP6_CANCEL Cancel; + EFI_TCP6_POLL Poll; +} EFI_TCP6_PROTOCOL; + +extern EFI_GUID gEfiTcp6ServiceBindingProtocolGuid; +extern EFI_GUID gEfiTcp6ProtocolGuid; + +#endif + -- 2.39.2