X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIScsiDxe%2FIScsiConfig.c;h=cb1eff1b690cc8494bc631e6f3e2c0497f64e992;hp=e263f0e306b68134970ca5caf6c6cdc139245d86;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hpb=d28c4ed72bb390b1152c114b0b34374428956871 diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c index e263f0e306..cb1eff1b69 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 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, 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 @@ -39,7 +39,7 @@ HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = { { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, - { + { (UINT8) (END_DEVICE_PATH_LENGTH), (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) } @@ -180,7 +180,7 @@ IScsiConvertIsIdToString ( Update the list of iSCSI devices the iSCSI driver is controlling. @retval EFI_SUCCESS The callback successfully handled the action. - @retval Others Other errors as indicated. + @retval Others Other errors as indicated. **/ EFI_STATUS IScsiUpdateDeviceList ( @@ -445,7 +445,7 @@ IScsiConvertDeviceConfigDataToIfrNvData ( would result in this type of error. In this case, the Progress parameter would be - set to NULL. + set to NULL. @retval EFI_NOT_FOUND Routing data doesn't match any known driver. Progress set to the first character in the routing header. @@ -579,7 +579,7 @@ IScsiFormExtractConfig ( @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Configuration A null-terminated Unicode string in - format. + format. @param[out] Progress A pointer to a string filled in with the offset of the most recent '&' before the first failing name / value pair (or the @@ -589,7 +589,7 @@ IScsiFormExtractConfig ( successful. @retval EFI_SUCCESS The results have been distributed or are - awaiting distribution. + awaiting distribution. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the parts of the results that must be stored awaiting possible future @@ -634,7 +634,7 @@ IScsiFormRouteConfig ( @param[in] Action Specifies the type of action taken by the browser. @param[in] QuestionId A unique value which is sent to the original exporting driver so that it can identify the type - of data to expect. The format of the data tends to + of data to expect. The format of the data tends to vary based on the opcode that enerated the callback. @param[in] Type The type of value for the question. @param[in] Value A pointer to the data being sent to the original @@ -648,8 +648,8 @@ IScsiFormRouteConfig ( @retval EFI_DEVICE_ERROR The variable could not be saved. @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.Currently not implemented. - @retval EFI_INVALID_PARAMETERS Passing in wrong parameter. - @retval Others Other errors as indicated. + @retval EFI_INVALID_PARAMETERS Passing in wrong parameter. + @retval Others Other errors as indicated. **/ EFI_STATUS EFIAPI @@ -684,7 +684,7 @@ IScsiFormCallback ( Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This); // - // Retrive uncommitted data from Browser + // Retrieve uncommitted data from Browser // IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA)); ASSERT (IfrNvData != NULL); @@ -711,7 +711,7 @@ IScsiFormCallback ( Private->Current = ConfigFormEntry; } } else if (Action == EFI_BROWSER_ACTION_CHANGED) { - switch (QuestionId) { + switch (QuestionId) { case KEY_INITIATOR_NAME: IScsiUnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName); BufferSize = AsciiStrSize (IScsiName); @@ -727,7 +727,9 @@ IScsiFormCallback ( case KEY_LOCAL_IP: IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String); Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4); - if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (EFI_ERROR (Status) || + ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && + !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -751,7 +753,10 @@ IScsiFormCallback ( case KEY_GATE_WAY: IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String); Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4); - if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { + if (EFI_ERROR (Status) || + ((Gateway.Addr[0] != 0) && + (Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && + !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -763,7 +768,7 @@ IScsiFormCallback ( case KEY_TARGET_IP: IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String); Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4); - if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST (EFI_NTOHL(HostIp.v4)) || IP4_IS_UNSPECIFIED (EFI_NTOHL(HostIp.v4))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -778,7 +783,7 @@ IScsiFormCallback ( if (EFI_ERROR (Status)) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL); } else { - AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName); + AsciiStrCpyS (Private->Current->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName); } break; @@ -867,7 +872,7 @@ IScsiFormCallback ( // if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) { CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4)); - if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (IP4_IS_UNSPECIFIED (NTOHL (HostIp.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (HostIp.Addr[0]))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL); Status = EFI_INVALID_PARAMETER; break; @@ -939,9 +944,9 @@ IScsiFormCallback ( // HiiSetBrowserData (&gIp4IScsiConfigGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData, NULL); } - + FreePool (IfrNvData); - + return Status; } @@ -1028,12 +1033,12 @@ 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] = (UINT8) (ConfigFormEntry->SessionConfigData.IsId[0] & 0x3F); } // @@ -1071,6 +1076,7 @@ IScsiConfigUpdateForm ( mNumberOfIScsiDevices--; RemoveEntryList (&ConfigFormEntry->Link); FreePool (ConfigFormEntry); + mCallbackInfo->Current = NULL; } // // Allocate space for creation of Buffer @@ -1183,7 +1189,7 @@ IScsiConfigFormInit ( NULL ); ASSERT_EFI_ERROR (Status); - + // // Publish our HII data // @@ -1210,7 +1216,7 @@ IScsiConfigFormInit ( free the resources used. @param[in] DriverBindingHandle The iSCSI driverbinding handle. - + @retval EFI_SUCCESS The iSCSI configuration form is unloaded. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. **/