summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Network/IScsiDxe
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
parentf3c59716269340784b2045b483f4c1c0deab017e (diff)
downloadedk2-312e3bdfccc5b2dffa23fcc450a3cca51828009e.zip
edk2-312e3bdfccc5b2dffa23fcc450a3cca51828009e.tar.gz
edk2-312e3bdfccc5b2dffa23fcc450a3cca51828009e.tar.bz2
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')
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c133
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr13
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.unibin6662 -> 7248 bytes
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h9
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h4
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c18
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h7
7 files changed, 162 insertions, 22 deletions
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
index 2f9806e..1b4c7ad 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.
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
index 101902b..fca8cfd 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
@@ -1,7 +1,7 @@
/** @file
Vfr file for iSCSI config.
-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
@@ -193,6 +193,17 @@ formset
subtitle text = STRING_TOKEN(STR_NULL);
+ string varid = ISCSI_CONFIG_IFR_NVDATA.IsId,
+ prompt = STRING_TOKEN(STR_ISCSI_CONFIG_ISID),
+ help = STRING_TOKEN(STR_ISCSI_CONFIG_ISID_HELP),
+ flags = INTERACTIVE,
+ key = KEY_CONFIG_ISID,
+ minsize = ISID_CONFIGURABLE_MIN_LEN,
+ maxsize = ISID_CONFIGURABLE_MAX_LEN,
+ endstring;
+
+ subtitle text = STRING_TOKEN(STR_NULL);
+
goto FORMID_DEVICE_FORM,
prompt = STRING_TOKEN (STR_SAVE_CHANGES),
help = STRING_TOKEN (STR_SAVE_CHANGES),
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
index 42ca5a6..140f242 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
Binary files differ
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
index d51af3a..7c26ff3 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
@@ -1,7 +1,7 @@
/** @file
Define NVData structures used by the iSCSI configuration component
-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
@@ -63,6 +63,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define KEY_SAVE_CHANGES 0x10b
#define KEY_TARGET_NAME 0x10c
#define KEY_BOOT_LUN 0x10d
+#define KEY_CONFIG_ISID 0x10e
#define KEY_DEVICE_ENTRY_BASE 0x1000
@@ -76,6 +77,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define ISCSI_CHAP_NAME_MAX_LEN 126
+#define ISID_CONFIGURABLE_MIN_LEN 6
+#define ISID_CONFIGURABLE_MAX_LEN 12
+#define ISID_CONFIGURABLE_STORAGE 13
+
#pragma pack(1)
typedef struct {
CHAR16 InitiatorName[ISCSI_NAME_MAX_SIZE];
@@ -98,6 +103,8 @@ typedef struct {
CHAR16 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
CHAR16 ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];
CHAR16 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
+
+ CHAR16 IsId[ISID_CONFIGURABLE_STORAGE];
} ISCSI_CONFIG_IFR_NVDATA;
#pragma pack()
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
index 4322bf6..512c67c 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
@@ -1,7 +1,7 @@
/** @file
Miscellaneous definitions for iSCSI driver.
-Copyright (c) 2004 - 2009, 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
@@ -33,6 +33,8 @@ typedef struct {
EFI_IPv4_ADDRESS TargetIp;
UINT16 TargetPort;
UINT8 BootLun[8];
+
+ UINT8 IsId[6];
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
index 2390737..3836053 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
@@ -1,7 +1,7 @@
/** @file
The implementation of iSCSI protocol based on RFC3720.
-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
@@ -303,6 +303,11 @@ IScsiSessionLogin (
}
//
+ // Set session identifier
+ //
+ CopyMem (Session->Isid, Session->ConfigData.NvData.IsId, 6);
+
+ //
// Create a connection for the session.
//
Conn = IScsiCreateConnection (Private, Session);
@@ -2681,21 +2686,10 @@ IScsiSessionInit (
IN BOOLEAN Recovery
)
{
- UINT32 Random;
-
if (!Recovery) {
Session->Signature = ISCSI_SESSION_SIGNATURE;
Session->State = SESSION_STATE_FREE;
- Random = NET_RANDOM (NetRandomInitSeed ());
-
- Session->Isid[0] = ISID_BYTE_0;
- Session->Isid[1] = ISID_BYTE_1;
- Session->Isid[2] = ISID_BYTE_2;
- Session->Isid[3] = ISID_BYTE_3;
- Session->Isid[4] = (UINT8) Random;
- Session->Isid[5] = (UINT8) (Random >> 8);
-
InitializeListHead (&Session->Conns);
InitializeListHead (&Session->TcbList);
}
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
index e8022cb..cac98c8 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
@@ -1,7 +1,7 @@
/** @file
The header file of iSCSI Protocol that defines many specific data structures.
-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
@@ -42,11 +42,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define ISCSI_VERSION_MAX 0x00
#define ISCSI_VERSION_MIN 0x00
-#define ISID_BYTE_0 0 // OUI format
-#define ISID_BYTE_1 0
-#define ISID_BYTE_2 0xaa
-#define ISID_BYTE_3 0x1
-
#define ISCSI_KEY_AUTH_METHOD "AuthMethod"
#define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"
#define ISCSI_KEY_DATA_DIGEST "DataDigest"