/** @file\r
Helper functions for configuring or getting the parameters relating to iSCSI.\r
\r
-Copyright (c) 2004 - 2017, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include "IScsiImpl.h"\r
\r
CHAR16 mVendorStorageName[] = L"ISCSI_CONFIG_IFR_NVDATA";\r
-BOOLEAN mIScsiDeviceListUpdated = FALSE;\r
-UINTN mNumberOfIScsiDevices = 0;\r
ISCSI_FORM_CALLBACK_INFO *mCallbackInfo = NULL;\r
\r
HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = {\r
{\r
END_DEVICE_PATH_TYPE,\r
END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- { \r
+ {\r
(UINT8) (END_DEVICE_PATH_LENGTH),\r
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
}\r
L"CHAP Name or CHAP Secret is invalid!",\r
NULL\r
);\r
- \r
+\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
&Key,\r
L"Reverse CHAP Name or Reverse CHAP Secret is invalid!",\r
NULL\r
- ); \r
+ );\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r
if (AttemptName2 == NULL) {\r
FreePool (AttemptName1);\r
return EFI_OUT_OF_RESOURCES;\r
- } \r
+ }\r
\r
AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_SIZE);\r
AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_SIZE);\r
&Key,\r
mPrivate->PortString,\r
NULL\r
- ); \r
+ );\r
\r
FreePool (AttemptName1);\r
FreePool (AttemptName2);\r
PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, mPrivate->PortString, NULL);\r
if (PortTitleHelpToken == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
- goto Exit; \r
+ goto Exit;\r
}\r
\r
HiiCreateGotoOpCode (\r
Exit:\r
HiiFreeOpCodeHandle (StartOpCodeHandle);\r
HiiFreeOpCodeHandle (EndOpCodeHandle);\r
- \r
+\r
return Status;\r
}\r
\r
/**\r
Add the attempts by keyword 'iSCSIAddAttempts', you can use this keyword with\r
value 'attempt:1 attempt:2' etc to add one or more attempts once. This is different\r
- with IScsiConfigAddAttempt function which is used to add attempt by UI configuration. \r
+ with IScsiConfigAddAttempt function which is used to add attempt by UI configuration.\r
\r
@param[in] AttemptList The new attempt List will be added.\r
\r
//\r
\r
AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);\r
- if (AttemptConfigData == NULL) {\r
- Status = EFI_NOT_FOUND;\r
- goto Error;\r
- }\r
\r
//\r
// Remove this attempt from UI configured attempt list.\r
FORMID_DELETE_FORM, // Form ID\r
StartOpCodeHandle, // Label for where to insert opcodes\r
EndOpCodeHandle // Replace data\r
- ); \r
+ );\r
\r
HiiFreeOpCodeHandle (StartOpCodeHandle);\r
HiiFreeOpCodeHandle (EndOpCodeHandle);\r
EFI_IFR_GUID_LABEL *StartLabel;\r
VOID *EndOpCodeHandle;\r
EFI_IFR_GUID_LABEL *EndLabel;\r
- VOID *OptionsOpCodeHandle; \r
- \r
+ VOID *OptionsOpCodeHandle;\r
+\r
Status = IScsiCreateOpCode (\r
ORDER_ENTRY_LABEL,\r
&StartOpCodeHandle,\r
DYNAMIC_ORDERED_LIST_QUESTION_ID, // Question ID\r
CONFIGURATION_VARSTORE_ID, // VarStore ID\r
DYNAMIC_ORDERED_LIST_VAR_OFFSET, // Offset in Buffer Storage\r
- STRING_TOKEN (STR_ORDER_ATTEMPT_ENTRY), // Question prompt text \r
- STRING_TOKEN (STR_ORDER_ATTEMPT_ENTRY), // Question help text \r
+ STRING_TOKEN (STR_ORDER_ATTEMPT_ENTRY), // Question prompt text\r
+ STRING_TOKEN (STR_ORDER_ATTEMPT_ENTRY), // Question help text\r
0, // Question flag\r
EFI_IFR_UNIQUE_SET, // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET\r
EFI_IFR_NUMERIC_SIZE_1, // Data type of Question value\r
ISCSI_MAX_ATTEMPTS_NUM, // Maximum container\r
- OptionsOpCodeHandle, // Option Opcode list \r
- NULL // Default Opcode is NULL \r
+ OptionsOpCodeHandle, // Option Opcode list\r
+ NULL // Default Opcode is NULL\r
);\r
\r
Exit:\r
FORMID_ORDER_FORM, // Form ID\r
StartOpCodeHandle, // Label for where to insert opcodes\r
EndOpCodeHandle // Replace data\r
- ); \r
+ );\r
\r
Error:\r
HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle); \r
+ HiiFreeOpCodeHandle (EndOpCodeHandle);\r
if (OptionsOpCodeHandle != NULL) {\r
HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
}\r
if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) {\r
continue;\r
}\r
- \r
+\r
break;\r
}\r
- \r
+\r
if (Index > PcdGet8 (PcdMaxIScsiAttemptNumber)) {\r
CreatePopUp (\r
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
// Generate OUI-format ISID based on MAC address.\r
//\r
CopyMem (AttemptConfigData->SessionConfigData.IsId, &NicInfo->PermanentAddress, 6);\r
- AttemptConfigData->SessionConfigData.IsId[0] = \r
+ AttemptConfigData->SessionConfigData.IsId[0] =\r
(UINT8) (AttemptConfigData->SessionConfigData.IsId[0] & 0x3F);\r
\r
//\r
ZeroMem (IfrNvData->ReverseCHAPName, sizeof (IfrNvData->ReverseCHAPName));\r
ZeroMem (IfrNvData->ReverseCHAPSecret, sizeof (IfrNvData->ReverseCHAPSecret));\r
}\r
- \r
+\r
IScsiConvertAttemptConfigDataToIfrNvData (AttemptConfigData, IfrNvData);\r
\r
//\r
\r
\r
/**\r
- \r
+\r
This function allows the caller to request the current\r
configuration for one or more named elements. The resulting\r
string is in <ConfigAltResp> format. Also, any and all alternative\r
to the most recent "&" before the first\r
failing name / value pair (or the beginning\r
of the string if the failure is in the first\r
- name / value pair) if the request was not successful. \r
+ name / value pair) if the request was not successful.\r
\r
@param[out] Results A null-terminated Unicode string in\r
<ConfigAltResp> format which has all values\r
would result in this type of\r
error. In this case, the\r
Progress parameter would be\r
- set to NULL. \r
+ set to NULL.\r
\r
@retval EFI_NOT_FOUND Routing data doesn't match any\r
known driver. Progress set to the\r
FreePool (IfrNvData);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- \r
+\r
Status = gIScsiInitiatorName.Get (&gIScsiInitiatorName, &BufferSize, InitiatorName);\r
if (EFI_ERROR (Status)) {\r
IfrNvData->InitiatorName[0] = L'\0';\r
\r
\r
/**\r
- \r
+\r
This function applies changes in a driver's configuration.\r
Input is a Configuration, which has the routing data for this\r
driver followed by name / value configuration pairs. The driver\r
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
\r
@param[in] Configuration A null-terminated Unicode string in\r
- <ConfigString> format. \r
- \r
+ <ConfigString> format.\r
+\r
@param[out] Progress A pointer to a string filled in with the\r
offset of the most recent '&' before the\r
first failing name / value pair (or the\r
\r
@retval EFI_SUCCESS The results have been distributed or are\r
awaiting distribution.\r
- \r
+\r
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the\r
parts of the results that must be\r
stored awaiting possible future\r
protocols.\r
- \r
+\r
@retval EFI_INVALID_PARAMETERS Passing in a NULL for the\r
Results parameter would result\r
in this type of error.\r
- \r
+\r
@retval EFI_NOT_FOUND Target for the specified routing data\r
was not found.\r
\r
}\r
\r
/**\r
- \r
+\r
This function is called to provide results data to the driver.\r
This data consists of a unique key that is used to identify\r
which data is either being passed back or being asked for.\r
@param[in] Action Specifies the type of action taken by the browser.\r
@param[in] QuestionId A unique value which is sent to the original\r
exporting driver so that it can identify the type\r
- of data to expect. The format of the data tends to \r
+ of data to expect. The format of the data tends to\r
vary based on the opcode that generated the callback.\r
@param[in] Type The type of value for the question.\r
@param[in, out] Value A pointer to the data being sent to the original\r
}\r
\r
Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
- \r
+\r
//\r
// Retrieve uncommitted data from Browser\r
//\r
- \r
+\r
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
IfrNvData = AllocateZeroPool (BufferSize);\r
if (IfrNvData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- \r
+\r
IScsiName = (CHAR8 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE);\r
if (IScsiName == NULL) {\r
FreePool (IfrNvData);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- \r
+\r
Status = EFI_SUCCESS;\r
- \r
+\r
ZeroMem (&OldIfrNvData, BufferSize);\r
- \r
+\r
HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);\r
- \r
+\r
CopyMem (&OldIfrNvData, IfrNvData, BufferSize);\r
\r
if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
&Key,\r
L"Error: please configure iSCSI initiator name first!",\r
NULL\r
- ); \r
+ );\r
break;\r
}\r
- \r
+\r
Status = IScsiConfigAddAttempt ();\r
break;\r
\r
);\r
IScsiConfigDisplayOrderAttempts ();\r
break;\r
- \r
+\r
default:\r
Status = IScsiConfigProcessDefault (QuestionId, IfrNvData);\r
break;\r
}\r
- } else if (Action == EFI_BROWSER_ACTION_CHANGED) { \r
+ } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
switch (QuestionId) {\r
case KEY_INITIATOR_NAME:\r
UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, IScsiName, ISCSI_NAME_MAX_SIZE);\r
&Key,\r
L"Invalid iSCSI Name!",\r
NULL\r
- ); \r
+ );\r
}\r
\r
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
break;\r
- \r
+\r
case KEY_SAVE_ATTEMPT_CONFIG:\r
Status = IScsiConvertIfrNvDataToAttemptConfigData (IfrNvData, Private->Current);\r
if (EFI_ERROR (Status)) {\r
case KEY_IP_MODE:\r
switch (Value->u8) {\r
case IP_MODE_IP6:\r
- NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex); \r
+ NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex);\r
if(NicInfo == NULL) {\r
break;\r
}\r
\r
- if(!NicInfo->Ipv6Available) { \r
- //\r
- // Current NIC doesn't Support IPv6, hence use IPv4. \r
- // \r
+ if(!NicInfo->Ipv6Available) {\r
+ //\r
+ // Current NIC doesn't Support IPv6, hence use IPv4.\r
+ //\r
IfrNvData->IpMode = IP_MODE_IP4;\r
- \r
+\r
CreatePopUp (\r
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
&Key,\r
NULL\r
);\r
}\r
- \r
+\r
case IP_MODE_IP4:\r
ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp));\r
ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask));\r
ZeroMem (&Private->Current->SessionConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
ZeroMem (&Private->Current->SessionConfigData.Gateway, sizeof (EFI_IP_ADDRESS));\r
ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (EFI_IP_ADDRESS));\r
- \r
+\r
break;\r
}\r
\r
\r
case KEY_LOCAL_IP:\r
Status = NetLibStrToIp4 (IfrNvData->LocalIp, &HostIp.v4);\r
- if (EFI_ERROR (Status) || \r
- ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && \r
+ if (EFI_ERROR (Status) ||\r
+ ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&\r
!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {\r
CreatePopUp (\r
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
&Key,\r
L"Invalid IP address!",\r
NULL\r
- ); \r
- \r
+ );\r
+\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));\r
&Key,\r
L"Invalid Subnet Mask!",\r
NULL\r
- ); \r
- \r
+ );\r
+\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
\r
case KEY_GATE_WAY:\r
Status = NetLibStrToIp4 (IfrNvData->Gateway, &Gateway.v4);\r
- if (EFI_ERROR (Status) || \r
- ((Gateway.Addr[0] != 0) && \r
- (Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && \r
+ if (EFI_ERROR (Status) ||\r
+ ((Gateway.Addr[0] != 0) &&\r
+ (Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&\r
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {\r
CreatePopUp (\r
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
&Key,\r
L"Invalid Gateway!",\r
NULL\r
- ); \r
+ );\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));\r
&Key,\r
L"Invalid LUN string!",\r
NULL\r
- ); \r
+ );\r
} else {\r
CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));\r
}\r
NULL\r
);\r
ASSERT_EFI_ERROR (Status);\r
- \r
+\r
//\r
// Publish our HII data.\r
//\r