summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
diff options
context:
space:
mode:
authortye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-06 07:19:38 +0000
committertye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-06 07:19:38 +0000
commit312e3bdfccc5b2dffa23fcc450a3cca51828009e (patch)
treeeb1d193188c24b18343f992317b508f642f14c02 /MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
parentf3c59716269340784b2045b483f4c1c0deab017e (diff)
downloadedk2-platforms-312e3bdfccc5b2dffa23fcc450a3cca51828009e.tar.xz
Update ISID to fixed value: first 3 bytes are derived from MAC address while the other 3 bytes are configurable via ISCSI configuration.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11507 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c')
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c133
1 files changed, 132 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
index 2f9806e20a..1b4c7ad75e 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
@@ -1,7 +1,7 @@
/** @file
Helper functions for configuring or getting the parameters relating to iSCSI.
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -65,6 +65,121 @@ IScsiIpToStr (
UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);
}
+
+/**
+ Parse IsId in string format and convert it to binary.
+
+ @param[in] String The buffer of the string to be parsed.
+ @param[in, out] IsId The buffer to store IsId.
+
+ @retval EFI_SUCCESS The operation finished successfully.
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
+
+**/
+EFI_STATUS
+IScsiParseIsIdFromString (
+ IN CONST CHAR16 *String,
+ IN OUT UINT8 *IsId
+ )
+{
+ UINT8 Index;
+ CHAR16 *IsIdStr;
+ CHAR16 TempStr[3];
+ UINTN NodeVal;
+ CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];
+ EFI_INPUT_KEY Key;
+
+ if ((String == NULL) || (IsId == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IsIdStr = (CHAR16 *) String;
+
+ if (StrLen (IsIdStr) != 6) {
+ UnicodeSPrint (
+ PortString,
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
+ L"Error! Input is incorrect, please input 6 hex numbers!\n"
+ );
+
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ PortString,
+ NULL
+ );
+
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (Index = 3; Index < 6; Index++) {
+ CopyMem (TempStr, IsIdStr, sizeof (TempStr));
+ TempStr[2] = L'\0';
+
+ //
+ // Convert the string to IsId. StrHexToUintn stops at the first character
+ // that is not a valid hex character, '\0' here.
+ //
+ NodeVal = StrHexToUintn (TempStr);
+
+ IsId[Index] = (UINT8) NodeVal;
+
+ IsIdStr = IsIdStr + 2;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Convert IsId from binary to string format.
+
+ @param[out] String The buffer to store the converted string.
+ @param[in] IsId The buffer to store IsId.
+
+ @retval EFI_SUCCESS The string converted successfully.
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
+
+**/
+EFI_STATUS
+IScsiConvertIsIdToString (
+ OUT CHAR16 *String,
+ IN UINT8 *IsId
+ )
+{
+ UINT8 Index;
+ UINTN Number;
+
+ if ((String == NULL) || (IsId == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (Index = 0; Index < 6; Index++) {
+ if (IsId[Index] <= 0xF) {
+ Number = UnicodeSPrint (
+ String,
+ 2 * ISID_CONFIGURABLE_STORAGE,
+ L"0%X",
+ (UINTN) IsId[Index]
+ );
+ } else {
+ Number = UnicodeSPrint (
+ String,
+ 2 * ISID_CONFIGURABLE_STORAGE,
+ L"%X",
+ (UINTN) IsId[Index]
+ );
+
+ }
+
+ String = String + Number;
+ }
+
+ *String = L'\0';
+
+ return EFI_SUCCESS;
+}
+
+
/**
Update the list of iSCSI devices the iSCSI driver is controlling.
@@ -241,6 +356,7 @@ IScsiGetConfigFormEntryByIndex (
@param[in] ConfigFormEntry The iSCSI configuration form entry.
@param[out] IfrNvData The IFR nv data.
+
**/
VOID
IScsiConvertDeviceConfigDataToIfrNvData (
@@ -270,6 +386,8 @@ IScsiConvertDeviceConfigDataToIfrNvData (
IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun);
+ IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId);
+
//
// CHAP authentication parameters.
//
@@ -688,6 +806,12 @@ IScsiFormCallback (
IScsiUnicodeStrToAsciiStr (IfrNvData->ReverseCHAPSecret, Private->Current->AuthConfigData.ReverseCHAPSecret);
break;
+ case KEY_CONFIG_ISID:
+ IScsiParseIsIdFromString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);
+ IScsiConvertIsIdToString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);
+
+ break;
+
case KEY_SAVE_CHANGES:
//
// First, update those fields which don't have INTERACTIVE set.
@@ -890,6 +1014,13 @@ IScsiConfigUpdateForm (
);
if (EFI_ERROR (Status)) {
ZeroMem (&ConfigFormEntry->SessionConfigData, sizeof (ConfigFormEntry->SessionConfigData));
+
+ //
+ // Generate OUI-format ISID based on MAC address.
+ //
+ CopyMem (ConfigFormEntry->SessionConfigData.IsId, &MacAddress, 6);
+ ConfigFormEntry->SessionConfigData.IsId[0] =
+ ConfigFormEntry->SessionConfigData.IsId[0] & 0x3F;
}
//
// Get the CHAP authentication configuration data.