mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
f3c5971626
commit
312e3bdfcc
|
@ -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.
|
||||
|
|
|
@ -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),
|
||||
|
|
Binary file not shown.
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue