X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIScsiDxe%2FIScsiMisc.c;h=2e43b415ec593b899d16426991d0aca73229805f;hp=865acb090e429cea77a4fa79837871cd606be14d;hb=25a516ab1a9dfccf2b71ec15771e99192c307418;hpb=779ae3579848a36319d67a6ba012b4b9aa88aa6b diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index 865acb090e..2e43b415ec 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -1,8 +1,8 @@ /** @file Miscellaneous routines for iSCSI driver. -Copyright (c) 2004 - 2009, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2004 - 2013, 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 @@ -616,6 +616,59 @@ IScsiCleanDriverData ( FreePool (Private); } +/** + Check wheather the Controller is configured to use DHCP protocol. + + @param[in] Controller The handle of the controller. + + @retval TRUE The handle of the controller need the Dhcp protocol. + @retval FALSE The handle of the controller does not need the Dhcp protocol. + +**/ +BOOLEAN +IScsiDhcpIsConfigured ( + IN EFI_HANDLE Controller + ) +{ + EFI_STATUS Status; + EFI_MAC_ADDRESS MacAddress; + UINTN HwAddressSize; + UINT16 VlanId; + CHAR16 MacString[70]; + ISCSI_SESSION_CONFIG_NVDATA *ConfigDataTmp; + + // + // Get the mac string, it's the name of various variable + // + Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize); + if (EFI_ERROR (Status)) { + return FALSE; + } + VlanId = NetLibGetVlanId (Controller); + IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, MacString); + + // + // Get the normal configuration. + // + Status = GetVariable2 ( + MacString, + &gEfiIScsiInitiatorNameProtocolGuid, + (VOID**)&ConfigDataTmp, + NULL + ); + if (ConfigDataTmp == NULL || EFI_ERROR (Status)) { + return FALSE; + } + + if (ConfigDataTmp->Enabled && ConfigDataTmp->InitiatorInfoFromDhcp) { + FreePool (ConfigDataTmp); + return TRUE; + } + + FreePool (ConfigDataTmp); + return FALSE; +} + /** Get the various configuration data of this iSCSI instance. @@ -684,7 +737,7 @@ IScsiGetConfigData ( BufferSize = sizeof (Session->AuthData.AuthConfig); Status = gRT->GetVariable ( MacString, - &mIScsiCHAPAuthInfoGuid, + &gIScsiCHAPAuthInfoGuid, NULL, &BufferSize, &Session->AuthData.AuthConfig @@ -757,7 +810,19 @@ IScsiGetTcpConnDevicePath ( ) { DPathNode->Ipv4.LocalPort = 0; - DPathNode->Ipv4.StaticIpAddress = (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp); + DPathNode->Ipv4.StaticIpAddress = + (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp); + + IP4_COPY_ADDRESS ( + &DPathNode->Ipv4.GatewayIpAddress, + &Session->ConfigData.NvData.Gateway + ); + + IP4_COPY_ADDRESS ( + &DPathNode->Ipv4.SubnetMask, + &Session->ConfigData.NvData.SubnetMask + ); + break; }