X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FMnpDxe%2FMnpMain.c;h=86004cda84323ef21ad87e78d2c8613edbd18194;hp=71f0a3cc5a4a905f97b13ce8978faa6dada167bd;hb=87f89c0840a042a683b966d2be8ecb015886cb39;hpb=3e8c18da0441069591e5aa218f378001b29512dd diff --git a/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c b/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c index 71f0a3cc5a..86004cda84 100644 --- a/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c +++ b/MdeModulePkg/Universal/Network/MnpDxe/MnpMain.c @@ -1,8 +1,7 @@ /** @file Implementation of Managed Network Protocol public services. - -Copyright (c) 2005 - 2007, Intel Corporation.
+Copyright (c) 2005 - 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 @@ -12,11 +11,8 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include "MnpImpl.h" -#include -#include - +#include "MnpImpl.h" /** Returns the operational parameters for the current MNP child driver. May also @@ -40,7 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @retval EFI_NOT_STARTED This MNP child driver instance has not been configured. The default values are returned in MnpConfigData if it is not NULL. - @retval Other The mode data could not be read. + @retval Others The mode data could not be read. **/ EFI_STATUS @@ -76,7 +72,7 @@ MnpGetModeData ( // // Copy the underlayer Snp mode data. // - Snp = Instance->MnpServiceData->Snp; + Snp = Instance->MnpServiceData->Snp; CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData)); } @@ -114,13 +110,13 @@ MnpGetModeData ( Note: Warning: Receive filter settings that overlap will consume extra processor and/or DMA resources and degrade system and network performance. - @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. - @param[in] MnpConfigData Pointer to configuration data that will be assigned - to the MNP child driver instance. If NULL, the MNP - child driver instance is reset to startup defaults - and all pending transmit and receive requests are - flushed. Type EFI_MANAGED_NETWORK_CONFIG_DATA is - defined in EFI_MANAGED_NETWORK_PROTOCOL.GetModeData(). + @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. + @param[in] MnpConfigData Pointer to configuration data that will be assigned + to the MNP child driver instance. If NULL, the MNP + child driver instance is reset to startup defaults + and all pending transmit and receive requests are + flushed. Type EFI_MANAGED_NETWORK_CONFIG_DATA is + defined in EFI_MANAGED_NETWORK_PROTOCOL.GetModeData(). @retval EFI_SUCCESS The operation completed successfully. @retval EFI_INVALID_PARAMETER One or more of the following conditions is @@ -140,7 +136,7 @@ MnpGetModeData ( @retval EFI_DEVICE_ERROR An unexpected network or system error occurred. The MNP child driver instance has been reset to startup defaults. - @retval Other The MNP child driver instance has been reset to + @retval Others The MNP child driver instance has been reset to startup defaults. **/ @@ -193,15 +189,15 @@ ON_EXIT: The McastIpToMac() function translates an IP multicast address to a hardware (MAC) multicast address. This function may be implemented by calling the - underlying EFI_SIMPLE_NETWORK.MCastIpToMac() function, which may also be + underlying EFI_SIMPLE_NETWORK. MCastIpToMac() function, which may also be unsupported in some MNP implementations. - @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. - @param[in] Ipv6Flag Set to TRUE to if IpAddress is an IPv6 multicast address. - Set to FALSE if IpAddress is an IPv4 multicast address. - @param[in] IpAddress Pointer to the multicast IP address (in network byte order) - to convert. - @param[out] MacAddress Pointer to the resulting multicast MAC address. + @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. + @param[in] Ipv6Flag Set to TRUE to if IpAddress is an IPv6 multicast address. + Set to FALSE if IpAddress is an IPv4 multicast address. + @param[in] IpAddress Pointer to the multicast IP address (in network byte + order) to convert. + @param[out] MacAddress Pointer to the resulting multicast MAC address. @retval EFI_SUCCESS The operation completed successfully. @retval EFI_INVALID_PARAMETER One of the following conditions is TRUE: @@ -215,7 +211,7 @@ ON_EXIT: @retval EFI_UNSUPPORTED The requested feature is unsupported in this MNP implementation. @retval EFI_DEVICE_ERROR An unexpected network or system error occurred. - @retval Other The address could not be converted. + @retval Others The address could not be converted. **/ EFI_STATUS EFIAPI @@ -230,22 +226,20 @@ MnpMcastIpToMac ( MNP_INSTANCE_DATA *Instance; EFI_SIMPLE_NETWORK_PROTOCOL *Snp; EFI_TPL OldTpl; + EFI_IPv6_ADDRESS *Ip6Address; if ((This == NULL) || (IpAddress == NULL) || (MacAddress == NULL)) { return EFI_INVALID_PARAMETER; } - if (Ipv6Flag) { - // - // Currently IPv6 isn't supported. - // - return EFI_UNSUPPORTED; - } + Ip6Address = &IpAddress->v6; - if (!IP4_IS_MULTICAST (EFI_NTOHL (*IpAddress))) { + if ((Ipv6Flag && !IP6_IS_MULTICAST (Ip6Address)) || + (!Ipv6Flag && !IP4_IS_MULTICAST (EFI_NTOHL (*IpAddress))) + ) { // - // The IPv4 address passed in is not a multicast address. + // The IP address passed in is not a multicast address. // return EFI_INVALID_PARAMETER; } @@ -263,17 +257,33 @@ MnpMcastIpToMac ( Snp = Instance->MnpServiceData->Snp; ASSERT (Snp != NULL); + ZeroMem (MacAddress, sizeof (EFI_MAC_ADDRESS)); + if (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) { - // - // Translate the IPv4 address into a multicast MAC address if the NIC is an - // ethernet NIC. - // - MacAddress->Addr[0] = 0x01; - MacAddress->Addr[1] = 0x00; - MacAddress->Addr[2] = 0x5E; - MacAddress->Addr[3] = (UINT8) (IpAddress->v4.Addr[1] & 0x7F); - MacAddress->Addr[4] = IpAddress->v4.Addr[2]; - MacAddress->Addr[5] = IpAddress->v4.Addr[3]; + if (!Ipv6Flag) { + // + // Translate the IPv4 address into a multicast MAC address if the NIC is an + // ethernet NIC according to RFC1112.. + // + MacAddress->Addr[0] = 0x01; + MacAddress->Addr[1] = 0x00; + MacAddress->Addr[2] = 0x5E; + MacAddress->Addr[3] = (UINT8) (IpAddress->v4.Addr[1] & 0x7F); + MacAddress->Addr[4] = IpAddress->v4.Addr[2]; + MacAddress->Addr[5] = IpAddress->v4.Addr[3]; + } else { + // + // Translate the IPv6 address into a multicast MAC address if the NIC is an + // ethernet NIC according to RFC2464. + // + + MacAddress->Addr[0] = 0x33; + MacAddress->Addr[1] = 0x33; + MacAddress->Addr[2] = Ip6Address->Addr[12]; + MacAddress->Addr[3] = Ip6Address->Addr[13]; + MacAddress->Addr[4] = Ip6Address->Addr[14]; + MacAddress->Addr[5] = Ip6Address->Addr[15]; + } Status = EFI_SUCCESS; } else { @@ -326,7 +336,7 @@ ON_EXIT: startup defaults. @retval EFI_UNSUPPORTED The requested feature is unsupported in this MNP implementation. - @retval Other The requested operation could not be completed. + @retval Others The requested operation could not be completed. The MNP multicast group settings are unchanged. **/ @@ -457,8 +467,8 @@ ON_EXIT: @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. @param[in] Token Pointer to a token associated with the transmit data - descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN is - defined in "Related Definitions" below. + descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN + is defined in "Related Definitions" below. @retval EFI_SUCCESS The transmit completion token was cached. @retval EFI_NOT_STARTED This MNP child driver instance has not been @@ -562,11 +572,11 @@ ON_EXIT: updates the Token.Status and Token.RxData fields and the Token.Event is signaled. - @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. - @param[in] Token Pointer to a token associated with the receive - data descriptor. Type - EFI_MANAGED_NETWORK_COMPLETION_TOKEN is defined in - EFI_MANAGED_NETWORK_PROTOCOL.Transmit(). + @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. + @param[in] Token Pointer to a token associated with the receive + data descriptor. Type + EFI_MANAGED_NETWORK_COMPLETION_TOKEN is defined in + EFI_MANAGED_NETWORK_PROTOCOL.Transmit(). @retval EFI_SUCCESS The receive completion token was cached. @retval EFI_NOT_STARTED This MNP child driver instance has not been @@ -636,7 +646,7 @@ MnpReceive ( // // Dispatch the DPC queued by the NotifyFunction of Token->Event. // - NetLibDispatchDpc (); + DispatchDpc (); } ON_EXIT: @@ -658,8 +668,8 @@ ON_EXIT: @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. @param[in] Token Pointer to a token that has been issued by EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or - EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all pending - tokens are aborted. + EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all + pending tokens are aborted. @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event was signaled. When Token is NULL, @@ -713,7 +723,7 @@ MnpCancel ( // // Dispatch the DPC queued by the NotifyFunction of the cancled token's events. // - NetLibDispatchDpc (); + DispatchDpc (); ON_EXIT: gBS->RestoreTPL (OldTpl); @@ -733,7 +743,7 @@ ON_EXIT: applications that are experiencing packet loss should try calling the Poll() function more often. - @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. + @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance. @retval EFI_SUCCESS Incoming or outgoing data was processed. @retval EFI_NOT_STARTED This MNP child driver instance has not been @@ -775,7 +785,10 @@ MnpPoll ( // Status = MnpReceivePacket (Instance->MnpServiceData); - NetLibDispatchDpc (); + // + // Dispatch the DPC queued by the NotifyFunction of rx token's events. + // + DispatchDpc (); ON_EXIT: gBS->RestoreTPL (OldTpl);