From 312e3bdfccc5b2dffa23fcc450a3cca51828009e Mon Sep 17 00:00:00 2001 From: tye1 Date: Wed, 6 Apr 2011 07:19:38 +0000 Subject: [PATCH] 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 --- .../Universal/Network/IScsiDxe/IScsiConfig.c | 133 +++++++++++++++++- .../Network/IScsiDxe/IScsiConfigDxe.vfr | 13 +- .../IScsiDxe/IScsiConfigDxeStrings.uni | Bin 6662 -> 7248 bytes .../Network/IScsiDxe/IScsiConfigNVDataStruc.h | 9 +- .../Universal/Network/IScsiDxe/IScsiMisc.h | 4 +- .../Universal/Network/IScsiDxe/IScsiProto.c | 18 +-- .../Universal/Network/IScsiDxe/IScsiProto.h | 7 +- 7 files changed, 162 insertions(+), 22 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.
+Copyright (c) 2004 - 2011, 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 @@ -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 101902b7e9..fca8cfd1b2 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.
+Copyright (c) 2004 - 2011, 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 @@ -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 42ca5a610df71de912effbee3ffe4c65ee937d47..140f2425a2c2af14e509fd960a65058a79cdf026 100644 GIT binary patch delta 415 zcmY+APfG$(6va;jxrtm2wrgme(oj^k%YWb^C8TZeY-U0j9T`(>WvkZ0`viRiY17B( z3kCk(2wGg;efQpT-Z^*XitR8+#_T4+O^Mk`eTRpYau%BLaTN|(Z4_g&W z_Nj2X=;{$}S+P=O8p`NZK9gL5YM>GMiqqE{Sfq*0=t8O(_Ebs!Vn&_NMPLRccRNmo z!i+nlkLgl8eBJ9#b;n!)ggJeJaD`D9!vrgzY?!%qE;u{;oxwA5BV-49!8(KA=T(&J zG&QFmYMf7QQJ7MP%-l!#I%kENdNuZ_t3fo07U4rkw}cJef_|+kIRJ61Z2rs`QMce< Oykd=a^3^&1-dh7aiA-|< delta 19 bcmca$(PlEikJ*61d}H8W@y#=&b}#|}NUjGz diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h index d51af3a92f..7c26ff377d 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.
+Copyright (c) 2004 - 2011, 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 @@ -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 4322bf6320..512c67c38c 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.
+Copyright (c) 2004 - 2011, 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 @@ -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 2390737f25..3836053d93 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.
+Copyright (c) 2004 - 2011, 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 @@ -302,6 +302,11 @@ IScsiSessionLogin ( return EFI_NO_MEDIA; } + // + // Set session identifier + // + CopyMem (Session->Isid, Session->ConfigData.NvData.IsId, 6); + // // Create a connection for the 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 e8022cb6c7..cac98c8b3d 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.
+Copyright (c) 2004 - 2011, 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 @@ -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"