--- /dev/null
+/** @file\r
+ Implementation of EFI_IP6_PROTOCOL protocol interfaces.\r
+\r
+ Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+ 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
+**/\r
+\r
+#include "Ip6Impl.h"\r
+\r
+EFI_IPSEC_PROTOCOL *mIpSec = NULL;\r
+\r
+EFI_IP6_PROTOCOL mEfiIp6ProtocolTemplete = {\r
+ EfiIp6GetModeData,\r
+ EfiIp6Configure,\r
+ EfiIp6Groups,\r
+ EfiIp6Routes,\r
+ EfiIp6Neighbors,\r
+ EfiIp6Transmit,\r
+ EfiIp6Receive,\r
+ EfiIp6Cancel,\r
+ EfiIp6Poll\r
+};\r
+\r
+/**\r
+ Gets the current operational settings for this instance of the EFI IPv6 Protocol driver.\r
+\r
+ The GetModeData() function returns the current operational mode data for this driver instance.\r
+ The data fields in EFI_IP6_MODE_DATA are read only. This function is used optionally to\r
+ retrieve the operational mode data of underlying networks or drivers.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[out] Ip6ModeData Pointer to the EFI IPv6 Protocol mode data structure.\r
+ @param[out] MnpConfigData Pointer to the managed network configuration data structure.\r
+ @param[out] SnpModeData Pointer to the simple network mode data structure.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6GetModeData (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,\r
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
+ )\r
+{\r
+ IP6_PROTOCOL *IpInstance;\r
+ IP6_SERVICE *IpSb;\r
+ IP6_INTERFACE *IpIf;\r
+ EFI_IP6_CONFIG_DATA *Config;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+ IpIf = IpInstance->Interface;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Ip6ModeData != NULL) {\r
+ //\r
+ // IsStarted is "whether the EfiIp6Configure has been called".\r
+ // IsConfigured is "whether the station address has been configured"\r
+ //\r
+ Ip6ModeData->IsStarted = (BOOLEAN) (IpInstance->State == IP6_STATE_CONFIGED);\r
+ Ip6ModeData->MaxPacketSize = IpSb->MaxPacketSize;\r
+ CopyMem (&Ip6ModeData->ConfigData, &IpInstance->ConfigData, sizeof (EFI_IP6_CONFIG_DATA));\r
+ Ip6ModeData->IsConfigured = FALSE;\r
+\r
+ Ip6ModeData->AddressCount = 0;\r
+ Ip6ModeData->AddressList = NULL;\r
+\r
+ Ip6ModeData->GroupCount = IpInstance->GroupCount;\r
+ Ip6ModeData->GroupTable = NULL;\r
+\r
+ Ip6ModeData->RouteCount = 0;\r
+ Ip6ModeData->RouteTable = NULL;\r
+\r
+ Ip6ModeData->NeighborCount = 0;\r
+ Ip6ModeData->NeighborCache = NULL;\r
+\r
+ Ip6ModeData->PrefixCount = 0;\r
+ Ip6ModeData->PrefixTable = NULL;\r
+\r
+ Ip6ModeData->IcmpTypeCount = 23;\r
+ Ip6ModeData->IcmpTypeList = AllocateCopyPool (\r
+ Ip6ModeData->IcmpTypeCount * sizeof (EFI_IP6_ICMP_TYPE),\r
+ mIp6SupportedIcmp\r
+ );\r
+ if (Ip6ModeData->IcmpTypeList == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+\r
+ //\r
+ // Return the currently configured IPv6 addresses and corresponding prefix lengths.\r
+ //\r
+ Status = Ip6BuildEfiAddressList (\r
+ IpSb,\r
+ &Ip6ModeData->AddressCount,\r
+ &Ip6ModeData->AddressList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ //\r
+ // Return the current station address for this IP child.\r
+ // If UseAnyStationAddress is set to TRUE, IP6 driver will\r
+ // select a source address from its address list. Otherwise use the\r
+ // StationAddress in config data.\r
+ //\r
+ if (Ip6ModeData->IsStarted) {\r
+ Config = &Ip6ModeData->ConfigData;\r
+\r
+ if (IpIf->Configured || NetIp6IsUnspecifiedAddr (&Config->DestinationAddress)) {\r
+ Ip6ModeData->IsConfigured = TRUE;\r
+ } else {\r
+ Ip6ModeData->IsConfigured = FALSE;\r
+ }\r
+\r
+ //\r
+ // Build a EFI route table for user from the internal route table.\r
+ //\r
+ Status = Ip6BuildEfiRouteTable (\r
+ IpSb->RouteTable,\r
+ &Ip6ModeData->RouteCount,\r
+ &Ip6ModeData->RouteTable\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ }\r
+\r
+ if (Ip6ModeData->IsConfigured) {\r
+ //\r
+ // Return the joined multicast group addresses.\r
+ //\r
+ if (IpInstance->GroupCount != 0) {\r
+ Ip6ModeData->GroupTable = AllocateCopyPool (\r
+ IpInstance->GroupCount * sizeof (EFI_IPv6_ADDRESS),\r
+ IpInstance->GroupList\r
+ );\r
+ if (Ip6ModeData->GroupTable == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+ }\r
+ //\r
+ // Return the neighbor cache entries\r
+ //\r
+ Status = Ip6BuildEfiNeighborCache (\r
+ IpInstance,\r
+ &Ip6ModeData->NeighborCount,\r
+ &Ip6ModeData->NeighborCache\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ //\r
+ // Return the prefix table entries\r
+ //\r
+ Status = Ip6BuildPrefixTable (\r
+ IpInstance,\r
+ &Ip6ModeData->PrefixCount,\r
+ &Ip6ModeData->PrefixTable\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ }\r
+ }\r
+\r
+ //\r
+ // Get fresh mode data from MNP, since underlying media status may change\r
+ //\r
+ Status = IpSb->Mnp->GetModeData (IpSb->Mnp, MnpConfigData, SnpModeData);\r
+\r
+ goto Exit;\r
+\r
+Error:\r
+ if (Ip6ModeData != NULL) {\r
+ if (Ip6ModeData->AddressList != NULL) {\r
+ FreePool (Ip6ModeData->AddressList);\r
+ }\r
+\r
+ if (Ip6ModeData->GroupTable != NULL) {\r
+ FreePool (Ip6ModeData->GroupTable);\r
+ }\r
+\r
+ if (Ip6ModeData->RouteTable != NULL) {\r
+ FreePool (Ip6ModeData->RouteTable);\r
+ }\r
+\r
+ if (Ip6ModeData->NeighborCache != NULL) {\r
+ FreePool (Ip6ModeData->NeighborCache);\r
+ }\r
+\r
+ if (Ip6ModeData->PrefixTable != NULL) {\r
+ FreePool (Ip6ModeData->PrefixTable);\r
+ }\r
+\r
+ if (Ip6ModeData->IcmpTypeList != NULL) {\r
+ FreePool (Ip6ModeData->IcmpTypeList);\r
+ }\r
+ }\r
+\r
+Exit:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Validate that Ipv6 address is OK to be used as station address or next hop address/ neighbor.\r
+\r
+ @param[in] IpSb The IP6 service instance.\r
+ @param[in] Ip The IPv6 address to validate.\r
+ @param[in] Flag If TRUE, validate if the address is OK to be used\r
+ as station address. If FALSE, validate if the\r
+ address is OK to be used as the next hop address/\r
+ neighbor.\r
+\r
+ @retval TRUE The Ip address is valid and could be used.\r
+ @retval FALSE Invalid Ip address.\r
+\r
+**/\r
+BOOLEAN\r
+Ip6IsValidAddress (\r
+ IN IP6_SERVICE *IpSb,\r
+ IN EFI_IPv6_ADDRESS *Ip,\r
+ IN BOOLEAN Flag\r
+ )\r
+{\r
+ if (!NetIp6IsUnspecifiedAddr (Ip)) {\r
+ if (!NetIp6IsValidUnicast(Ip)) {\r
+ return FALSE;\r
+ }\r
+ if (Ip6IsOneOfSetAddress (IpSb, Ip, NULL, NULL)) {\r
+ return Flag;\r
+ }\r
+ } else {\r
+ return Flag;\r
+ }\r
+\r
+ return (BOOLEAN) !Flag;\r
+}\r
+\r
+/**\r
+ Validate whether the value of protocol is illegal or not. Protocol is the 'Next Header' field\r
+ in the last IPv6 extension header, or basic IPv6 header is there's no extension header.\r
+\r
+ @param[in] Protocol Default value of 'Next Header'\r
+\r
+ @retval TRUE The protocol is illegal.\r
+ @retval FALSE The protocol is legal.\r
+\r
+**/\r
+BOOLEAN\r
+Ip6IsIllegalProtocol (\r
+ IN UINT8 Protocol\r
+ )\r
+{\r
+ if (Protocol == IP6_HOP_BY_HOP || Protocol == EFI_IP_PROTO_ICMP || Protocol == IP4_PROTO_IGMP) {\r
+ return TRUE;\r
+ }\r
+\r
+ if (Protocol == 41 || Protocol == 43 || Protocol == 44 || Protocol == 59 || Protocol == 60 || Protocol == 124) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ Intiialize the IP6_PROTOCOL structure to the unconfigured states.\r
+\r
+ @param[in] IpSb The IP6 service instance.\r
+ @param[in, out] IpInstance The IP6 child instance.\r
+\r
+**/\r
+VOID\r
+Ip6InitProtocol (\r
+ IN IP6_SERVICE *IpSb,\r
+ IN OUT IP6_PROTOCOL *IpInstance\r
+ )\r
+{\r
+ ASSERT ((IpSb != NULL) && (IpInstance != NULL));\r
+\r
+ ZeroMem (IpInstance, sizeof (IP6_PROTOCOL));\r
+\r
+ IpInstance->Signature = IP6_PROTOCOL_SIGNATURE;\r
+ IpInstance->State = IP6_STATE_UNCONFIGED;\r
+ IpInstance->Service = IpSb;\r
+ IpInstance->GroupList = NULL;\r
+ CopyMem (&IpInstance->Ip6Proto, &mEfiIp6ProtocolTemplete, sizeof (EFI_IP6_PROTOCOL));\r
+\r
+ NetMapInit (&IpInstance->RxTokens);\r
+ NetMapInit (&IpInstance->TxTokens);\r
+ InitializeListHead (&IpInstance->Received);\r
+ InitializeListHead (&IpInstance->Delivered);\r
+\r
+ EfiInitializeLock (&IpInstance->RecycleLock, TPL_NOTIFY);\r
+}\r
+\r
+/**\r
+ Configure the IP6 child. If the child is already configured,\r
+ change the configuration parameter. Otherwise, configure it\r
+ for the first time. The caller should validate the configuration\r
+ before deliver them to it. It also don't do configure NULL.\r
+\r
+ @param[in, out] IpInstance The IP6 child to configure.\r
+ @param[in] Config The configure data.\r
+\r
+ @retval EFI_SUCCESS The IP6 child is successfully configured.\r
+ @retval EFI_DEVICE_ERROR Failed to free the pending transive or to\r
+ configure underlying MNP, or other errors.\r
+ @retval EFI_NO_MAPPING The IP6 child is configured to use the default\r
+ address, but the default address hasn't been\r
+ configured. The IP6 child doesn't need to be\r
+ reconfigured when the default address is configured.\r
+ @retval EFI_OUT_OF_RESOURCES No more memory space is available.\r
+ @retval other Other error occurs.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip6ConfigProtocol (\r
+ IN OUT IP6_PROTOCOL *IpInstance,\r
+ IN EFI_IP6_CONFIG_DATA *Config\r
+ )\r
+{\r
+ IP6_SERVICE *IpSb;\r
+ IP6_INTERFACE *IpIf;\r
+ EFI_STATUS Status;\r
+ EFI_IP6_CONFIG_DATA *Current;\r
+ IP6_ADDRESS_INFO *AddressInfo;\r
+ BOOLEAN StationZero;\r
+ BOOLEAN DestZero;\r
+ EFI_IPv6_ADDRESS Source;\r
+ BOOLEAN AddrOk;\r
+\r
+ IpSb = IpInstance->Service;\r
+ Current = &IpInstance->ConfigData;\r
+\r
+ //\r
+ // User is changing packet filters. It must be stopped\r
+ // before the station address can be changed.\r
+ //\r
+ if (IpInstance->State == IP6_STATE_CONFIGED) {\r
+ //\r
+ // Cancel all the pending transmit/receive from upper layer\r
+ //\r
+ Status = Ip6Cancel (IpInstance, NULL);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ CopyMem (Current, Config, sizeof (EFI_IP6_CONFIG_DATA));\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ //\r
+ // Set up the interface.\r
+ //\r
+ StationZero = NetIp6IsUnspecifiedAddr (&Config->StationAddress);\r
+ DestZero = NetIp6IsUnspecifiedAddr (&Config->DestinationAddress);\r
+\r
+ if (StationZero && DestZero) {\r
+ //\r
+ // StationAddress is still zero.\r
+ //\r
+\r
+ NET_GET_REF (IpSb->DefaultInterface);\r
+ IpInstance->Interface = IpSb->DefaultInterface;\r
+ InsertTailList (&IpSb->DefaultInterface->IpInstances, &IpInstance->AddrLink);\r
+\r
+ CopyMem (Current, Config, sizeof (EFI_IP6_CONFIG_DATA));\r
+ IpInstance->State = IP6_STATE_CONFIGED;\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ if (StationZero && !DestZero) {\r
+ Status = Ip6SelectSourceAddress (IpSb, &Config->DestinationAddress, &Source);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ } else {\r
+ IP6_COPY_ADDRESS (&Source, &Config->StationAddress);\r
+ }\r
+\r
+ AddrOk = Ip6IsOneOfSetAddress (IpSb, &Source, &IpIf, &AddressInfo);\r
+ if (AddrOk) {\r
+ if (AddressInfo != NULL) {\r
+ IpInstance->PrefixLength = AddressInfo->PrefixLength;\r
+ } else {\r
+ IpInstance->PrefixLength = IP6_LINK_LOCAL_PREFIX_LENGTH;\r
+ }\r
+ } else {\r
+ //\r
+ // The specified source address is not one of the addresses IPv6 maintains.\r
+ //\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+\r
+ NET_GET_REF (IpIf);\r
+ IpInstance->Interface = IpIf;\r
+ InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);\r
+\r
+ CopyMem (Current, Config, sizeof (EFI_IP6_CONFIG_DATA));\r
+ IP6_COPY_ADDRESS (&Current->StationAddress, &Source);\r
+ IpInstance->State = IP6_STATE_CONFIGED;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Clean up the IP6 child, and release all the resources used by it.\r
+\r
+ @param[in, out] IpInstance The IP6 child to clean up.\r
+\r
+ @retval EFI_SUCCESS The IP6 child is cleaned up.\r
+ @retval EFI_DEVICE_ERROR Some resources failed to be released.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip6CleanProtocol (\r
+ IN OUT IP6_PROTOCOL *IpInstance\r
+ )\r
+{\r
+ if (EFI_ERROR (Ip6Cancel (IpInstance, NULL))) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ if (EFI_ERROR (Ip6Groups (IpInstance, FALSE, NULL))) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ //\r
+ // Some packets haven't been recycled. It is because either the\r
+ // user forgets to recycle the packets, or because the callback\r
+ // hasn't been called. Just leave it alone.\r
+ //\r
+ if (!IsListEmpty (&IpInstance->Delivered)) {\r
+ ;\r
+ }\r
+\r
+ if (IpInstance->Interface != NULL) {\r
+ RemoveEntryList (&IpInstance->AddrLink);\r
+ Ip6CleanInterface (IpInstance->Interface, IpInstance);\r
+ IpInstance->Interface = NULL;\r
+ }\r
+\r
+ if (IpInstance->GroupList != NULL) {\r
+ FreePool (IpInstance->GroupList);\r
+ IpInstance->GroupList = NULL;\r
+ IpInstance->GroupCount = 0;\r
+ }\r
+\r
+ NetMapClean (&IpInstance->TxTokens);\r
+\r
+ NetMapClean (&IpInstance->RxTokens);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Configure the MNP parameter used by IP. The IP driver uses one MNP\r
+ child to transmit/receive frames. By default, it configures MNP\r
+ to receive unicast/multicast/broadcast. Also, it will enable/disable\r
+ the promiscuous receive according to whether there is IP child\r
+ enable that or not. If Force is FALSE, it will iterate through\r
+ all the IP children to check whether the promiscuous receive\r
+ setting has been changed. If it hasn't been changed, it won't\r
+ reconfigure the MNP. If Force is TRUE, the MNP is configured\r
+ whether that is changed or not.\r
+\r
+ @param[in] IpSb The IP6 service instance that is to be changed.\r
+ @param[in] Force Force the configuration or not.\r
+\r
+ @retval EFI_SUCCESS The MNP successfully configured/reconfigured.\r
+ @retval Others Configuration failed.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip6ServiceConfigMnp (\r
+ IN IP6_SERVICE *IpSb,\r
+ IN BOOLEAN Force\r
+ )\r
+{\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *ProtoEntry;\r
+ IP6_INTERFACE *IpIf;\r
+ IP6_PROTOCOL *IpInstance;\r
+ BOOLEAN Reconfig;\r
+ BOOLEAN PromiscReceive;\r
+ EFI_STATUS Status;\r
+\r
+ Reconfig = FALSE;\r
+ PromiscReceive = FALSE;\r
+\r
+ if (!Force) {\r
+ //\r
+ // Iterate through the IP children to check whether promiscuous\r
+ // receive setting has been changed. Update the interface's receive\r
+ // filter also.\r
+ //\r
+ NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {\r
+\r
+ IpIf = NET_LIST_USER_STRUCT (Entry, IP6_INTERFACE, Link);\r
+ IpIf->PromiscRecv = FALSE;\r
+\r
+ NET_LIST_FOR_EACH (ProtoEntry, &IpIf->IpInstances) {\r
+ IpInstance = NET_LIST_USER_STRUCT (ProtoEntry, IP6_PROTOCOL, AddrLink);\r
+\r
+ if (IpInstance->ConfigData.AcceptPromiscuous) {\r
+ IpIf->PromiscRecv = TRUE;\r
+ PromiscReceive = TRUE;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // If promiscuous receive isn't changed, it isn't necessary to reconfigure.\r
+ //\r
+ if (PromiscReceive == IpSb->MnpConfigData.EnablePromiscuousReceive) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Reconfig = TRUE;\r
+ IpSb->MnpConfigData.EnablePromiscuousReceive = PromiscReceive;\r
+ }\r
+\r
+ Status = IpSb->Mnp->Configure (IpSb->Mnp, &IpSb->MnpConfigData);\r
+\r
+ //\r
+ // recover the original configuration if failed to set the configure.\r
+ //\r
+ if (EFI_ERROR (Status) && Reconfig) {\r
+ IpSb->MnpConfigData.EnablePromiscuousReceive = (BOOLEAN) !PromiscReceive;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Assigns an IPv6 address and subnet mask to this EFI IPv6 Protocol driver instance.\r
+\r
+ The Configure() function is used to set, change, or reset the operational parameters and filter\r
+ settings for this EFI IPv6 Protocol instance. Until these parameters have been set, no network traffic\r
+ can be sent or received by this instance. Once the parameters have been reset (by calling this\r
+ function with Ip6ConfigData set to NULL), no more traffic can be sent or received until these\r
+ parameters have been set again. Each EFI IPv6 Protocol instance can be started and stopped\r
+ independently of each other by enabling or disabling their receive filter settings with the\r
+ Configure() function.\r
+\r
+ If Ip6ConfigData.StationAddress is a valid non-zero IPv6 unicast address, it is required\r
+ to be one of the currently configured IPv6 addresses listed in the EFI IPv6 drivers, or else\r
+ EFI_INVALID_PARAMETER will be returned. If Ip6ConfigData.StationAddress is\r
+ unspecified, the IPv6 driver will bind a source address according to the source address selection\r
+ algorithm. Clients could frequently call GetModeData() to check get currently configured IPv6\r
+ address list in the EFI IPv6 driver. If both Ip6ConfigData.StationAddress and\r
+ Ip6ConfigData.Destination are unspecified, when transmitting the packet afterwards, the\r
+ source address filled in each outgoing IPv6 packet is decided based on the destination of this packet.\r
+\r
+ If operational parameters are reset or changed, any pending transmit and receive requests will be\r
+ cancelled. Their completion token status will be set to EFI_ABORTED and their events will be\r
+ signaled.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] Ip6ConfigData Pointer to the EFI IPv6 Protocol configuration data structure.\r
+ If NULL, reset the configuration data.\r
+\r
+ @retval EFI_SUCCESS The driver instance was successfully opened.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - Ip6ConfigData.StationAddress is neither zero nor\r
+ a unicast IPv6 address.\r
+ - Ip6ConfigData.StationAddress is neither zero nor\r
+ one of the configured IP addresses in the EFI IPv6 driver.\r
+ - Ip6ConfigData.DefaultProtocol is illegal.\r
+ @retval EFI_OUT_OF_RESOURCES The EFI IPv6 Protocol driver instance data could not be allocated.\r
+ @retval EFI_NO_MAPPING The IPv6 driver was responsible for choosing a source address for\r
+ this instance, but no source address was available for use.\r
+ @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the IPv6\r
+ address or prefix length can be changed.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv6\r
+ Protocol driver instance was not opened.\r
+ @retval EFI_UNSUPPORTED Default protocol specified through\r
+ Ip6ConfigData.DefaulProtocol isn't supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Configure (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL\r
+ )\r
+{\r
+ IP6_PROTOCOL *IpInstance;\r
+ EFI_IP6_CONFIG_DATA *Current;\r
+ EFI_TPL OldTpl;\r
+ EFI_STATUS Status;\r
+ IP6_SERVICE *IpSb;\r
+\r
+ //\r
+ // First, validate the parameters\r
+ //\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ Status = EFI_INVALID_PARAMETER;\r
+\r
+ //\r
+ // Validate the configuration first.\r
+ //\r
+ if (Ip6ConfigData != NULL) {\r
+ //\r
+ // Check whether the station address is valid.\r
+ //\r
+ if (!Ip6IsValidAddress (IpSb, &Ip6ConfigData->StationAddress, TRUE)) {\r
+ goto Exit;\r
+ }\r
+ //\r
+ // Check whether the default protocol is valid.\r
+ //\r
+ if (Ip6IsIllegalProtocol (Ip6ConfigData->DefaultProtocol)) {\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // User can only update packet filters when already configured.\r
+ // If it wants to change the station address, it must configure(NULL)\r
+ // the instance firstly.\r
+ //\r
+ if (IpInstance->State == IP6_STATE_CONFIGED) {\r
+ Current = &IpInstance->ConfigData;\r
+\r
+ if (!EFI_IP6_EQUAL (&Current->StationAddress, &Ip6ConfigData->StationAddress)) {\r
+ Status = EFI_ALREADY_STARTED;\r
+ goto Exit;\r
+ }\r
+\r
+ if (NetIp6IsUnspecifiedAddr (&Current->StationAddress) && IP6_NO_MAPPING (IpInstance)) {\r
+ Status = EFI_NO_MAPPING;\r
+ goto Exit;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // Configure the instance or clean it up.\r
+ //\r
+ if (Ip6ConfigData != NULL) {\r
+ Status = Ip6ConfigProtocol (IpInstance, Ip6ConfigData);\r
+ } else {\r
+ Status = Ip6CleanProtocol (IpInstance);\r
+\r
+ //\r
+ // Don't change the state if it is DESTORY, consider the following\r
+ // valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,\r
+ // Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,\r
+ // the unload fails miserably.\r
+ //\r
+ if (IpInstance->State == IP6_STATE_CONFIGED) {\r
+ IpInstance->State = IP6_STATE_UNCONFIGED;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Update the MNP's configure data. Ip6ServiceConfigMnp will check\r
+ // whether it is necessary to reconfigure the MNP.\r
+ //\r
+ Ip6ServiceConfigMnp (IpInstance->Service, FALSE);\r
+\r
+ //\r
+ // Update the variable data.\r
+ //\r
+ Ip6SetVariableData (IpInstance->Service);\r
+\r
+Exit:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Joins and leaves multicast groups.\r
+\r
+ The Groups() function is used to join and leave multicast group sessions. Joining a group will\r
+ enable reception of matching multicast packets. Leaving a group will disable reception of matching\r
+ multicast packets. Source-Specific Multicast isn't required to be supported.\r
+\r
+ If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] JoinFlag Set to TRUE to join the multicast group session, and FALSE to leave.\r
+ @param[in] GroupAddress Pointer to the IPv6 multicast address.\r
+ This is an optional parameter that may be NULL.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:\r
+ - This is NULL.\r
+ - JoinFlag is TRUE and GroupAddress is NULL.\r
+ - GroupAddress is not NULL and *GroupAddress is\r
+ not a multicast IPv6 address.\r
+ - GroupAddress is not NULL and *GroupAddress is in the\r
+ range of SSM destination address.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.\r
+ @retval EFI_UNSUPPORTED This EFI IPv6 Protocol implementation does not support multicast groups.\r
+ @retval EFI_ALREADY_STARTED The group address is already in the group table (when\r
+ JoinFlag is TRUE).\r
+ @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Groups (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN BOOLEAN JoinFlag,\r
+ IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL\r
+ )\r
+{\r
+ EFI_TPL OldTpl;\r
+ EFI_STATUS Status;\r
+ IP6_PROTOCOL *IpInstance;\r
+ IP6_SERVICE *IpSb;\r
+\r
+ if ((This == NULL) || (JoinFlag && GroupAddress == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (GroupAddress != NULL && !IP6_IS_MULTICAST (GroupAddress)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ if (IpInstance->State != IP6_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Status = Ip6Groups (IpInstance, JoinFlag, GroupAddress);\r
+\r
+ON_EXIT:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Adds and deletes routing table entries.\r
+\r
+ The Routes() function adds a route to, or deletes a route from, the routing table.\r
+\r
+ Routes are determined by comparing the leftmost PrefixLength bits of Destination with\r
+ the destination IPv6 address arithmetically. The gateway address must be on the same subnet as the\r
+ configured station address.\r
+\r
+ The default route is added with Destination and PrefixLegth both set to all zeros. The\r
+ default route matches all destination IPv6 addresses that do not match any other routes.\r
+\r
+ All EFI IPv6 Protocol instances share a routing table.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] DeleteRoute Set to TRUE to delete this route from the routing table. Set to\r
+ FALSE to add this route to the routing table. Destination,\r
+ PrefixLength and Gateway are used as the key to each\r
+ route entry.\r
+ @param[in] Destination The address prefix of the subnet that needs to be routed.\r
+ This is an optional parameter that may be NULL.\r
+ @param[in] PrefixLength The prefix length of Destination. Ignored if Destination\r
+ is NULL.\r
+ @param[in] GatewayAddress The unicast gateway IPv6 address for this route.\r
+ This is an optional parameter that may be NULL.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_NOT_STARTED The driver instance has not been started.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - When DeleteRoute is TRUE, both Destination and\r
+ GatewayAddress are NULL.\r
+ - When DeleteRoute is FALSE, either Destination or\r
+ GatewayAddress is NULL.\r
+ - *GatewayAddress is not a valid unicast IPv6 address.\r
+ - *GatewayAddress is one of the local configured IPv6\r
+ addresses.\r
+ @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.\r
+ @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).\r
+ @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when\r
+ DeleteRoute is FALSE).\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Routes (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN BOOLEAN DeleteRoute,\r
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,\r
+ IN UINT8 PrefixLength,\r
+ IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL\r
+ )\r
+{\r
+ IP6_PROTOCOL *IpInstance;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+ IP6_SERVICE *IpSb;\r
+\r
+ if ((This == NULL) || (PrefixLength >= IP6_PREFIX_NUM)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ if (IpInstance->State != IP6_STATE_CONFIGED) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ if (DeleteRoute && (Destination == NULL) && (GatewayAddress == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (!DeleteRoute && (Destination == NULL || GatewayAddress == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (GatewayAddress != NULL) {\r
+ if (!Ip6IsValidAddress (IpSb, GatewayAddress, FALSE)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (!NetIp6IsUnspecifiedAddr (GatewayAddress) &&\r
+ !NetIp6IsNetEqual (GatewayAddress, &IpInstance->ConfigData.StationAddress, PrefixLength)\r
+ ) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ //\r
+ // Update the route table\r
+ //\r
+ if (DeleteRoute) {\r
+ Status = Ip6DelRoute (IpSb->RouteTable, Destination, PrefixLength, GatewayAddress);\r
+ } else {\r
+ Status = Ip6AddRoute (IpSb->RouteTable, Destination, PrefixLength, GatewayAddress);\r
+ }\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Add or delete Neighbor cache entries.\r
+\r
+ The Neighbors() function is used to add, update, or delete an entry from neighbor cache.\r
+ IPv6 neighbor cache entries are typically inserted and updated by the network protocol driver as\r
+ network traffic is processed. Most neighbor cache entries will timeout and be deleted if the network\r
+ traffic stops. Neighbor cache entries that were inserted by Neighbors() may be static (will not\r
+ timeout) or dynamic (will timeout).\r
+\r
+ The implementation should follow the neighbor cache timeout mechanism which is defined in\r
+ RFC4861. The default neighbor cache timeout value should be tuned for the expected network\r
+ environment\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] DeleteFlag Set to TRUE to delete the specified cache entry, set to FALSE to\r
+ add (or update, if it already exists and Override is TRUE) the\r
+ specified cache entry. TargetIp6Address is used as the key\r
+ to find the requested cache entry.\r
+ @param[in] TargetIp6Address Pointer to the Target IPv6 address.\r
+ @param[in] TargetLinkAddress Pointer to the link-layer address of the target. Ignored if NULL.\r
+ @param[in] Timeout Time in 100-ns units that this entry will remain in the neighbor\r
+ cache, it will be deleted after Timeout. A value of zero means that\r
+ the entry is permanent. A non-zero value means that the entry is\r
+ dynamic.\r
+ @param[in] Override If TRUE, the cached link-layer address of the matching entry will\r
+ be overridden and updated; if FALSE, EFI_ACCESS_DENIED\r
+ will be returned if a corresponding cache entry already existed.\r
+\r
+ @retval EFI_SUCCESS The data has been queued for transmission.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - TargetIpAddress is NULL.\r
+ - *TargetLinkAddress is invalid when not NULL.\r
+ - *TargetIpAddress is not a valid unicast IPv6 address.\r
+ - *TargetIpAddress is one of the local configured IPv6\r
+ addresses.\r
+ @retval EFI_OUT_OF_RESOURCES Could not add the entry to the neighbor cache.\r
+ @retval EFI_NOT_FOUND This entry is not in the neighbor cache (when DeleteFlag is\r
+ TRUE or when DeleteFlag is FALSE while\r
+ TargetLinkAddress is NULL.).\r
+ @retval EFI_ACCESS_DENIED The to-be-added entry is already defined in the neighbor cache,\r
+ and that entry is tagged as un-overridden (when Override\r
+ is FALSE).\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Neighbors (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN BOOLEAN DeleteFlag,\r
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,\r
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,\r
+ IN UINT32 Timeout,\r
+ IN BOOLEAN Override\r
+ )\r
+{\r
+ EFI_TPL OldTpl;\r
+ EFI_STATUS Status;\r
+ IP6_PROTOCOL *IpInstance;\r
+ IP6_SERVICE *IpSb;\r
+\r
+ if (This == NULL || TargetIp6Address == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (NetIp6IsUnspecifiedAddr (TargetIp6Address)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ if (!Ip6IsValidAddress (IpSb, TargetIp6Address, FALSE)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (TargetLinkAddress != NULL) {\r
+ if (!Ip6IsValidLinkAddress (IpSb, TargetLinkAddress)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+\r
+ if (Ip6IsOneOfSetAddress (IpSb, TargetIp6Address, NULL, NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ if (IpInstance->State != IP6_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto Exit;\r
+ }\r
+\r
+ if (DeleteFlag) {\r
+ Status = Ip6DelNeighbor (IpInstance->Service, TargetIp6Address, TargetLinkAddress, Timeout, Override);\r
+ } else {\r
+ Status = Ip6AddNeighbor (IpInstance->Service, TargetIp6Address, TargetLinkAddress, Timeout, Override);\r
+ }\r
+\r
+Exit:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Check whether the user's token or event has already\r
+ been enqueue on IP6's list.\r
+\r
+ @param[in] Map The container of either user's transmit or receive\r
+ token.\r
+ @param[in] Item Current item to check against.\r
+ @param[in] Context The Token to check againist.\r
+\r
+ @retval EFI_ACCESS_DENIED The token or event has already been enqueued in IP\r
+ @retval EFI_SUCCESS The current item isn't the same token/event as the\r
+ context.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip6TokenExist (\r
+ IN NET_MAP *Map,\r
+ IN NET_MAP_ITEM *Item,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_IP6_COMPLETION_TOKEN *Token;\r
+ EFI_IP6_COMPLETION_TOKEN *TokenInItem;\r
+\r
+ Token = (EFI_IP6_COMPLETION_TOKEN *) Context;\r
+ TokenInItem = (EFI_IP6_COMPLETION_TOKEN *) Item->Key;\r
+\r
+ if (Token == TokenInItem || Token->Event == TokenInItem->Event) {\r
+ return EFI_ACCESS_DENIED;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Validate the user's token against the current station address.\r
+\r
+ @param[in] Token User's token to validate.\r
+\r
+ @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r
+ @retval EFI_BAD_BUFFER_SIZE The user's option/data is too long.\r
+ @retval EFI_SUCCESS The token is OK.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip6TxTokenValid (\r
+ IN EFI_IP6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ EFI_IP6_TRANSMIT_DATA *TxData;\r
+ UINT32 Index;\r
+ UINT32 DataLength;\r
+\r
+ if (Token == NULL || Token->Event == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ TxData = Token->Packet.TxData;\r
+\r
+ if (TxData == NULL || (TxData->ExtHdrsLength != 0 && TxData->ExtHdrs == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (TxData->FragmentCount == 0 || TxData->DataLength == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ for (DataLength = 0, Index = 0; Index < TxData->FragmentCount; Index++) {\r
+ if (TxData->FragmentTable[Index].FragmentLength == 0 || TxData->FragmentTable[Index].FragmentBuffer == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ DataLength += TxData->FragmentTable[Index].FragmentLength;\r
+ }\r
+\r
+ if (TxData->DataLength != DataLength) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // TODO: Token.Packet.TxData.DataLength is too short to transmit.\r
+ // return EFI_BUFFER_TOO_SMALL;\r
+ //\r
+\r
+ //\r
+ // If Token.Packet.TxData.DataLength is beyond the maximum that which can be\r
+ // described through the Fragment Offset field in Fragment header when performing\r
+ // fragmentation.\r
+ //\r
+ if (TxData->DataLength > 64 * 1024) {\r
+ return EFI_BAD_BUFFER_SIZE;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ The callback function for the net buffer which wraps the user's\r
+ transmit token. Although this function seems simple, there\r
+ are some subtle aspects.\r
+ When user requests the IP to transmit a packet by passing it a\r
+ token, the token is wrapped in an IP6_TXTOKEN_WRAP and the data\r
+ is wrapped in an net buffer. The net buffer's Free function is\r
+ set to Ip6FreeTxToken. The Token and token wrap are added to the\r
+ IP child's TxToken map. Then the buffer is passed to Ip6Output for\r
+ transmission. If an error happened before that, the buffer\r
+ is freed, which in turn frees the token wrap. The wrap may\r
+ have been added to the TxToken map or not, and the user's event\r
+ shouldn't be fired because we are still in the EfiIp6Transmit. If\r
+ the buffer has been sent by Ip6Output, it should be removed from\r
+ the TxToken map and user's event signaled. The token wrap and buffer\r
+ are bound together. Check the comments in Ip6Output for information\r
+ about IP fragmentation.\r
+\r
+ @param[in] Context The token's wrap.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Ip6FreeTxToken (\r
+ IN VOID *Context\r
+ )\r
+{\r
+ IP6_TXTOKEN_WRAP *Wrap;\r
+ NET_MAP_ITEM *Item;\r
+\r
+ Wrap = (IP6_TXTOKEN_WRAP *) Context;\r
+\r
+ //\r
+ // Signal IpSecRecycleEvent to inform IPsec free the memory\r
+ //\r
+ if (Wrap->IpSecRecycleSignal != NULL) {\r
+ gBS->SignalEvent (Wrap->IpSecRecycleSignal);\r
+ }\r
+\r
+ //\r
+ // Find the token in the instance's map. EfiIp6Transmit put the\r
+ // token to the map. If that failed, NetMapFindKey will return NULL.\r
+ //\r
+ Item = NetMapFindKey (&Wrap->IpInstance->TxTokens, Wrap->Token);\r
+\r
+ if (Item != NULL) {\r
+ NetMapRemoveItem (&Wrap->IpInstance->TxTokens, Item, NULL);\r
+ }\r
+\r
+ if (Wrap->Sent) {\r
+ gBS->SignalEvent (Wrap->Token->Event);\r
+\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of Token->Event.\r
+ //\r
+ DispatchDpc ();\r
+ }\r
+\r
+ FreePool (Wrap);\r
+}\r
+\r
+\r
+/**\r
+ The callback function to Ip6Output to update the transmit status.\r
+\r
+ @param[in] Packet The user's transmit packet.\r
+ @param[in] IoStatus The result of the transmission.\r
+ @param[in] Flag Not used during transmission.\r
+ @param[in] Context The token's wrap.\r
+\r
+**/\r
+VOID\r
+Ip6OnPacketSent (\r
+ IN NET_BUF *Packet,\r
+ IN EFI_STATUS IoStatus,\r
+ IN UINT32 Flag,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ IP6_TXTOKEN_WRAP *Wrap;\r
+\r
+ //\r
+ // This is the transmission request from upper layer,\r
+ // not the IP6 driver itself.\r
+ //\r
+ Wrap = (IP6_TXTOKEN_WRAP *) Context;\r
+ Wrap->Token->Status = IoStatus;\r
+\r
+ NetbufFree (Wrap->Packet);\r
+}\r
+\r
+/**\r
+ Places outgoing data packets into the transmit queue.\r
+\r
+ The Transmit() function places a sending request in the transmit queue of this\r
+ EFI IPv6 Protocol instance. Whenever the packet in the token is sent out or some\r
+ errors occur, the event in the token will be signaled, and the status is updated.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to the transmit token.\r
+\r
+ @retval EFI_SUCCESS The data has been queued for transmission.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_NO_MAPPING The IPv6 driver was responsible for choosing\r
+ a source address for this transmission,\r
+ but no source address was available for use.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:\r
+ - This is NULL.\r
+ - Token is NULL.\r
+ - Token.Event is NULL.\r
+ - Token.Packet.TxData is NULL.\r
+ - Token.Packet.ExtHdrsLength is not zero and\r
+ Token.Packet.ExtHdrs is NULL.\r
+ - Token.Packet.FragmentCount is zero.\r
+ - One or more of the Token.Packet.TxData.\r
+ FragmentTable[].FragmentLength fields is zero.\r
+ - One or more of the Token.Packet.TxData.\r
+ FragmentTable[].FragmentBuffer fields is NULL.\r
+ - Token.Packet.TxData.DataLength is zero or not\r
+ equal to the sum of fragment lengths.\r
+ - Token.Packet.TxData.DestinationAddress is non\r
+ zero when DestinationAddress is configured as\r
+ non-zero when doing Configure() for this\r
+ EFI IPv6 protocol instance.\r
+ - Token.Packet.TxData.DestinationAddress is\r
+ unspecified when DestinationAddress is unspecified\r
+ when doing Configure() for this EFI IPv6 protocol\r
+ instance.\r
+ @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.\r
+ Event was already in the transmit queue.\r
+ @retval EFI_NOT_READY The completion token could not be queued because\r
+ the transmit queue is full.\r
+ @retval EFI_NOT_FOUND Not route is found to destination address.\r
+ @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.\r
+ @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too\r
+ short to transmit.\r
+ @retval EFI_BAD_BUFFER_SIZE If Token.Packet.TxData.DataLength is beyond the\r
+ maximum that which can be described through the\r
+ Fragment Offset field in Fragment header when\r
+ performing fragmentation.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Transmit (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN EFI_IP6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ IP6_SERVICE *IpSb;\r
+ IP6_PROTOCOL *IpInstance;\r
+ EFI_IP6_CONFIG_DATA *Config;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+ EFI_IP6_HEADER Head;\r
+ EFI_IP6_TRANSMIT_DATA *TxData;\r
+ EFI_IP6_OVERRIDE_DATA *Override;\r
+ IP6_TXTOKEN_WRAP *Wrap;\r
+ UINT8 *ExtHdrs;\r
+\r
+ //\r
+ // Check input parameters.\r
+ //\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ ExtHdrs = NULL;\r
+\r
+ Status = Ip6TxTokenValid (Token);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ if (IpInstance->State != IP6_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto Exit;\r
+ }\r
+\r
+ Config = &IpInstance->ConfigData;\r
+\r
+ //\r
+ // Check whether the token or signal already existed.\r
+ //\r
+ if (EFI_ERROR (NetMapIterate (&IpInstance->TxTokens, Ip6TokenExist, Token))) {\r
+ Status = EFI_ACCESS_DENIED;\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // Build the IP header, fill in the information from ConfigData or OverrideData\r
+ //\r
+ ZeroMem (&Head, sizeof(EFI_IP6_HEADER));\r
+ TxData = Token->Packet.TxData;\r
+ IP6_COPY_ADDRESS (&Head.SourceAddress, &Config->StationAddress);\r
+ IP6_COPY_ADDRESS (&Head.DestinationAddress, &Config->DestinationAddress);\r
+\r
+ Status = EFI_INVALID_PARAMETER;\r
+\r
+ if (NetIp6IsUnspecifiedAddr (&TxData->DestinationAddress)) {\r
+ if (NetIp6IsUnspecifiedAddr (&Config->DestinationAddress)) {\r
+ goto Exit;\r
+ }\r
+\r
+ ASSERT (!NetIp6IsUnspecifiedAddr (&Config->StationAddress));\r
+\r
+ } else {\r
+ //\r
+ // StationAddress is unspecified only when ConfigData.Dest is unspecified.\r
+ // Use TxData.Dest to override the DestinationAddress.\r
+ //\r
+ if (!NetIp6IsUnspecifiedAddr (&Config->DestinationAddress)) {\r
+ goto Exit;\r
+ }\r
+\r
+ if (NetIp6IsUnspecifiedAddr (&Config->StationAddress)) {\r
+ Status = Ip6SelectSourceAddress (\r
+ IpSb,\r
+ &TxData->DestinationAddress,\r
+ &Head.SourceAddress\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Exit;\r
+ }\r
+ }\r
+\r
+ IP6_COPY_ADDRESS (&Head.DestinationAddress, &TxData->DestinationAddress);\r
+ }\r
+\r
+ //\r
+ // Fill in Head infos.\r
+ //\r
+ Head.NextHeader = Config->DefaultProtocol;\r
+ if (TxData->ExtHdrsLength != 0) {\r
+ Head.NextHeader = TxData->NextHeader;\r
+ }\r
+\r
+ if (TxData->OverrideData != NULL) {\r
+ Override = TxData->OverrideData;\r
+ Head.NextHeader = Override->Protocol;\r
+ Head.HopLimit = Override->HopLimit;\r
+ Head.FlowLabelL = HTONS ((UINT16) Override->FlowLabel);\r
+ Head.FlowLabelH = (UINT8) ((Override->FlowLabel >> 16) & 0x0F);\r
+ } else {\r
+ Head.HopLimit = Config->HopLimit;\r
+ Head.FlowLabelL = HTONS ((UINT16) Config->FlowLabel);\r
+ Head.FlowLabelH = (UINT8) ((Config->FlowLabel >> 16) & 0x0F);\r
+ }\r
+\r
+ Head.PayloadLength = HTONS ((UINT16) (TxData->ExtHdrsLength + TxData->DataLength));\r
+\r
+ //\r
+ // OK, it survives all the validation check. Wrap the token in\r
+ // a IP6_TXTOKEN_WRAP and the data in a netbuf\r
+ //\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ Wrap = AllocateZeroPool (sizeof (IP6_TXTOKEN_WRAP));\r
+ if (Wrap == NULL) {\r
+ goto Exit;\r
+ }\r
+\r
+ Wrap->IpInstance = IpInstance;\r
+ Wrap->Token = Token;\r
+ Wrap->Sent = FALSE;\r
+ Wrap->Life = IP6_US_TO_SEC (Config->TransmitTimeout);\r
+ Wrap->Packet = NetbufFromExt (\r
+ (NET_FRAGMENT *) TxData->FragmentTable,\r
+ TxData->FragmentCount,\r
+ IP6_MAX_HEADLEN,\r
+ 0,\r
+ Ip6FreeTxToken,\r
+ Wrap\r
+ );\r
+\r
+ if (Wrap->Packet == NULL) {\r
+ FreePool (Wrap);\r
+ goto Exit;\r
+ }\r
+\r
+ Token->Status = EFI_NOT_READY;\r
+\r
+ Status = NetMapInsertTail (&IpInstance->TxTokens, Token, Wrap);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // NetbufFree will call Ip6FreeTxToken, which in turn will\r
+ // free the IP6_TXTOKEN_WRAP. Now, the token wrap hasn't been\r
+ // enqueued.\r
+ //\r
+ NetbufFree (Wrap->Packet);\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // Allocate a new buffer to store IPv6 extension headers to avoid updating\r
+ // the original data in EFI_IP6_COMPLETION_TOKEN.\r
+ //\r
+ if (TxData->ExtHdrsLength != 0 && TxData->ExtHdrs != NULL) {\r
+ ExtHdrs = (UINT8 *) AllocateCopyPool (TxData->ExtHdrsLength, TxData->ExtHdrs);\r
+ if (ExtHdrs == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Mark the packet sent before output it. Mark it not sent again if the\r
+ // returned status is not EFI_SUCCESS;\r
+ //\r
+ Wrap->Sent = TRUE;\r
+\r
+ Status = Ip6Output (\r
+ IpSb,\r
+ NULL,\r
+ IpInstance,\r
+ Wrap->Packet,\r
+ &Head,\r
+ ExtHdrs,\r
+ TxData->ExtHdrsLength,\r
+ Ip6OnPacketSent,\r
+ Wrap\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Wrap->Sent = FALSE;\r
+ NetbufFree (Wrap->Packet);\r
+ }\r
+\r
+Exit:\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ if (ExtHdrs != NULL) {\r
+ FreePool (ExtHdrs);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Places a receiving request into the receiving queue.\r
+\r
+ The Receive() function places a completion token into the receive packet queue.\r
+ This function is always asynchronous.\r
+\r
+ The Token.Event field in the completion token must be filled in by the caller\r
+ and cannot be NULL. When the receive operation completes, the EFI IPv6 Protocol\r
+ driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event\r
+ is signaled.\r
+\r
+ Current Udp implementation creates an IP child for each Udp child.\r
+ It initates a asynchronous receive immediately no matter whether\r
+ there is no mapping or not. Therefore, disable the returning EFI_NO_MAPPING for now.\r
+ To enable it, the following check must be performed:\r
+\r
+ if (NetIp6IsUnspecifiedAddr (&Config->StationAddress) && IP6_NO_MAPPING (IpInstance)) {\r
+ Status = EFI_NO_MAPPING;\r
+ goto Exit;\r
+ }\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to a token that is associated with the receive data descriptor.\r
+\r
+ @retval EFI_SUCCESS The receive completion token was cached.\r
+ @retval EFI_NOT_STARTED This EFI IPv6 Protocol instance has not been started.\r
+ @retval EFI_NO_MAPPING When IP6 driver responsible for binding source address to this instance,\r
+ while no source address is available for use.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - Token is NULL.\r
+ - Token.Event is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system\r
+ resources (usually memory).\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ The EFI IPv6 Protocol instance has been reset to startup defaults.\r
+ @retval EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already\r
+ in the receive queue.\r
+ @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Receive (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN EFI_IP6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ IP6_PROTOCOL *IpInstance;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+ IP6_SERVICE *IpSb;\r
+\r
+ if (This == NULL || Token == NULL || Token->Event == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ if (IpInstance->State != IP6_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // Check whether the toke is already on the receive queue.\r
+ //\r
+ Status = NetMapIterate (&IpInstance->RxTokens, Ip6TokenExist, Token);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_ACCESS_DENIED;\r
+ goto Exit;\r
+ }\r
+\r
+ //\r
+ // Queue the token then check whether there is pending received packet.\r
+ //\r
+ Status = NetMapInsertTail (&IpInstance->RxTokens, Token, NULL);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto Exit;\r
+ }\r
+\r
+ Status = Ip6InstanceDeliverPacket (IpInstance);\r
+\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of this instane's receive\r
+ // event.\r
+ //\r
+ DispatchDpc ();\r
+\r
+Exit:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Cancel the transmitted but not recycled packet. If a matching\r
+ token is found, it will call Ip6CancelPacket to cancel the\r
+ packet. Ip6CancelPacket cancels all the fragments of the\r
+ packet. When all the fragments are freed, the IP6_TXTOKEN_WRAP\r
+ is deleted from the Map, and user's event is signalled.\r
+ Because Ip6CancelPacket and other functions are all called in\r
+ line, after Ip6CancelPacket returns, the Item has been freed.\r
+\r
+ @param[in] Map The IP6 child's transmit queue.\r
+ @param[in] Item The current transmitted packet to test.\r
+ @param[in] Context The user's token to cancel.\r
+\r
+ @retval EFI_SUCCESS Continue to check the next Item.\r
+ @retval EFI_ABORTED The user's Token (Token != NULL) is cancelled.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip6CancelTxTokens (\r
+ IN NET_MAP *Map,\r
+ IN NET_MAP_ITEM *Item,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_IP6_COMPLETION_TOKEN *Token;\r
+ IP6_TXTOKEN_WRAP *Wrap;\r
+\r
+ Token = (EFI_IP6_COMPLETION_TOKEN *) Context;\r
+\r
+ //\r
+ // Return EFI_SUCCESS to check the next item in the map if\r
+ // this one doesn't match.\r
+ //\r
+ if ((Token != NULL) && (Token != Item->Key)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Wrap = (IP6_TXTOKEN_WRAP *) Item->Value;\r
+ ASSERT (Wrap != NULL);\r
+\r
+ //\r
+ // Don't access the Item, Wrap and Token's members after this point.\r
+ // Item and wrap has been freed. And we no longer own the Token.\r
+ //\r
+ Ip6CancelPacket (Wrap->IpInstance->Interface, Wrap->Packet, EFI_ABORTED);\r
+\r
+ //\r
+ // If only one item is to be cancel, return EFI_ABORTED to stop\r
+ // iterating the map any more.\r
+ //\r
+ if (Token != NULL) {\r
+ return EFI_ABORTED;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Cancel the receive request. This is simple, because\r
+ it is only enqueued in our local receive map.\r
+\r
+ @param[in] Map The IP6 child's receive queue.\r
+ @param[in] Item Current receive request to cancel.\r
+ @param[in] Context The user's token to cancel.\r
+\r
+\r
+ @retval EFI_SUCCESS Continue to check the next receive request on the\r
+ queue.\r
+ @retval EFI_ABORTED The user's token (token != NULL) has been\r
+ cancelled.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Ip6CancelRxTokens (\r
+ IN NET_MAP *Map,\r
+ IN NET_MAP_ITEM *Item,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_IP6_COMPLETION_TOKEN *Token;\r
+ EFI_IP6_COMPLETION_TOKEN *This;\r
+\r
+ Token = (EFI_IP6_COMPLETION_TOKEN *) Context;\r
+ This = Item->Key;\r
+\r
+ if ((Token != NULL) && (Token != This)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ NetMapRemoveItem (Map, Item, NULL);\r
+\r
+ This->Status = EFI_ABORTED;\r
+ This->Packet.RxData = NULL;\r
+ gBS->SignalEvent (This->Event);\r
+\r
+ if (Token != NULL) {\r
+ return EFI_ABORTED;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Cancel the user's receive/transmit request. It is the worker function of\r
+ EfiIp6Cancel API.\r
+\r
+ @param[in] IpInstance The IP6 child.\r
+ @param[in] Token The token to cancel. If NULL, all token will be\r
+ cancelled.\r
+\r
+ @retval EFI_SUCCESS The token is cancelled.\r
+ @retval EFI_NOT_FOUND The token isn't found on either the\r
+ transmit/receive queue.\r
+ @retval EFI_DEVICE_ERROR Not all tokens are cancelled when Token is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip6Cancel (\r
+ IN IP6_PROTOCOL *IpInstance,\r
+ IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // First check the transmitted packet. Ip6CancelTxTokens returns\r
+ // EFI_ABORTED to mean that the token has been cancelled when\r
+ // token != NULL. So, return EFI_SUCCESS for this condition.\r
+ //\r
+ Status = NetMapIterate (&IpInstance->TxTokens, Ip6CancelTxTokens, Token);\r
+ if (EFI_ERROR (Status)) {\r
+ if ((Token != NULL) && (Status == EFI_ABORTED)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Check the receive queue. Ip6CancelRxTokens also returns EFI_ABORT\r
+ // for Token!=NULL and it is cancelled.\r
+ //\r
+ Status = NetMapIterate (&IpInstance->RxTokens, Ip6CancelRxTokens, Token);\r
+ //\r
+ // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's\r
+ // events.\r
+ //\r
+ DispatchDpc ();\r
+ if (EFI_ERROR (Status)) {\r
+ if ((Token != NULL) && (Status == EFI_ABORTED)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // OK, if the Token is found when Token != NULL, the NetMapIterate\r
+ // will return EFI_ABORTED, which has been interrupted as EFI_SUCCESS.\r
+ //\r
+ if (Token != NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ //\r
+ // If Token == NULL, cancel all the tokens. return error if not\r
+ // all of them are cancelled.\r
+ //\r
+ if (!NetMapIsEmpty (&IpInstance->TxTokens) || !NetMapIsEmpty (&IpInstance->RxTokens)) {\r
+\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Abort an asynchronous transmit or receive request.\r
+\r
+ The Cancel() function is used to abort a pending transmit or receive request.\r
+ If the token is in the transmit or receive request queues, after calling this\r
+ function, Token->Status will be set to EFI_ABORTED, and then Token->Event will\r
+ be signaled. If the token is not in one of the queues, which usually means the\r
+ asynchronous operation has completed, this function will not signal the token,\r
+ and EFI_NOT_FOUND is returned.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to a token that has been issued by\r
+ EFI_IP6_PROTOCOL.Transmit() or\r
+ EFI_IP6_PROTOCOL.Receive(). If NULL, all pending\r
+ tokens are aborted. Type EFI_IP6_COMPLETION_TOKEN is\r
+ defined in EFI_IP6_PROTOCOL.Transmit().\r
+\r
+ @retval EFI_SUCCESS The asynchronous I/O request was aborted and\r
+ Token->Event was signaled. When Token is NULL, all\r
+ pending requests were aborted, and their events were signaled.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was\r
+ not found in the transmit or receive queue. It has either completed\r
+ or was not issued by Transmit() and Receive().\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Cancel (\r
+ IN EFI_IP6_PROTOCOL *This,\r
+ IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL\r
+ )\r
+{\r
+ IP6_PROTOCOL *IpInstance;\r
+ IP6_SERVICE *IpSb;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ if (IpInstance->State != IP6_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto Exit;\r
+ }\r
+\r
+ Status = Ip6Cancel (IpInstance, Token);\r
+\r
+Exit:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Polls for incoming data packets, and processes outgoing data packets.\r
+\r
+ The Poll() function polls for incoming data packets and processes outgoing data\r
+ packets. Network drivers and applications can call the EFI_IP6_PROTOCOL.Poll()\r
+ function to increase the rate that data packets are moved between the communications\r
+ device and the transmit and receive queues.\r
+\r
+ In some systems the periodic timer event may not poll the underlying communications\r
+ device fast enough to transmit and/or receive all data packets without missing\r
+ incoming packets or dropping outgoing packets. Drivers and applications that are\r
+ experiencing packet loss should try calling the EFI_IP6_PROTOCOL.Poll() function\r
+ more often.\r
+\r
+ @param[in] This Pointer to the EFI_IP6_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_NOT_STARTED This EFI IPv6 Protocol instance has not been started.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred.\r
+ @retval EFI_NOT_READY No incoming or outgoing data was processed.\r
+ @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r
+ Consider increasing the polling rate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiIp6Poll (\r
+ IN EFI_IP6_PROTOCOL *This\r
+ )\r
+{\r
+ IP6_PROTOCOL *IpInstance;\r
+ IP6_SERVICE *IpSb;\r
+ EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);\r
+ IpSb = IpInstance->Service;\r
+\r
+ if (IpSb->LinkLocalDadFail) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ if (IpInstance->State == IP6_STATE_UNCONFIGED) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ Mnp = IpInstance->Service->Mnp;\r
+\r
+ //\r
+ // Don't lock the Poll function to enable the deliver of\r
+ // the packet polled up.\r
+ //\r
+ return Mnp->Poll (Mnp);\r
+\r
+}\r
+\r