/** @file\r
Helper functions for configuring or getting the parameters relating to iSCSI.\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2004 - 2009, Intel Corporation.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
/**\r
Update the list of iSCSI devices the iSCSI driver is controlling.\r
- \r
+\r
@retval EFI_SUCCESS The callback successfully handled the action.\r
@retval Others Other errors as indicated. \r
**/\r
UINTN HandleIndex;\r
UINTN Index;\r
UINTN LastDeviceIndex;\r
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
- EFI_SIMPLE_NETWORK_MODE *Mode;\r
+ EFI_MAC_ADDRESS MacAddress;\r
+ UINTN HwAddressSize;\r
+ UINT16 VlanId;\r
ISCSI_MAC_INFO *CurMacInfo;\r
ISCSI_MAC_INFO TempMacInfo;\r
- CHAR16 MacString[65];\r
+ CHAR16 MacString[70];\r
UINTN DeviceListSize;\r
\r
//\r
- // Dump all the handles the Simple Network Protocol is installed on.\r
+ // Dump all the handles the Managed Network Service Binding Protocol is installed on.\r
//\r
Status = gBS->LocateHandleBuffer (\r
ByProtocol,\r
- &gEfiSimpleNetworkProtocolGuid,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\r
NULL,\r
&NumHandles,\r
&Handles\r
LastDeviceIndex = 0;\r
\r
for (HandleIndex = 0; HandleIndex < NumHandles; HandleIndex++) {\r
- gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-\r
- Mode = Snp->Mode;\r
+ Status = NetLibGetMacAddress (Handles[HandleIndex], &MacAddress, &HwAddressSize);\r
+ ASSERT (Status == EFI_SUCCESS);\r
+ VlanId = NetLibGetVlanId (Handles[HandleIndex]);\r
\r
for (Index = LastDeviceIndex; Index < DeviceList->NumDevice; Index++) {\r
CurMacInfo = &DeviceList->MacInfo[Index];\r
- if ((CurMacInfo->Len == Mode->HwAddressSize) &&\r
- (NET_MAC_EQUAL (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize))\r
+ if ((CurMacInfo->Len == HwAddressSize) &&\r
+ (CurMacInfo->VlanId == VlanId) &&\r
+ (NET_MAC_EQUAL (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize))\r
) {\r
//\r
// The previous configured NIC is still here.\r
// delete the variables\r
//\r
CurMacInfo = &DeviceList->MacInfo[Index];\r
- IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, MacString);\r
+ IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, CurMacInfo->VlanId, MacString);\r
gRT->SetVariable (MacString, &gEfiIScsiInitiatorNameProtocolGuid, 0, 0, NULL);\r
gRT->SetVariable (MacString, &mIScsiCHAPAuthInfoGuid, 0, 0, NULL);\r
}\r
\r
- gBS->FreePool (DeviceList);\r
+ FreePool (DeviceList);\r
} else if (Status != EFI_NOT_FOUND) {\r
- gBS->FreePool (Handles);\r
+ FreePool (Handles);\r
return Status;\r
}\r
//\r
DeviceList->NumDevice = (UINT8) NumHandles;\r
\r
for (Index = 0; Index < NumHandles; Index++) {\r
- gBS->HandleProtocol (Handles[Index], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
- Mode = Snp->Mode;\r
+ NetLibGetMacAddress (Handles[Index], &MacAddress, &HwAddressSize);\r
\r
CurMacInfo = &DeviceList->MacInfo[Index];\r
- CopyMem (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize);\r
- CurMacInfo->Len = (UINT8) Mode->HwAddressSize;\r
+ CopyMem (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize);\r
+ CurMacInfo->Len = (UINT8) HwAddressSize;\r
+ CurMacInfo->VlanId = NetLibGetVlanId (Handles[Index]);\r
}\r
\r
gRT->SetVariable (\r
DeviceList\r
);\r
\r
- gBS->FreePool (DeviceList);\r
- gBS->FreePool (Handles);\r
+ FreePool (DeviceList);\r
+ FreePool (Handles);\r
\r
return Status;\r
}\r
Results,\r
Progress\r
);\r
- gBS->FreePool (IfrNvData);\r
+ FreePool (IfrNvData);\r
return Status;\r
}\r
\r
case KEY_LOCAL_IP:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
- if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+ if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
case KEY_GATE_WAY:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);\r
- if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
+ if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
case KEY_TARGET_IP:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
- if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+ if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
//\r
if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {\r
CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));\r
- if (!Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+ if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
break;\r
ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry;\r
BOOLEAN EntryExisted;\r
EFI_STATUS Status;\r
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+ EFI_MAC_ADDRESS MacAddress;\r
+ UINTN HwAddressSize;\r
+ UINT16 VlanId;\r
CHAR16 PortString[128];\r
UINT16 FormIndex;\r
UINTN BufferSize;\r
ConfigFormEntry->Controller = Controller;\r
\r
//\r
- // Get the simple network protocol and convert the MAC address into\r
- // the formatted string.\r
+ // Get the MAC address and convert it into the formatted string.\r
//\r
- Status = gBS->HandleProtocol (\r
- Controller,\r
- &gEfiSimpleNetworkProtocolGuid,\r
- (VOID **)&Snp\r
- );\r
+ Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);\r
ASSERT (Status == EFI_SUCCESS);\r
+ VlanId = NetLibGetVlanId (Controller);\r
\r
- IScsiMacAddrToStr (&Snp->Mode->PermanentAddress, Snp->Mode->HwAddressSize, ConfigFormEntry->MacString);\r
+ IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, ConfigFormEntry->MacString);\r
\r
//\r
// Get the normal session configuration data.\r
\r
mNumberOfIScsiDevices--;\r
RemoveEntryList (&ConfigFormEntry->Link);\r
- gBS->FreePool (ConfigFormEntry);\r
+ FreePool (ConfigFormEntry);\r
}\r
//\r
// Allocate space for creation of Buffer\r
&mCallbackInfo->ConfigAccess,\r
NULL\r
);\r
- gBS->FreePool (mCallbackInfo);\r
+ FreePool (mCallbackInfo);\r
\r
return EFI_SUCCESS;\r
}\r