/** @file\r
Helper functions for configuring or getting the parameters relating to iSCSI.\r
\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
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
UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);\r
}\r
\r
+\r
+/**\r
+ Parse IsId in string format and convert it to binary.\r
+\r
+ @param[in] String The buffer of the string to be parsed.\r
+ @param[in, out] IsId The buffer to store IsId.\r
+\r
+ @retval EFI_SUCCESS The operation finished successfully.\r
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiParseIsIdFromString (\r
+ IN CONST CHAR16 *String,\r
+ IN OUT UINT8 *IsId\r
+ )\r
+{\r
+ UINT8 Index;\r
+ CHAR16 *IsIdStr;\r
+ CHAR16 TempStr[3];\r
+ UINTN NodeVal;\r
+ CHAR16 PortString[ISCSI_NAME_IFR_MAX_SIZE];\r
+ EFI_INPUT_KEY Key;\r
+\r
+ if ((String == NULL) || (IsId == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ IsIdStr = (CHAR16 *) String;\r
+\r
+ if (StrLen (IsIdStr) != 6) {\r
+ UnicodeSPrint (\r
+ PortString,\r
+ (UINTN) ISCSI_NAME_IFR_MAX_SIZE,\r
+ L"Error! Input is incorrect, please input 6 hex numbers!\n"\r
+ );\r
+\r
+ CreatePopUp (\r
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+ &Key,\r
+ PortString,\r
+ NULL\r
+ );\r
+\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ for (Index = 3; Index < 6; Index++) {\r
+ CopyMem (TempStr, IsIdStr, sizeof (TempStr));\r
+ TempStr[2] = L'\0';\r
+\r
+ //\r
+ // Convert the string to IsId. StrHexToUintn stops at the first character\r
+ // that is not a valid hex character, '\0' here.\r
+ //\r
+ NodeVal = StrHexToUintn (TempStr);\r
+\r
+ IsId[Index] = (UINT8) NodeVal;\r
+\r
+ IsIdStr = IsIdStr + 2;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Convert IsId from binary to string format.\r
+\r
+ @param[out] String The buffer to store the converted string.\r
+ @param[in] IsId The buffer to store IsId.\r
+\r
+ @retval EFI_SUCCESS The string converted successfully.\r
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiConvertIsIdToString (\r
+ OUT CHAR16 *String,\r
+ IN UINT8 *IsId\r
+ )\r
+{\r
+ UINT8 Index;\r
+ UINTN Number;\r
+\r
+ if ((String == NULL) || (IsId == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ for (Index = 0; Index < 6; Index++) {\r
+ if (IsId[Index] <= 0xF) {\r
+ Number = UnicodeSPrint (\r
+ String,\r
+ 2 * ISID_CONFIGURABLE_STORAGE,\r
+ L"0%X",\r
+ (UINTN) IsId[Index]\r
+ );\r
+ } else {\r
+ Number = UnicodeSPrint (\r
+ String,\r
+ 2 * ISID_CONFIGURABLE_STORAGE,\r
+ L"%X",\r
+ (UINTN) IsId[Index]\r
+ );\r
+\r
+ }\r
+\r
+ String = String + Number;\r
+ }\r
+\r
+ *String = L'\0';\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
/**\r
Update the list of iSCSI devices the iSCSI driver is controlling.\r
\r
\r
@param[in] ConfigFormEntry The iSCSI configuration form entry.\r
@param[out] IfrNvData The IFR nv data.\r
+\r
**/\r
VOID\r
IScsiConvertDeviceConfigDataToIfrNvData (\r
\r
IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun);\r
\r
+ IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId);\r
+\r
//\r
// CHAP authentication parameters.\r
//\r
IScsiUnicodeStrToAsciiStr (IfrNvData->ReverseCHAPSecret, Private->Current->AuthConfigData.ReverseCHAPSecret);\r
break;\r
\r
+ case KEY_CONFIG_ISID:\r
+ IScsiParseIsIdFromString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);\r
+ IScsiConvertIsIdToString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);\r
+\r
+ break;\r
+\r
case KEY_SAVE_CHANGES:\r
//\r
// First, update those fields which don't have INTERACTIVE set.\r
);\r
if (EFI_ERROR (Status)) {\r
ZeroMem (&ConfigFormEntry->SessionConfigData, sizeof (ConfigFormEntry->SessionConfigData));\r
+ \r
+ //\r
+ // Generate OUI-format ISID based on MAC address.\r
+ //\r
+ CopyMem (ConfigFormEntry->SessionConfigData.IsId, &MacAddress, 6);\r
+ ConfigFormEntry->SessionConfigData.IsId[0] = \r
+ ConfigFormEntry->SessionConfigData.IsId[0] & 0x3F;\r
}\r
//\r
// Get the CHAP authentication configuration data.\r
/** @file\r
Vfr file for iSCSI config.\r
\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
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
subtitle text = STRING_TOKEN(STR_NULL); \r
\r
+ string varid = ISCSI_CONFIG_IFR_NVDATA.IsId, \r
+ prompt = STRING_TOKEN(STR_ISCSI_CONFIG_ISID),\r
+ help = STRING_TOKEN(STR_ISCSI_CONFIG_ISID_HELP),\r
+ flags = INTERACTIVE,\r
+ key = KEY_CONFIG_ISID,\r
+ minsize = ISID_CONFIGURABLE_MIN_LEN,\r
+ maxsize = ISID_CONFIGURABLE_MAX_LEN,\r
+ endstring;\r
+\r
+ subtitle text = STRING_TOKEN(STR_NULL); \r
+\r
goto FORMID_DEVICE_FORM, \r
prompt = STRING_TOKEN (STR_SAVE_CHANGES),\r
help = STRING_TOKEN (STR_SAVE_CHANGES),\r
/** @file\r
Define NVData structures used by the iSCSI configuration component\r
\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
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
#define KEY_SAVE_CHANGES 0x10b\r
#define KEY_TARGET_NAME 0x10c\r
#define KEY_BOOT_LUN 0x10d\r
+#define KEY_CONFIG_ISID 0x10e\r
\r
#define KEY_DEVICE_ENTRY_BASE 0x1000\r
\r
\r
#define ISCSI_CHAP_NAME_MAX_LEN 126\r
\r
+#define ISID_CONFIGURABLE_MIN_LEN 6\r
+#define ISID_CONFIGURABLE_MAX_LEN 12\r
+#define ISID_CONFIGURABLE_STORAGE 13\r
+\r
#pragma pack(1)\r
typedef struct {\r
CHAR16 InitiatorName[ISCSI_NAME_MAX_SIZE];\r
CHAR16 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];\r
CHAR16 ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];\r
CHAR16 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];\r
+\r
+ CHAR16 IsId[ISID_CONFIGURABLE_STORAGE];\r
} ISCSI_CONFIG_IFR_NVDATA;\r
#pragma pack()\r
\r
/** @file\r
Miscellaneous definitions for iSCSI driver.\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
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
EFI_IPv4_ADDRESS TargetIp;\r
UINT16 TargetPort;\r
UINT8 BootLun[8];\r
+\r
+ UINT8 IsId[6];\r
} ISCSI_SESSION_CONFIG_NVDATA;\r
#pragma pack()\r
\r
/** @file\r
The implementation of iSCSI protocol based on RFC3720.\r
\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
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
return EFI_NO_MEDIA;\r
}\r
\r
+ //\r
+ // Set session identifier\r
+ //\r
+ CopyMem (Session->Isid, Session->ConfigData.NvData.IsId, 6);\r
+\r
//\r
// Create a connection for the session.\r
//\r
IN BOOLEAN Recovery\r
)\r
{\r
- UINT32 Random;\r
-\r
if (!Recovery) {\r
Session->Signature = ISCSI_SESSION_SIGNATURE;\r
Session->State = SESSION_STATE_FREE;\r
\r
- Random = NET_RANDOM (NetRandomInitSeed ());\r
-\r
- Session->Isid[0] = ISID_BYTE_0;\r
- Session->Isid[1] = ISID_BYTE_1;\r
- Session->Isid[2] = ISID_BYTE_2;\r
- Session->Isid[3] = ISID_BYTE_3;\r
- Session->Isid[4] = (UINT8) Random;\r
- Session->Isid[5] = (UINT8) (Random >> 8);\r
-\r
InitializeListHead (&Session->Conns);\r
InitializeListHead (&Session->TcbList);\r
}\r
/** @file\r
The header file of iSCSI Protocol that defines many specific data structures.\r
\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
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
#define ISCSI_VERSION_MAX 0x00\r
#define ISCSI_VERSION_MIN 0x00\r
\r
-#define ISID_BYTE_0 0 // OUI format\r
-#define ISID_BYTE_1 0\r
-#define ISID_BYTE_2 0xaa\r
-#define ISID_BYTE_3 0x1\r
-\r
#define ISCSI_KEY_AUTH_METHOD "AuthMethod"\r
#define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"\r
#define ISCSI_KEY_DATA_DIGEST "DataDigest"\r